implemented SUPER key/modifier support on windows
[freeglut] / wayland / fg_gamemode_wl.c
1 /*
2  * fg_gamemode_wl.c
3  *
4  * The game mode handling code.
5  *
6  * Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
7  * Written by Manuel Bachmann, <tarnyko@tarnyko.net>
8  * Creation date: Sun Mar 23 2015
9  *
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:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
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.
26  */
27
28 #include <GL/freeglut.h>
29 #include "../fg_internal.h"
30
31 /* Pointer locking is a Weston-specific WIP protocol (for now)
32  *
33  * #include "pointer-lock-client-protocol.h"
34  * #include "relative-pointer-client-protocol.h"
35  *
36  * static struct _wl_relative_pointer_manager* relative_pointer_manager;
37  * static struct _wl_pointer_lock* pointer_lock;
38  *
39  * static struct _wl_relative_pointer* relative_pointer;
40  * static struct _wl_locked_pointer* locked_pointer;
41  *
42  *
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 )
47  * {
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 ) );
53  * }
54  * static const struct _wl_relative_pointer_listener
55  *                                fghRelativeListener =
56  * {
57  *   fghRelativeMotion
58  * };
59  *
60  * static void fghLockedLocked( void* data, struct _wl_locked_pointer
61  *                              pointer, uint32_t serial )
62  * {
63  *     fgPlatformRememberState();
64  *     fgPlatformSetCursor( win, GLUT_CURSOR_NONE ):
65  * }
66  * static void fghLockedUnlocked( void* data, struct _wl_locked_pointer
67  *                                pointer )
68  * {
69  *     fgPlatformRestoreState();
70  * }
71  * static const struct _wl_locked_pointer_listener
72  *                                 fghLockedListener =
73  * {
74  *   fghLockedLocked,
75  *   fghLockedUnlocked
76  * };
77  */
78
79
80 static struct wl_cursor* saved_cursor;
81
82 /*
83  * Remembers the current visual settings, so that
84  * we can change them and restore later...
85  */
86 void fgPlatformRememberState( void )
87 {
88     SFG_Window* win = fgStructure.CurrentWindow;
89     saved_cursor = win->Window.pContext.cursor;
90 }
91
92 /*
93  * Restores the previously remembered visual settings
94  */
95 void fgPlatformRestoreState( void )
96 {
97     SFG_Window* win = fgStructure.CurrentWindow;
98     win->Window.pContext.cursor = saved_cursor;
99 }
100
101 /*
102  *  * Private function to get the virtual maximum screen extent
103  *   */
104 GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
105 {
106     /*
107      * under Wayland, just return the size of the window,
108      * at least until we start messing with the outputs...
109      */
110     *x = window->State.Width;
111     *y = window->State.Height;
112 }
113
114 /*
115  * Changes the current display mode to match user's settings
116  */
117 GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
118 {
119     /* Such a protocol is being studied in Wayland */
120     return GL_FALSE;
121 }
122
123
124 void fgPlatformEnterGameMode( void )
125 {
126     SFG_Window* win = fgStructure.CurrentWindow;
127     struct wl_region* region;
128
129     region = wl_compositor_create_region (
130                                  fgDisplay.pDisplay.compositor );
131     wl_region_add( region, 0, 0,
132                    win->State.Width,
133                    win->State.Height );
134    /*
135     * relative_pointer =
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,
141     *                                    NULL );
142     * locked_pointer = _wl_pointer_lock_lock_pointer (
143     *                             pointer_lock,
144     *                             win->Window.pContext.surface,
145     *                             fgDisplay.pDisplay.seat,
146     *                             NULL);
147     * _wl_locked_pointer_add_listener( locked_pointer,
148     *                                  &fghLockedListener,
149     *                                  NULL );
150     */
151     wl_region_destroy( region );
152 }
153
154 void fgPlatformLeaveGameMode( void )
155 {
156    /* 
157     * _wl_locked_pointer_destroy( locked_pointer );
158     * _wl_relative_pointer_release( relative_pointer );
159     */
160 }
161