From: Mikko Rasa Date: Mon, 24 Dec 2007 23:06:24 +0000 (+0000) Subject: Implement the rest of fullscreen mode (video mode switching, pointer grab) X-Git-Tag: 0.9~14 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7c7c2cdce368b09b8b07bab860874440c7bc3c14;p=libs%2Fgui.git Implement the rest of fullscreen mode (video mode switching, pointer grab) --- diff --git a/source/display.cpp b/source/display.cpp index 724318a..b8e4fbe 100644 --- a/source/display.cpp +++ b/source/display.cpp @@ -59,19 +59,25 @@ Display::Display(const string &disp_name) XSetErrorHandler(x_error_handler); + int screen=DefaultScreen(display); + int nmodes; XF86VidModeModeInfo **infos; - XF86VidModeGetAllModeLines(display, DefaultScreen(display), &nmodes, &infos); + XF86VidModeGetAllModeLines(display, screen, &nmodes, &infos); for(int i=0; i modes; + VideoMode orig_mode; std::map windows; public: @@ -43,6 +47,7 @@ public: const std::list &get_modes() const { return modes; } void set_mode(const VideoMode &); + void restore_mode() { set_mode(orig_mode); } void tick(); void check_error(); diff --git a/source/window.cpp b/source/window.cpp index f867faf..2241956 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -48,6 +48,9 @@ Window::~Window() XDestroyWindow(display.get_display(), window); display.remove_window(this); + + if(options.fullscreen) + display.restore_mode(); } void Window::set_title(const string &title) @@ -88,6 +91,12 @@ void Window::init() XSetWMProtocols(dpy, window, &wm_delete_window, 1); + if(options.fullscreen) + { + display.set_mode(VideoMode(options.width, options.height)); + XWarpPointer(dpy, None, window, 0, 0, 0, 0, options.width/2, options.height/2); + } + display.add_window(this); display.check_error(); } @@ -128,6 +137,10 @@ void Window::event(const XEvent &ev) case EnterNotify: XSetInputFocus(display.get_display(), window, RevertToParent, CurrentTime); break; + case MapNotify: + if(options.fullscreen) + XGrabPointer(display.get_display(), window, true, None, GrabModeAsync, GrabModeAsync, window, None, CurrentTime); + break; default:; } }