]> git.tdb.fi Git - libs/gui.git/commitdiff
Simplify invisible cursor creation
authorMikko Rasa <tdb@tdb.fi>
Mon, 6 Oct 2008 19:44:07 +0000 (19:44 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 6 Oct 2008 19:44:07 +0000 (19:44 +0000)
Fullscreen mode fixes

source/gbase/window.cpp

index 4aebc27e0c1384688d0a82c1519f42844df77693..b9e3fa49790df373fd08b2420b5d908f6dced860 100644 (file)
@@ -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<int>(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<XPointer>(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)