wl_monitor.c
Go to the documentation of this file.
1 //========================================================================
2 // GLFW 3.3 Wayland - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
5 //
6 // This software is provided 'as-is', without any express or implied
7 // warranty. In no event will the authors be held liable for any damages
8 // arising from the use of this software.
9 //
10 // Permission is granted to anyone to use this software for any purpose,
11 // including commercial applications, and to alter it and redistribute it
12 // freely, subject to the following restrictions:
13 //
14 // 1. The origin of this software must not be misrepresented; you must not
15 // claim that you wrote the original software. If you use this software
16 // in a product, an acknowledgment in the product documentation would
17 // be appreciated but is not required.
18 //
19 // 2. Altered source versions must be plainly marked as such, and must not
20 // be misrepresented as being the original software.
21 //
22 // 3. This notice may not be removed or altered from any source
23 // distribution.
24 //
25 //========================================================================
26 
27 #include "internal.h"
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <errno.h>
33 
34 
35 static void outputHandleGeometry(void* data,
36  struct wl_output* output,
37  int32_t x,
38  int32_t y,
39  int32_t physicalWidth,
40  int32_t physicalHeight,
41  int32_t subpixel,
42  const char* make,
43  const char* model,
45 {
46  struct _GLFWmonitor *monitor = data;
47  char name[1024];
48 
49  monitor->wl.x = x;
50  monitor->wl.y = y;
51  monitor->widthMM = physicalWidth;
52  monitor->heightMM = physicalHeight;
53 
54  snprintf(name, sizeof(name), "%s %s", make, model);
55  monitor->name = _glfw_strdup(name);
56 }
57 
58 static void outputHandleMode(void* data,
59  struct wl_output* output,
61  int32_t width,
64 {
65  struct _GLFWmonitor *monitor = data;
67 
68  mode.width = width;
69  mode.height = height;
70  mode.redBits = 8;
71  mode.greenBits = 8;
72  mode.blueBits = 8;
73  mode.refreshRate = refresh / 1000;
74 
75  monitor->modeCount++;
76  monitor->modes =
77  realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
78  monitor->modes[monitor->modeCount - 1] = mode;
79 
80  if (flags & WL_OUTPUT_MODE_CURRENT)
81  monitor->wl.currentMode = monitor->modeCount - 1;
82 }
83 
84 static void outputHandleDone(void* data, struct wl_output* output)
85 {
86  struct _GLFWmonitor *monitor = data;
87 
89 }
90 
91 static void outputHandleScale(void* data,
92  struct wl_output* output,
93  int32_t factor)
94 {
95  struct _GLFWmonitor *monitor = data;
96 
97  monitor->wl.scale = factor;
98 }
99 
100 static const struct wl_output_listener outputListener = {
105 };
106 
107 
111 
113 {
114  _GLFWmonitor *monitor;
115  struct wl_output *output;
116 
117  if (version < 2)
118  {
120  "Wayland: Unsupported output interface version");
121  return;
122  }
123 
124  // The actual name of this output will be set in the geometry handler.
125  monitor = _glfwAllocMonitor(NULL, 0, 0);
126 
127  output = wl_registry_bind(_glfw.wl.registry,
128  name,
129  &wl_output_interface,
130  2);
131  if (!output)
132  {
133  _glfwFreeMonitor(monitor);
134  return;
135  }
136 
137  monitor->wl.scale = 1;
138  monitor->wl.output = output;
139  monitor->wl.name = name;
140 
141  wl_output_add_listener(output, &outputListener, monitor);
142 }
143 
144 
148 
150 {
151  if (monitor->wl.output)
152  wl_output_destroy(monitor->wl.output);
153 }
154 
156 {
157  if (xpos)
158  *xpos = monitor->wl.x;
159  if (ypos)
160  *ypos = monitor->wl.y;
161 }
162 
164  float* xscale, float* yscale)
165 {
166  if (xscale)
167  *xscale = (float) monitor->wl.scale;
168  if (yscale)
169  *yscale = (float) monitor->wl.scale;
170 }
171 
173 {
174  *found = monitor->modeCount;
175  return monitor->modes;
176 }
177 
179 {
180  *mode = monitor->modes[monitor->wl.currentMode];
181 }
182 
184 {
185  // TODO
187  "Wayland: Gamma ramp getting not supported yet");
188 }
189 
191  const GLFWgammaramp* ramp)
192 {
193  // TODO
195  "Wayland: Gamma ramp setting not supported yet");
196 }
197 
198 
202 
204 {
205  _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
207  return monitor->wl.output;
208 }
209 
int redBits
Definition: glfw3.h:1535
int height
Definition: glfw3.h:1532
GLint y
void _glfwPlatformFreeMonitor(_GLFWmonitor *monitor)
Definition: wl_monitor.c:149
int blueBits
Definition: glfw3.h:1541
void _glfwPlatformSetGammaRamp(_GLFWmonitor *monitor, const GLFWgammaramp *ramp)
Definition: wl_monitor.c:190
GLuint const GLchar * name
#define GLFWAPI
Definition: glfw3.h:240
int width
Definition: glfw3.h:1529
static void outputHandleGeometry(void *data, struct wl_output *output, int32_t x, int32_t y, int32_t physicalWidth, int32_t physicalHeight, int32_t subpixel, const char *make, const char *model, int32_t transform)
Definition: wl_monitor.c:35
GLuint64 GLenum void * handle
Definition: glext.h:7785
GLFWvidmode * _glfwPlatformGetVideoModes(_GLFWmonitor *monitor, int *found)
Definition: wl_monitor.c:172
void _glfwPlatformGetMonitorPos(_GLFWmonitor *monitor, int *xpos, int *ypos)
Definition: wl_monitor.c:155
GLFWvidmode * modes
Definition: internal.h:433
struct GLFWmonitor GLFWmonitor
_GLFWmonitor * _glfwAllocMonitor(const char *name, int widthMM, int heightMM)
Definition: monitor.c:161
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
Definition: wl_monitor.c:112
int heightMM
Definition: internal.h:428
int refreshRate
Definition: glfw3.h:1544
char * _glfw_strdup(const char *source)
Definition: init.c:114
int modeCount
Definition: internal.h:434
static void outputHandleDone(void *data, struct wl_output *output)
Definition: wl_monitor.c:84
int greenBits
Definition: glfw3.h:1538
char * name
Definition: internal.h:424
#define GLFW_CONNECTED
Definition: glfw3.h:1058
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
Definition: internal.h:210
GLenum mode
static const textual_icon refresh
Definition: model-views.h:217
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:726
void _glfwFreeMonitor(_GLFWmonitor *monitor)
Definition: monitor.c:175
_GLFWlibrary _glfw
Definition: init.c:44
GLdouble x
GLFWAPI struct wl_output * glfwGetWaylandMonitor(GLFWmonitor *handle)
Definition: wl_monitor.c:203
unsigned int uint32_t
Definition: stdint.h:80
GLint GLsizei GLsizei height
GLbitfield flags
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor *monitor, float *xscale, float *yscale)
Definition: wl_monitor.c:163
GLFWvidmode currentMode
Definition: internal.h:435
void _glfwInputError(int code, const char *format,...)
Definition: init.c:129
void _glfwInputMonitor(_GLFWmonitor *monitor, int action, int placement)
Definition: monitor.c:91
void _glfwPlatformGetGammaRamp(_GLFWmonitor *monitor, GLFWgammaramp *ramp)
Definition: wl_monitor.c:183
static void outputHandleScale(void *data, struct wl_output *output, int32_t factor)
Definition: wl_monitor.c:91
Gamma ramp.
Definition: glfw3.h:1559
Video mode type.
Definition: glfw3.h:1525
static double xpos
Definition: splitview.c:33
void _glfwPlatformGetVideoMode(_GLFWmonitor *monitor, GLFWvidmode *mode)
Definition: wl_monitor.c:178
#define NULL
Definition: tinycthread.c:47
signed int int32_t
Definition: stdint.h:77
GLuint GLenum GLenum transform
Definition: glext.h:11553
GLboolean * data
Definition: parser.hpp:150
GLint GLsizei width
static void outputHandleMode(void *data, struct wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh)
Definition: wl_monitor.c:58
static double ypos
Definition: splitview.c:33
static const struct wl_output_listener outputListener
Definition: wl_monitor.c:100
#define _GLFW_INSERT_LAST
Definition: internal.h:52


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:23