4 * The game mode handling code.
6 * Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
7 * Written by Manuel Bachmann, <tarnyko@tarnyko.net>
8 * Creation date: Sun Mar 23 2015
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include <GL/freeglut.h>
29 #include "../fg_internal.h"
31 /* Pointer locking is a Weston-specific WIP protocol (for now)
33 * #include "pointer-lock-client-protocol.h"
34 * #include "relative-pointer-client-protocol.h"
36 * static struct _wl_relative_pointer_manager* relative_pointer_manager;
37 * static struct _wl_pointer_lock* pointer_lock;
39 * static struct _wl_relative_pointer* relative_pointer;
40 * static struct _wl_locked_pointer* locked_pointer;
43 * static void fghRelativeMotion( void* data, struct _wl_relative_pointer
44 * pointer, uint32_t time,
45 * wl_fixed_t x_w, wl_fixed_t y_w,
46 * wl_fixed_t x_noacc, wl_fixed_t y_noacc )
48 * SFG_Window* win = fgStructure.CurrentWindow;
49 * win->State.MouseX = wl_fixed_to_int( x_w );
50 * win->State.MouseY = wl_fixed_to_int( y_w );
51 * INVOKE_WCB( *win, Passive, ( win->State.MouseX,
52 * win->State.MouseY ) );
54 * static const struct _wl_relative_pointer_listener
55 * fghRelativeListener =
60 * static void fghLockedLocked( void* data, struct _wl_locked_pointer
61 * pointer, uint32_t serial )
63 * fgPlatformRememberState();
64 * fgPlatformSetCursor( win, GLUT_CURSOR_NONE ):
66 * static void fghLockedUnlocked( void* data, struct _wl_locked_pointer
69 * fgPlatformRestoreState();
71 * static const struct _wl_locked_pointer_listener
80 static struct wl_cursor* saved_cursor;
83 * Remembers the current visual settings, so that
84 * we can change them and restore later...
86 void fgPlatformRememberState( void )
88 SFG_Window* win = fgStructure.CurrentWindow;
89 saved_cursor = win->Window.pContext.cursor;
93 * Restores the previously remembered visual settings
95 void fgPlatformRestoreState( void )
97 SFG_Window* win = fgStructure.CurrentWindow;
98 win->Window.pContext.cursor = saved_cursor;
102 * * Private function to get the virtual maximum screen extent
104 GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
107 * under Wayland, just return the size of the window,
108 * at least until we start messing with the outputs...
110 *x = window->State.Width;
111 *y = window->State.Height;
115 * Changes the current display mode to match user's settings
117 GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
119 /* Such a protocol is being studied in Wayland */
124 void fgPlatformEnterGameMode( void )
126 SFG_Window* win = fgStructure.CurrentWindow;
127 struct wl_region* region;
129 region = wl_compositor_create_region (
130 fgDisplay.pDisplay.compositor );
131 wl_region_add( region, 0, 0,
136 * _wl_relative_pointer_manager_get_relative_pointer (
137 * relative_pointer_manager,
138 * fgDisplay.pDisplay.seat );
139 * _wl_relative_pointer_add_listener( relative_pointer,
140 * &fghRelativeListener,
142 * locked_pointer = _wl_pointer_lock_lock_pointer (
144 * win->Window.pContext.surface,
145 * fgDisplay.pDisplay.seat,
147 * _wl_locked_pointer_add_listener( locked_pointer,
148 * &fghLockedListener,
151 wl_region_destroy( region );
154 void fgPlatformLeaveGameMode( void )
157 * _wl_locked_pointer_destroy( locked_pointer );
158 * _wl_relative_pointer_release( relative_pointer );