4 * Wayland-specific freeglut state query methods.
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"
30 #include "egl/fg_state_egl.h"
32 int fgPlatformGlutDeviceGet ( GLenum eWhat )
36 case GLUT_HAS_KEYBOARD:
37 if( fgDisplay.pDisplay.keyboard )
43 /* we want the touchscreen to behave like a mouse,
44 * so let us pretend it is one.
46 if( fgDisplay.pDisplay.pointer ||
47 fgDisplay.pDisplay.touch )
52 case GLUT_NUM_MOUSE_BUTTONS:
53 /* Wayland has no way of telling us how much buttons
54 * a mouse has, unless the actual event gets sent to
55 * the client. As we are only handling 3 buttons
56 * currently, return this fixed number for now.
58 if( fgDisplay.pDisplay.pointer )
60 /* touchscreen is considered as having one button */
61 else if( fgDisplay.pDisplay.touch )
67 fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
73 int fgPlatformGlutGet ( GLenum eWhat )
79 * Those calls are pointless under Wayland, so inform the user
84 if( fgStructure.CurrentWindow == NULL )
90 fgWarning( "glutGet(): GLUT_WINDOW_X/Y properties "
91 "unsupported under Wayland" );
97 * TODO : support this correctly once we will start drawing
98 * client-side decorations
100 case GLUT_WINDOW_BORDER_WIDTH:
101 case GLUT_WINDOW_HEADER_HEIGHT:
103 if( fgStructure.CurrentWindow == NULL ||
104 fgStructure.CurrentWindow->Parent )
105 /* can't get widths/heights if no current window
106 * and child windows don't have borders */
112 case GLUT_WINDOW_WIDTH:
113 case GLUT_WINDOW_HEIGHT:
115 if( fgStructure.CurrentWindow == NULL )
120 case GLUT_WINDOW_WIDTH:
121 return fgStructure.CurrentWindow->State.Width;
122 case GLUT_WINDOW_HEIGHT:
123 return fgStructure.CurrentWindow->State.Height;
127 /* Colormap size is handled in a bit different way than all the rest */
128 case GLUT_WINDOW_COLORMAP_SIZE:
130 if( fgStructure.CurrentWindow == NULL )
137 if ( ! eglGetConfigAttrib( fgDisplay.pDisplay.egl.Display,
138 fgStructure.CurrentWindow->Window.pContext.egl.Config,
139 EGL_BUFFER_SIZE, &result ) )
140 fgError( "eglGetConfigAttrib(EGL_BUFFER_SIZE) failed" );
147 return fghPlatformGlutGetEGL( eWhat );