From: Mikko Rasa Date: Thu, 15 Oct 2015 23:18:17 +0000 (+0300) Subject: Add a signal for window exposure X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=inline;h=05db7bfc90b3a3806080f34e463c57b9b3d87d31;p=libs%2Fgui.git Add a signal for window exposure Windows code is untested. --- 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; }