1 #include <msp/core/application.h>
4 #include "window_private.h"
11 WindowOptions::WindowOptions():
18 fullscreen_monitor(0),
19 fullscreen_exclusive(true),
24 Window::Window(Display &dpy, unsigned w, unsigned h, bool fs):
29 options.fullscreen = fs;
34 Window::Window(Display &dpy, const WindowOptions &opts):
44 kbd_autorepeat = true;
52 display.add_window(*this);
53 display.check_error();
55 const string &app_name = Application::get_name();
64 display.remove_window(*this);
66 if(options.fullscreen && visible)
67 display.restore_mode();
72 void Window::reconfigure(const WindowOptions &opts)
74 bool fullscreen_changed = (opts.fullscreen!=options.fullscreen);
75 if(opts.width!=options.width || opts.height!=options.height)
77 if(opts.x!=options.x || opts.y!=options.y)
84 if(options.fullscreen)
85 set_fullscreen_mode();
86 else if(fullscreen_changed)
87 display.restore_mode();
90 platform_reconfigure(fullscreen_changed);
93 void Window::set_fullscreen_mode()
95 if(!options.fullscreen_monitor)
96 options.fullscreen_monitor = display.get_desktop_mode().monitor;
97 VideoMode mode(options.width, options.height);
98 mode.monitor = options.fullscreen_monitor;
99 mode.rotation = mode.monitor->desktop_settings.rotation;
100 if(mode.rotation==ROTATE_LEFT || mode.rotation==ROTATE_RIGHT)
101 swap(mode.width, mode.height);
102 display.set_mode(mode, options.fullscreen_exclusive);
105 void Window::set_keyboard_autorepeat(bool r)
110 void Window::set_touch_input(bool t)
113 platform_set_touch_input();
121 if(options.fullscreen)
123 set_fullscreen_mode();
124 warp_pointer(options.width/2, options.height/2);
133 if(options.fullscreen)
134 display.restore_mode();
137 } // namespace Graphics