From 95480fceabec2dd6354b87a200b4a219b39d4f0a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 17 Sep 2016 02:08:45 +0300 Subject: [PATCH] Implement additional fullscreen options for Window --- source/graphics/window.cpp | 9 +++++++-- source/graphics/window.h | 3 +++ source/graphics/x11/window.cpp | 12 ++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/source/graphics/window.cpp b/source/graphics/window.cpp index 958667e..d27f41f 100644 --- a/source/graphics/window.cpp +++ b/source/graphics/window.cpp @@ -15,6 +15,8 @@ WindowOptions::WindowOptions(): width(640), height(480), fullscreen(false), + fullscreen_monitor(0), + fullscreen_exclusive(true), resizable(false) { } @@ -90,11 +92,14 @@ void Window::reconfigure(const WindowOptions &opts) void Window::set_fullscreen_mode() { + if(!options.fullscreen_monitor) + options.fullscreen_monitor = display.get_desktop_mode().monitor; 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); - display.set_mode(mode, true); + display.set_mode(mode, options.fullscreen_exclusive); } void Window::set_keyboard_autorepeat(bool r) diff --git a/source/graphics/window.h b/source/graphics/window.h index 443cac7..b9a50fe 100644 --- a/source/graphics/window.h +++ b/source/graphics/window.h @@ -8,6 +8,7 @@ namespace Msp { namespace Graphics { class Display; +class Monitor; struct WindowOptions { @@ -17,6 +18,8 @@ struct WindowOptions unsigned width; unsigned height; bool fullscreen; + const Monitor *fullscreen_monitor; + bool fullscreen_exclusive; bool resizable; WindowOptions(); diff --git a/source/graphics/x11/window.cpp b/source/graphics/x11/window.cpp index 7513d3f..07ff755 100644 --- a/source/graphics/x11/window.cpp +++ b/source/graphics/x11/window.cpp @@ -111,7 +111,15 @@ void Window::platform_reconfigure(bool fullscreen_changed) 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 @@ -244,7 +252,7 @@ bool Window::event(const Event &evnt) 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: -- 2.43.0