From 6ae920c7b34b23b933d4191ce576288da9556ab7 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Wed, 8 Jan 2020 22:26:07 +0100 Subject: [PATCH] ~ disabling redrawing now possible ~ move statusbar elements a bit ~ use clang not g++ --- .gitlab-ci.yml | 4 ++-- src/GUI.cpp | 40 +++++++++++++++++++--------------------- src/GUI_Window.cpp | 7 ------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2815013..85d35f3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,7 @@ make_test: - docker-ci script: - apt-get update - - apt-get install -y g++ make cmake clang-tidy libfltk1.3 libfltk1.3-dev + - apt-get install -y clang make cmake clang-tidy libfltk1.3 libfltk1.3-dev - mkdir current - ls | grep -v current | xargs mv -t current - git clone https://github.com/catchorg/Catch2.git @@ -57,7 +57,7 @@ cmake_build: - docker-ci script: - apt-get update - - apt-get install -y g++ make cmake clang-tidy libfltk1.3 libfltk1.3-dev + - apt-get install -y clang make cmake clang-tidy libfltk1.3 libfltk1.3-dev - mkdir current - ls | grep -v current | xargs mv -t current - git clone https://github.com/catchorg/Catch2.git diff --git a/src/GUI.cpp b/src/GUI.cpp index 4688d11..a686db0 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -13,25 +13,25 @@ int width; int height; static void redrawCallback(void * pointer); -static void refreshCallback(void * pointer); int GUI_run(int argc, char **argv) { vkvm::initialize(0); + //vkvm::setLogLevel(vkvm::LogLevel::DEBUG); width = vkvm::getWidth(); height = vkvm::getHeight(); redrawInterval = vkvm::getRedrawInterval(); - char *resolution = get_resolution(width, height); - std::cout << resolution << std::endl; - auto *window = new GUI_Window(width, height + 30, "vKVM GUI"); + char * resolution = get_resolution(width, height); + vkvm::log(vkvm::LogLevel::DEBUG, resolution); + auto * window = new GUI_Window(width, height + 30, "vKVM GUI"); Statusbar *status[5]; window->begin(); auto *image = new Image(0, 30, width, height); - status[0] = new Statusbar(0, 0, 300, 30, resolution); - status[1] = new Statusbar(300, 0, 170, 30, "Event:"); - status[2] = new Statusbar(470, 0, 200, 30, "Mouse Position:"); + status[0] = new Statusbar(0, 0, 200, 30, resolution); + status[1] = new Statusbar(200, 0, 170, 30, "Event:"); + status[2] = new Statusbar(400, 0, 170, 30, "Mouse Position:"); vkvm::registerEvent(vkvm::EventType::Redraw, [image]() { image->getPixels(); image->redraw(); @@ -39,9 +39,14 @@ int GUI_run(int argc, char **argv) { vkvm::registerEvent(vkvm::EventType::UpdateControlRegisters, [image, window, status]() { int newRedrawInterval = vkvm::getRedrawInterval(); if(newRedrawInterval != redrawInterval) { - /*if(redrawInterval == -1 && newRedrawInterval != -1) { - refreshCallback(image); - }*/ + if(redrawInterval == -1 && newRedrawInterval != -1) { + vkvm::log(vkvm::LogLevel::DEBUG, "adding timeout"); + Fl::add_timeout(1.0, redrawCallback, image); + } + if(newRedrawInterval == -1) { + vkvm::log(vkvm::LogLevel::DEBUG, "removing timeout"); + Fl::remove_timeout(redrawCallback); + } redrawInterval = newRedrawInterval; } @@ -59,24 +64,17 @@ int GUI_run(int argc, char **argv) { } }); - Fl::repeat_timeout((double) redrawInterval / 1000, refreshCallback, image); + Fl::add_timeout(1.0, redrawCallback, image); window->end(); window->show(argc, argv); return Fl::run(); } -static void refreshCallback(void * pointer) { +static void redrawCallback(void * pointer) { auto *image = static_cast(pointer); image->getPixels(); - if(redrawInterval != -1) { - Fl::repeat_timeout((double) redrawInterval / 1000, redrawCallback, image); - } - -} - -static void redrawCallback(void * pointer) { - auto *image = static_cast(pointer); image->redraw(); - refreshCallback(image); + Fl::repeat_timeout(redrawInterval / 1000.0, redrawCallback, image); + } \ No newline at end of file diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index 073bf17..c260d64 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -13,17 +13,14 @@ auto GUI_Window::handle(int e) -> int { mouse_status |= Mouse_Status::left_down; this->child(2)->label("Event:Mouse Left Down"); vkvm::callEvent(vkvm::EventType::MouseLeftDown); - // std::cout<child(2)->label("Event:Mouse Right Down"); vkvm::callEvent(vkvm::EventType::MouseRightDown); - // std::cout<child(2)->label("Event:Mouse Middle Down"); vkvm::callEvent(vkvm::EventType::MouseMiddleDown); - // std::cout< int { mouse_status &= Mouse_Status::left_up; this->child(2)->label("Event:Mouse Left Up"); vkvm::callEvent(vkvm::EventType::MouseLeftUp); - // std::cout<child(2)->label("Event:Mouse Right Up"); vkvm::callEvent(vkvm::EventType::MouseRightUp); - // std::cout<child(2)->label("Event:Mouse Middle Up"); vkvm::callEvent(vkvm::EventType::MouseMiddleUp); - // std::cout< int { return 1; case FL_KEYUP: button = Fl::event_button(); - std::cout << button << std::endl; keyCode = vkvm::KeyCode(button); vkvm::buttonPressed(keyCode); vkvm::callEvent(vkvm::EventType::KeyUp);