]> git.tdb.fi Git - libs/gui.git/blobdiff - source/gbase/window.cpp
Fix compilation on 64-bit systems
[libs/gui.git] / source / gbase / window.cpp
index 08cb74db081807edd765c6a0115a40684c913696..089136003529f2fbd56a0c002ddcccdde88304ee 100644 (file)
@@ -9,6 +9,9 @@ Distributed under the LGPL
 #ifndef WIN32
 #include <X11/Xatom.h>
 #include <X11/Xutil.h>
+#ifdef WITH_XF86VIDMODE
+#include <X11/extensions/xf86vmode.h>
+#endif
 #else
 #include <windowsx.h>
 #endif
@@ -46,7 +49,7 @@ LRESULT CALLBACK wndproc_(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 #else
 Bool match_event_type(Display *, XEvent *event, XPointer arg)
 {
-       return event->type==reinterpret_cast<int>(arg);
+       return event->type==*reinterpret_cast<int *>(arg);
 }
 #endif
 
@@ -84,6 +87,7 @@ void Window::init()
 {
        visible=false;
        kbd_autorepeat=true;
+       resizing=false;
        priv=new Private;
 
 #ifdef WIN32
@@ -210,6 +214,7 @@ void Window::set_title(const string &title)
 void Window::reconfigure(const WindowOptions &opts)
 {
        bool fullscreen_changed=(opts.fullscreen!=options.fullscreen);
+       resizing=(opts.width!=options.width || opts.height!=options.height);
 
        options=opts;
 
@@ -238,25 +243,22 @@ void Window::reconfigure(const WindowOptions &opts)
 #else
        ::Display *dpy=display.get_private().display;
 
+       bool was_visible=visible;
        if(fullscreen_changed)
        {
-               bool was_visible=visible;
-
                if(was_visible)
                {
                        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));
+                       int ev_type=UnmapNotify;
+                       XPeekIfEvent(dpy, &ev, match_event_type, reinterpret_cast<char *>(&ev_type));
                }
 
                XSetWindowAttributes attr;
                attr.override_redirect=options.fullscreen;
                XChangeWindowAttributes(dpy, priv->window, CWOverrideRedirect, &attr);
-
-               if(was_visible)
-                       show();
        }
 
        XSizeHints hints;
@@ -274,6 +276,12 @@ void Window::reconfigure(const WindowOptions &opts)
                XMoveResizeWindow(dpy, priv->window, 0, 0, options.width, options.height);
        else
                XResizeWindow(dpy, priv->window, options.width, options.height);
+
+       if(fullscreen_changed)
+       {
+               if(was_visible)
+                       show();
+       }
 #endif
 
        if(visible)
@@ -442,9 +450,21 @@ bool Window::event(const Event &evnt)
                signal_key_release.emit(XKeycodeToKeysym(display.get_private().display, ev.xkey.keycode, 0), ev.xkey.state);
                break;
        case ConfigureNotify:
-               options.width=ev.xconfigure.width;
-               options.height=ev.xconfigure.height;
-               signal_resize.emit(options.width, options.height);
+               if((ev.xconfigure.width==static_cast<int>(options.width) && ev.xconfigure.height==static_cast<int>(options.height)) == resizing)
+               {
+                       options.width=ev.xconfigure.width;
+                       options.height=ev.xconfigure.height;
+                       resizing=false;
+                       signal_resize.emit(options.width, options.height);
+               }
+#ifdef WITH_XF86VIDMODE
+               if(options.fullscreen)
+               {
+                       ::Display *dpy=display.get_private().display;
+                       int screen=DefaultScreen(dpy);
+                       XF86VidModeSetViewPort(dpy, screen, ev.xconfigure.x, ev.xconfigure.y);
+               }
+#endif
                break;
        case ClientMessage:
                if(ev.xclient.data.l[0]==static_cast<long>(priv->wm_delete_window))