From 05db7bfc90b3a3806080f34e463c57b9b3d87d31 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 16 Oct 2015 02:18:17 +0300 Subject: [PATCH] Add a signal for window exposure Windows code is untested. --- source/graphics/window.h | 1 + source/graphics/windows/window.cpp | 9 +++++++++ source/graphics/x11/window.cpp | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/graphics/window.h b/source/graphics/window.h index 70b4044..b2c7833 100644 --- a/source/graphics/window.h +++ b/source/graphics/window.h @@ -31,6 +31,7 @@ public: sigc::signal signal_input_event; sigc::signal signal_resize; + sigc::signal signal_expose; sigc::signal signal_close; protected: diff --git a/source/graphics/windows/window.cpp b/source/graphics/windows/window.cpp index 2d4d75b..68baea7 100644 --- a/source/graphics/windows/window.cpp +++ b/source/graphics/windows/window.cpp @@ -183,6 +183,15 @@ bool Window::event(const Event &evnt) case WM_CLOSE: signal_close.emit(); break; + case WM_PAINT: + { + RECT update_rect; + GetUpdateRect(priv->window, &update_rect, false); + unsigned width = update_rect.right-update_rect.left; + unsigned height = update_rect.bottom-update_rect.top; + signal_expose.emit(update_rect.left, update_rect.top, width, height, evnt); + } + break; default: return false; } diff --git a/source/graphics/x11/window.cpp b/source/graphics/x11/window.cpp index 1747da9..fbaf36c 100644 --- a/source/graphics/x11/window.cpp +++ b/source/graphics/x11/window.cpp @@ -29,7 +29,7 @@ void Window::platform_init() XSetWindowAttributes attr; attr.override_redirect = options.fullscreen; - attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask; + attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|StructureNotifyMask|EnterWindowMask|ExposureMask; priv->window = XCreateWindow(dpy, DefaultRootWindow(dpy), @@ -198,6 +198,9 @@ bool Window::event(const Event &evnt) if(options.fullscreen) XGrabPointer(display.get_private().display, priv->window, true, None, GrabModeAsync, GrabModeAsync, priv->window, None, CurrentTime); break; + case Expose: + signal_expose.emit(ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, evnt); + break; default: return false; } -- 2.45.2