summaryrefslogtreecommitdiffstats
path: root/client/windows/platform.cpp
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2009-11-09 19:19:00 +0200
committerYaniv Kamay <ykamay@redhat.com>2009-11-09 22:10:50 +0200
commite74de7834dda657966f209b2cb23b145773a915f (patch)
tree93f52fc9973d6c41f2b5f32b3a98b6e238bc3a73 /client/windows/platform.cpp
parent2e4d70980591f5d5c675de7461a462b7859080af (diff)
downloadspice-e74de7834dda657966f209b2cb23b145773a915f.tar.gz
spice-e74de7834dda657966f209b2cb23b145773a915f.tar.xz
spice-e74de7834dda657966f209b2cb23b145773a915f.zip
spice client: calling the timers during modal loop in Windows
Diffstat (limited to 'client/windows/platform.cpp')
-rw-r--r--client/windows/platform.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index 0fe7b244..24c9ca93 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -43,6 +43,11 @@ static Platform::EventListener* event_listener = &default_event_listener;
static HWND paltform_win;
static ProcessLoop* main_loop = NULL;
+static const unsigned long MODAL_LOOP_TIMER_ID = 1;
+static const int MODAL_LOOP_DEFAULT_TIMEOUT = 100;
+static bool modal_loop_active = false;
+static bool set_modal_loop_timer();
+
void Platform::send_quit_request()
{
ASSERT(main_loop);
@@ -52,6 +57,15 @@ void Platform::send_quit_request()
static LRESULT CALLBACK PlatformWinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
+ case WM_TIMER:
+ if (modal_loop_active) {
+ main_loop->timers_action();
+ if (!set_modal_loop_timer()) {
+ LOG_WARN("failed to set modal loop timer");
+ }
+ } else {
+ LOG_WARN("received WM_TIMER not inside a modal loop");
+ }
case WM_ACTIVATEAPP:
if (wParam) {
event_listener->on_app_activated();
@@ -618,3 +632,41 @@ Icon* Platform::load_icon(int id)
}
return new WinIcon(icon);
}
+
+void WinPlatform::enter_modal_loop()
+{
+ if (modal_loop_active) {
+ LOG_INFO("modal loop already active");
+ return;
+ }
+
+ if (set_modal_loop_timer()) {
+ modal_loop_active = true;
+ } else {
+ LOG_WARN("failed to create modal loop timer");
+ }
+}
+
+static bool set_modal_loop_timer()
+{
+ int timeout = main_loop->get_soonest_timeout();
+ if (timeout == INFINITE) {
+ timeout = MODAL_LOOP_DEFAULT_TIMEOUT; /* for cases timeouts are added after
+ the enterance to the loop*/
+ }
+
+ if (!SetTimer(paltform_win, MODAL_LOOP_TIMER_ID, timeout, NULL)) {
+ return false;
+ }
+ return true;
+}
+
+void WinPlatform::exit_modal_loop()
+{
+ if (!modal_loop_active) {
+ LOG_INFO("not inside the loop");
+ return;
+ }
+ KillTimer(paltform_win, MODAL_LOOP_TIMER_ID);
+ modal_loop_active = false;
+}