]> git.tdb.fi Git - libs/gui.git/commitdiff
Implement additional fullscreen options for Window
authorMikko Rasa <tdb@tdb.fi>
Fri, 16 Sep 2016 23:08:45 +0000 (02:08 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 16 Sep 2016 23:08:45 +0000 (02:08 +0300)
source/graphics/window.cpp
source/graphics/window.h
source/graphics/x11/window.cpp

index 958667ead5698165d18508a7685f7ea1eebcfa9f..d27f41fd6fda9980cbf9192329335388e918d8c0 100644 (file)
@@ -15,6 +15,8 @@ WindowOptions::WindowOptions():
        width(640),
        height(480),
        fullscreen(false),
        width(640),
        height(480),
        fullscreen(false),
+       fullscreen_monitor(0),
+       fullscreen_exclusive(true),
        resizable(false)
 { }
 
        resizable(false)
 { }
 
@@ -90,11 +92,14 @@ void Window::reconfigure(const WindowOptions &opts)
 
 void Window::set_fullscreen_mode()
 {
 
 void Window::set_fullscreen_mode()
 {
+       if(!options.fullscreen_monitor)
+               options.fullscreen_monitor = display.get_desktop_mode().monitor;
        VideoMode mode(options.width, options.height);
        VideoMode mode(options.width, options.height);
-       mode.rotation = display.get_desktop_mode().monitor->desktop_settings.rotation;
+       mode.monitor = options.fullscreen_monitor;
+       mode.rotation = mode.monitor->desktop_settings.rotation;
        if(mode.rotation==ROTATE_LEFT || mode.rotation==ROTATE_RIGHT)
                swap(mode.width, mode.height);
        if(mode.rotation==ROTATE_LEFT || mode.rotation==ROTATE_RIGHT)
                swap(mode.width, mode.height);
-       display.set_mode(mode, true);
+       display.set_mode(mode, options.fullscreen_exclusive);
 }
 
 void Window::set_keyboard_autorepeat(bool r)
 }
 
 void Window::set_keyboard_autorepeat(bool r)
index 443cac79210afe3904b5cbc2008daceabc907197..b9a50fec520bf7baa813e5cbbaa71edc2f875a34 100644 (file)
@@ -8,6 +8,7 @@ namespace Msp {
 namespace Graphics {
 
 class Display;
 namespace Graphics {
 
 class Display;
+class Monitor;
 
 struct WindowOptions
 {
 
 struct WindowOptions
 {
@@ -17,6 +18,8 @@ struct WindowOptions
        unsigned width;
        unsigned height;
        bool fullscreen;
        unsigned width;
        unsigned height;
        bool fullscreen;
+       const Monitor *fullscreen_monitor;
+       bool fullscreen_exclusive;
        bool resizable;
 
        WindowOptions();
        bool resizable;
 
        WindowOptions();
index 7513d3ffb14ebb958efe5e7d9b33a9f65e0482e4..07ff75588c824ad17ab1cdd22b09572a7cd279de 100644 (file)
@@ -111,7 +111,15 @@ void Window::platform_reconfigure(bool fullscreen_changed)
        XSetWMNormalHints(dpy, priv->window, &hints);
 
        if(options.fullscreen)
        XSetWMNormalHints(dpy, priv->window, &hints);
 
        if(options.fullscreen)
-               XMoveResizeWindow(dpy, priv->window, 0, 0, options.width, options.height);
+       {
+               if(options.fullscreen_exclusive)
+                       XMoveResizeWindow(dpy, priv->window, 0, 0, options.width, options.height);
+               else
+               {
+                       const Monitor::Settings &ms = options.fullscreen_monitor->current_settings;
+                       XMoveResizeWindow(dpy, priv->window, ms.x, ms.y, options.width, options.height);
+               }
+       }
        else if(options.user_position)
                XMoveResizeWindow(dpy, priv->window, options.x, options.y, options.width, options.height);
        else
        else if(options.user_position)
                XMoveResizeWindow(dpy, priv->window, options.x, options.y, options.width, options.height);
        else
@@ -244,7 +252,7 @@ bool Window::event(const Event &evnt)
                        XSetInputFocus(display.get_private().display, priv->window, RevertToParent, CurrentTime);
                break;
        case MapNotify:
                        XSetInputFocus(display.get_private().display, priv->window, RevertToParent, CurrentTime);
                break;
        case MapNotify:
-               if(options.fullscreen)
+               if(options.fullscreen && options.fullscreen_exclusive)
                        XGrabPointer(display.get_private().display, priv->window, true, None, GrabModeAsync, GrabModeAsync, priv->window, None, CurrentTime);
                break;
        case Expose:
                        XGrabPointer(display.get_private().display, priv->window, true, None, GrabModeAsync, GrabModeAsync, priv->window, None, CurrentTime);
                break;
        case Expose: