X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgbase%2Fwindow.cpp;h=089136003529f2fbd56a0c002ddcccdde88304ee;hb=22d13842e2bc956f941b6372045c1aa6a062bc10;hp=08cb74db081807edd765c6a0115a40684c913696;hpb=a8e642edcf466cf92313cbf1f467a2d10de03fb4;p=libs%2Fgui.git diff --git a/source/gbase/window.cpp b/source/gbase/window.cpp index 08cb74d..0891360 100644 --- a/source/gbase/window.cpp +++ b/source/gbase/window.cpp @@ -9,6 +9,9 @@ Distributed under the LGPL #ifndef WIN32 #include #include +#ifdef WITH_XF86VIDMODE +#include +#endif #else #include #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(arg); + return event->type==*reinterpret_cast(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(UnmapNotify)); + int ev_type=UnmapNotify; + XPeekIfEvent(dpy, &ev, match_event_type, reinterpret_cast(&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(options.width) && ev.xconfigure.height==static_cast(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(priv->wm_delete_window))