From: Mikko Rasa Date: Mon, 6 Oct 2008 19:44:07 +0000 (+0000) Subject: Simplify invisible cursor creation X-Git-Tag: 1.0~1 X-Git-Url: http://git.tdb.fi/?p=libs%2Fgui.git;a=commitdiff_plain;h=8f8480438244fd04058049ace22071a8e2e0b85c Simplify invisible cursor creation Fullscreen mode fixes --- diff --git a/source/gbase/window.cpp b/source/gbase/window.cpp index 4aebc27..b9e3fa4 100644 --- a/source/gbase/window.cpp +++ b/source/gbase/window.cpp @@ -43,6 +43,11 @@ LRESULT CALLBACK wndproc_(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) return DefWindowProc(hwnd, msg, wparam, lparam); } +#else +Bool match_event_type(Display *, XEvent *event, XPointer arg) +{ + return event->type==reinterpret_cast(arg); +} #endif } @@ -143,6 +148,11 @@ void Window::reconfigure(const WindowOptions &opts) if(fullscreen_changed) { hide(); + + // Wait for the window to be unmapped. This makes window managers happy. + XEvent ev; + XPeekIfEvent(dpy, &ev, match_event_type, reinterpret_cast(UnmapNotify)); + XSetWindowAttributes attr; attr.override_redirect=options.fullscreen; XChangeWindowAttributes(dpy, priv->window, CWOverrideRedirect, &attr); @@ -186,12 +196,12 @@ void Window::show_cursor(bool s) if(!priv->invisible_cursor) { int screen=DefaultScreen(dpy); - char data=0; - XImage *img=XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, 0, &data, 1, 1, 8, 1); Pixmap pm=XCreatePixmap(dpy, priv->window, 1, 1, 1); GC gc=XCreateGC(dpy, pm, 0, 0); - XPutImage(dpy, pm, gc, img, 0, 0, 0, 0, 1, 1); + XSetFunction(dpy, gc, GXclear); + XDrawPoint(dpy, pm, gc, 0, 0); + XFreeGC(dpy, gc); XColor black; black.pixel=BlackPixel(dpy, screen); @@ -199,10 +209,7 @@ void Window::show_cursor(bool s) priv->invisible_cursor=XCreatePixmapCursor(dpy, pm, pm, &black, &black, 0, 0); - XFreeGC(dpy, gc); XFreePixmap(dpy, pm); - img->data=0; - XDestroyImage(img); } XDefineCursor(dpy, priv->window, priv->invisible_cursor); } @@ -215,7 +222,6 @@ void Window::show() ShowWindow(priv->window, SW_SHOWNORMAL); #else XMapRaised(display.get_private().display, priv->window); - display.check_error(); #endif } @@ -225,7 +231,6 @@ void Window::hide() ShowWindow(priv->window, SW_HIDE); #else XUnmapWindow(display.get_private().display, priv->window); - display.check_error(); #endif } @@ -405,7 +410,8 @@ bool Window::event(const Event &evnt) signal_close.emit(); break; case EnterNotify: - XSetInputFocus(display.get_private().display, priv->window, RevertToParent, CurrentTime); + if(options.fullscreen) + XSetInputFocus(display.get_private().display, priv->window, RevertToParent, CurrentTime); break; case MapNotify: if(options.fullscreen)