mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Formatting and cleanup.
This commit is contained in:
parent
78fc96518f
commit
5491bd4fd2
|
@ -45,3 +45,4 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||||
fprintf(stderr, "_glfwPlatformGetClipboardString not implemented yet\n");
|
fprintf(stderr, "_glfwPlatformGetClipboardString not implemented yet\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,3 +44,4 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
// TODO
|
// TODO
|
||||||
fprintf(stderr, "_glfwPlatformSetGammaRamp not implemented yet\n");
|
fprintf(stderr, "_glfwPlatformSetGammaRamp not implemented yet\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,16 +34,14 @@
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void handlePing(void* data,
|
||||||
handlePing(void* data,
|
|
||||||
struct wl_shell_surface* shellSurface,
|
struct wl_shell_surface* shellSurface,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
wl_shell_surface_pong(shellSurface, serial);
|
wl_shell_surface_pong(shellSurface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void handleConfigure(void* data,
|
||||||
handleConfigure(void* data,
|
|
||||||
struct wl_shell_surface* shellSurface,
|
struct wl_shell_surface* shellSurface,
|
||||||
uint32_t edges,
|
uint32_t edges,
|
||||||
int32_t width,
|
int32_t width,
|
||||||
|
@ -51,8 +49,7 @@ handleConfigure(void* data,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void handlePopupDone(void *data, struct wl_shell_surface *shell_surface)
|
||||||
handlePopupDone(void *data, struct wl_shell_surface *shell_surface)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +110,12 @@ int _glfwPlatformInit(void)
|
||||||
wl_registry_add_listener(_glfw.wayland.registry, ®istryListener, NULL);
|
wl_registry_add_listener(_glfw.wayland.registry, ®istryListener, NULL);
|
||||||
|
|
||||||
_glfw.wayland.monitors = calloc(4, sizeof(_GLFWmonitor*));
|
_glfw.wayland.monitors = calloc(4, sizeof(_GLFWmonitor*));
|
||||||
if (!_glfw.wayland.monitors)
|
|
||||||
return GL_FALSE;
|
|
||||||
_glfw.wayland.monitorsSize = 4;
|
_glfw.wayland.monitorsSize = 4;
|
||||||
|
|
||||||
// Sync so we got all registry objects.
|
// Sync so we got all registry objects
|
||||||
wl_display_roundtrip(_glfw.wayland.display);
|
wl_display_roundtrip(_glfw.wayland.display);
|
||||||
|
|
||||||
// Sync so we got all initial output events.
|
// Sync so we got all initial output events
|
||||||
wl_display_roundtrip(_glfw.wayland.display);
|
wl_display_roundtrip(_glfw.wayland.display);
|
||||||
|
|
||||||
if (!_glfwInitContextAPI())
|
if (!_glfwInitContextAPI())
|
||||||
|
@ -157,3 +152,4 @@ const char* _glfwPlatformGetVersionString(void)
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
struct _GLFWvidmodeWayland {
|
struct _GLFWvidmodeWayland
|
||||||
|
{
|
||||||
GLFWvidmode base;
|
GLFWvidmode base;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
};
|
};
|
||||||
|
@ -77,10 +78,6 @@ static void mode(void* data,
|
||||||
_GLFWvidmodeWayland* modes =
|
_GLFWvidmodeWayland* modes =
|
||||||
realloc(monitor->wayland.modes,
|
realloc(monitor->wayland.modes,
|
||||||
monitor->wayland.modesSize * sizeof(_GLFWvidmodeWayland));
|
monitor->wayland.modesSize * sizeof(_GLFWvidmodeWayland));
|
||||||
if (!modes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
monitor->wayland.modes = modes;
|
monitor->wayland.modes = modes;
|
||||||
monitor->wayland.modesSize = size;
|
monitor->wayland.modesSize = size;
|
||||||
}
|
}
|
||||||
|
@ -154,14 +151,6 @@ void _glfwAddOutput(uint32_t name, uint32_t version)
|
||||||
int size = _glfw.wayland.monitorsSize * 2;
|
int size = _glfw.wayland.monitorsSize * 2;
|
||||||
|
|
||||||
monitors = realloc(monitors, size * sizeof(_GLFWmonitor*));
|
monitors = realloc(monitors, size * sizeof(_GLFWmonitor*));
|
||||||
if (!monitors)
|
|
||||||
{
|
|
||||||
wl_output_destroy(output);
|
|
||||||
_glfwFreeMonitor(monitor);
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Failed to retrieve monitor information");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.wayland.monitors = monitors;
|
_glfw.wayland.monitors = monitors;
|
||||||
_glfw.wayland.monitorsSize = size;
|
_glfw.wayland.monitorsSize = size;
|
||||||
|
@ -179,32 +168,17 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
{
|
{
|
||||||
_GLFWmonitor** monitors;
|
_GLFWmonitor** monitors;
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
int monitorsCount = _glfw.wayland.monitorsCount;
|
int i, monitorsCount = _glfw.wayland.monitorsCount;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (_glfw.wayland.monitorsCount == 0)
|
if (_glfw.wayland.monitorsCount == 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*));
|
monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*));
|
||||||
if (!monitors)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
for (i = 0; i < monitorsCount; i++)
|
for (i = 0; i < monitorsCount; i++)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* origMonitor = _glfw.wayland.monitors[i];
|
_GLFWmonitor* origMonitor = _glfw.wayland.monitors[i];
|
||||||
monitor = malloc(sizeof(_GLFWmonitor));
|
monitor = calloc(1, sizeof(_GLFWmonitor));
|
||||||
if (!monitor)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
{
|
|
||||||
*count = i;
|
|
||||||
return monitors;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
goto err_free;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
monitor->modes =
|
monitor->modes =
|
||||||
_glfwPlatformGetVideoModes(origMonitor,
|
_glfwPlatformGetVideoModes(origMonitor,
|
||||||
|
@ -216,9 +190,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
*count = monitorsCount;
|
*count = monitorsCount;
|
||||||
return monitors;
|
return monitors;
|
||||||
|
|
||||||
err_free:
|
|
||||||
free(monitors);
|
|
||||||
|
|
||||||
err:
|
err:
|
||||||
*count = 0;
|
*count = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -240,15 +211,9 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
GLFWvidmode *modes;
|
GLFWvidmode *modes;
|
||||||
int modesCount = monitor->wayland.modesCount;
|
int i, modesCount = monitor->wayland.modesCount;
|
||||||
int i;
|
|
||||||
|
|
||||||
modes = calloc(modesCount, sizeof(GLFWvidmode));
|
modes = calloc(modesCount, sizeof(GLFWvidmode));
|
||||||
if (!modes)
|
|
||||||
{
|
|
||||||
*found = 0;;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < modesCount; i++)
|
for (i = 0; i < modesCount; i++)
|
||||||
modes[i] = monitor->wayland.modes[i].base;
|
modes[i] = monitor->wayland.modes[i].base;
|
||||||
|
@ -270,3 +235,4 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,16 +32,14 @@
|
||||||
#include <wayland-egl.h>
|
#include <wayland-egl.h>
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void handlePing(void* data,
|
||||||
handlePing(void* data,
|
|
||||||
struct wl_shell_surface* shellSurface,
|
struct wl_shell_surface* shellSurface,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
wl_shell_surface_pong(shellSurface, serial);
|
wl_shell_surface_pong(shellSurface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void handleConfigure(void* data,
|
||||||
handleConfigure(void* data,
|
|
||||||
struct wl_shell_surface* shellSurface,
|
struct wl_shell_surface* shellSurface,
|
||||||
uint32_t edges,
|
uint32_t edges,
|
||||||
int32_t width,
|
int32_t width,
|
||||||
|
@ -49,8 +47,7 @@ handleConfigure(void* data,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void handlePopupDone(void* data,
|
||||||
handlePopupDone(void* data,
|
|
||||||
struct wl_shell_surface* shellSurface)
|
struct wl_shell_surface* shellSurface)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -159,8 +156,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||||
{
|
{
|
||||||
// A Wayland client can not set its position, so just warn and set it
|
// A Wayland client can not set its position, so just warn
|
||||||
// to (0, 0)
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland does not allow manual window positioning");
|
"Wayland does not allow manual window positioning");
|
||||||
|
@ -258,7 +254,7 @@ void _glfwPlatformPostEmptyEvent(void)
|
||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
// A Wayland client can not set the cursor position.
|
// A Wayland client can not set the cursor position
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland does not allow cursor positioning");
|
"Wayland does not allow cursor positioning");
|
||||||
}
|
}
|
||||||
|
@ -279,3 +275,4 @@ void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user