]> git.tdb.fi Git - libs/gui.git/commitdiff
Add a signal for window exposure
authorMikko Rasa <tdb@tdb.fi>
Thu, 15 Oct 2015 23:18:17 +0000 (02:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 15 Oct 2015 23:18:17 +0000 (02:18 +0300)
Windows code is untested.

source/graphics/window.h
source/graphics/windows/window.cpp
source/graphics/x11/window.cpp

index 70b40443d3d84575f93f4fefc51ffa99119da2c1..b2c7833c1db844957b09d39df9b1cbe6876dbdb5 100644 (file)
@@ -31,6 +31,7 @@ public:
        sigc::signal<void, const Event &> signal_input_event;
 
        sigc::signal<void, unsigned, unsigned> signal_resize;
+       sigc::signal<void, unsigned, unsigned, unsigned, unsigned, const Event &> signal_expose;
        sigc::signal<void> signal_close;
 
 protected:
index 2d4d75bead21b6a3f5b6e8208c454379479adcad..68baea71ed2d9c91a05d99ef42fd1fe844e3a8c8 100644 (file)
@@ -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;
        }
index 1747da9b2ba7198acd07873179284194ba4800ac..fbaf36c287a90928efe34dfa4dbaa3c7a887ff78 100644 (file)
@@ -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;
        }