2 #include "window_private.h"
3 #include <msp/core/application.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;
50 if(options.fullscreen && !options.fullscreen_monitor)
51 options.fullscreen_monitor = display.get_desktop_mode().monitor;
55 display.add_window(*this);
56 display.check_error();
58 const string &app_name = Application::get_name();
67 display.remove_window(*this);
69 if(options.fullscreen && visible)
70 display.restore_mode();
75 void Window::reconfigure(const WindowOptions &opts)
77 bool fullscreen_changed = (opts.fullscreen!=options.fullscreen);
78 if(opts.width!=options.width || opts.height!=options.height)
80 if(opts.x!=options.x || opts.y!=options.y)
87 if(options.fullscreen)
88 set_fullscreen_mode();
89 else if(fullscreen_changed)
90 display.restore_mode();
93 platform_reconfigure(fullscreen_changed);
96 void Window::set_fullscreen_mode()
98 if(!options.fullscreen_monitor)
99 options.fullscreen_monitor = display.get_desktop_mode().monitor;
100 VideoMode mode(options.width, options.height);
101 mode.monitor = options.fullscreen_monitor;
102 mode.rotation = mode.monitor->desktop_settings.rotation;
103 if(mode.rotation==ROTATE_LEFT || mode.rotation==ROTATE_RIGHT)
104 swap(mode.width, mode.height);
105 display.set_mode(mode, options.fullscreen_exclusive);
108 void Window::set_keyboard_autorepeat(bool r)
113 void Window::set_touch_input(bool t)
116 platform_set_touch_input();
124 if(options.fullscreen)
126 set_fullscreen_mode();
127 warp_pointer(options.width/2, options.height/2);
136 if(options.fullscreen)
137 display.restore_mode();
140 } // namespace Graphics