From: Mikko Rasa Date: Mon, 3 Aug 2009 12:26:54 +0000 (+0000) Subject: Various fixes to Window resizing and fullscreen handling on X11 X-Git-Tag: 1.1~1 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ac4a20591d64b08d435c88acce724a891a51d551;p=libs%2Fgui.git Various fixes to Window resizing and fullscreen handling on X11 Add fullscreen parameter to SimpleWindow constructors --- diff --git a/source/gbase/simplewindow.cpp b/source/gbase/simplewindow.cpp index aa34c04..406090d 100644 --- a/source/gbase/simplewindow.cpp +++ b/source/gbase/simplewindow.cpp @@ -10,13 +10,13 @@ Distributed under the LGPL namespace Msp { namespace Graphics { -SimpleWindow::SimpleWindow(unsigned w, unsigned h): - Window(dpy, w, h) +SimpleWindow::SimpleWindow(unsigned w, unsigned h, bool fs): + Window(dpy, w, h, fs) { } -SimpleGLWindow::SimpleGLWindow(unsigned w, unsigned h): - SimpleWindow(w, h), +SimpleGLWindow::SimpleGLWindow(unsigned w, unsigned h, bool fs): + SimpleWindow(w, h, fs), gl_ctx(*this) { } diff --git a/source/gbase/simplewindow.h b/source/gbase/simplewindow.h index a506636..1f5bb7d 100644 --- a/source/gbase/simplewindow.h +++ b/source/gbase/simplewindow.h @@ -33,7 +33,7 @@ A simplified Window that encapsulates a Display. class SimpleWindow: public SimpleWindowBase, public Window { public: - SimpleWindow(unsigned, unsigned); + SimpleWindow(unsigned, unsigned, bool =false); }; @@ -46,7 +46,7 @@ private: GLContext gl_ctx; public: - SimpleGLWindow(unsigned, unsigned); + SimpleGLWindow(unsigned, unsigned, bool =false); GLContext &get_gl_context() { return gl_ctx; } void swap_buffers(); }; diff --git a/source/gbase/window.cpp b/source/gbase/window.cpp index 08cb74d..06af1ae 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 @@ -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,10 +243,9 @@ 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(); @@ -254,9 +258,6 @@ void Window::reconfigure(const WindowOptions &opts) XSetWindowAttributes attr; attr.override_redirect=options.fullscreen; XChangeWindowAttributes(dpy, priv->window, CWOverrideRedirect, &attr); - - if(was_visible) - show(); } XSizeHints hints; @@ -274,6 +275,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 +449,19 @@ 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); + } + if(options.fullscreen) + { + ::Display *dpy=display.get_private().display; + int screen=DefaultScreen(dpy); + XF86VidModeSetViewPort(dpy, screen, ev.xconfigure.x, ev.xconfigure.y); + } break; case ClientMessage: if(ev.xclient.data.l[0]==static_cast(priv->wm_delete_window)) diff --git a/source/gbase/window.h b/source/gbase/window.h index ad575af..38ffb6d 100644 --- a/source/gbase/window.h +++ b/source/gbase/window.h @@ -45,6 +45,7 @@ protected: WindowOptions options; bool visible; bool kbd_autorepeat; + bool resizing; Private *priv; public: