X-Git-Url: http://git.tdb.fi/?p=libs%2Fgui.git;a=blobdiff_plain;f=source%2Fgraphics%2Fx11%2Fwindow.cpp;h=9b46e4e16593cfe4abe1e760d2cdf832a4593d26;hp=1747da9b2ba7198acd07873179284194ba4800ac;hb=f6ca714e2258f4cad433801c88264947d4c2d14c;hpb=1d7113259625a91f5f6d2f53365aad22ae744689 diff --git a/source/graphics/x11/window.cpp b/source/graphics/x11/window.cpp index 1747da9..9b46e4e 100644 --- a/source/graphics/x11/window.cpp +++ b/source/graphics/x11/window.cpp @@ -26,13 +26,16 @@ void Window::platform_init() priv->wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", true); priv->invisible_cursor = 0; + priv->reparented = false; + priv->rel_x = 0; + priv->rel_y = 0; 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), + display.get_private().root_window, 0, 0, options.width, options.height, 0, @@ -185,6 +188,46 @@ bool Window::event(const Event &evnt) resizing = false; signal_resize.emit(options.width, options.height); } + + { + int x = ev.xconfigure.x; + int y = ev.xconfigure.y; + + if(priv->reparented) + { + if(!ev.xconfigure.send_event) + { + /* If the window manager reparented us, the coordinates of a + real event are in the parent window's space. */ + priv->rel_x = ev.xconfigure.x; + priv->rel_y = ev.xconfigure.y; + + const Display::Private &dpy_priv = display.get_private(); + WindowHandle dummy; + XTranslateCoordinates(dpy_priv.display, priv->window, dpy_priv.root_window, 0, 0, &x, &y, &dummy); + } + + // Use the coordinates of the window manager frame + x -= priv->rel_x; + y -= priv->rel_y; + } + + if(x!=options.x || y!=options.y) + { + options.x = x; + options.y = y; + signal_move.emit(options.x, options.y); + } + } + + break; + case ReparentNotify: + priv->reparented = (ev.xreparent.parent!=display.get_private().root_window); + if(!priv->reparented) + { + priv->rel_x = 0; + priv->rel_y = 0; + } break; case ClientMessage: if(ev.xclient.data.l[0]==static_cast(priv->wm_delete_window)) @@ -198,6 +241,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; }