mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 21:14:35 +00: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");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -44,3 +44,4 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
// TODO
|
||||
fprintf(stderr, "_glfwPlatformSetGammaRamp not implemented yet\n");
|
||||
}
|
||||
|
||||
|
@ -34,25 +34,22 @@
|
||||
#include <wayland-cursor.h>
|
||||
|
||||
|
||||
static void
|
||||
handlePing(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t serial)
|
||||
static void handlePing(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t serial)
|
||||
{
|
||||
wl_shell_surface_pong(shellSurface, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
handleConfigure(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t edges,
|
||||
int32_t width,
|
||||
int32_t height)
|
||||
static void handleConfigure(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t edges,
|
||||
int32_t width,
|
||||
int32_t height)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
handlePopupDone(void *data, struct wl_shell_surface *shell_surface)
|
||||
static void 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);
|
||||
|
||||
_glfw.wayland.monitors = calloc(4, sizeof(_GLFWmonitor*));
|
||||
if (!_glfw.wayland.monitors)
|
||||
return GL_FALSE;
|
||||
_glfw.wayland.monitorsSize = 4;
|
||||
|
||||
// Sync so we got all registry objects.
|
||||
// Sync so we got all registry objects
|
||||
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);
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
@ -157,3 +152,4 @@ const char* _glfwPlatformGetVersionString(void)
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,8 @@
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
struct _GLFWvidmodeWayland {
|
||||
struct _GLFWvidmodeWayland
|
||||
{
|
||||
GLFWvidmode base;
|
||||
uint32_t flags;
|
||||
};
|
||||
@ -77,10 +78,6 @@ static void mode(void* data,
|
||||
_GLFWvidmodeWayland* modes =
|
||||
realloc(monitor->wayland.modes,
|
||||
monitor->wayland.modesSize * sizeof(_GLFWvidmodeWayland));
|
||||
if (!modes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
monitor->wayland.modes = modes;
|
||||
monitor->wayland.modesSize = size;
|
||||
}
|
||||
@ -154,14 +151,6 @@ void _glfwAddOutput(uint32_t name, uint32_t version)
|
||||
int size = _glfw.wayland.monitorsSize * 2;
|
||||
|
||||
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.monitorsSize = size;
|
||||
@ -179,46 +168,28 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
_GLFWmonitor** monitors;
|
||||
_GLFWmonitor* monitor;
|
||||
int monitorsCount = _glfw.wayland.monitorsCount;
|
||||
int i;
|
||||
int i, monitorsCount = _glfw.wayland.monitorsCount;
|
||||
|
||||
if (_glfw.wayland.monitorsCount == 0)
|
||||
goto err;
|
||||
|
||||
monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*));
|
||||
if (!monitors)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < monitorsCount; i++)
|
||||
{
|
||||
_GLFWmonitor* origMonitor = _glfw.wayland.monitors[i];
|
||||
monitor = malloc(sizeof(_GLFWmonitor));
|
||||
if (!monitor)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
*count = i;
|
||||
return monitors;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto err_free;
|
||||
}
|
||||
}
|
||||
_GLFWmonitor* origMonitor = _glfw.wayland.monitors[i];
|
||||
monitor = calloc(1, sizeof(_GLFWmonitor));
|
||||
|
||||
monitor->modes =
|
||||
_glfwPlatformGetVideoModes(origMonitor,
|
||||
&origMonitor->wayland.modesCount);
|
||||
*monitor = *_glfw.wayland.monitors[i];
|
||||
monitor->modes =
|
||||
_glfwPlatformGetVideoModes(origMonitor,
|
||||
&origMonitor->wayland.modesCount);
|
||||
*monitor = *_glfw.wayland.monitors[i];
|
||||
monitors[i] = monitor;
|
||||
}
|
||||
|
||||
*count = monitorsCount;
|
||||
return monitors;
|
||||
|
||||
err_free:
|
||||
free(monitors);
|
||||
|
||||
err:
|
||||
*count = 0;
|
||||
return NULL;
|
||||
@ -240,17 +211,11 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
GLFWvidmode *modes;
|
||||
int modesCount = monitor->wayland.modesCount;
|
||||
int i;
|
||||
int i, modesCount = monitor->wayland.modesCount;
|
||||
|
||||
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;
|
||||
|
||||
*found = modesCount;
|
||||
@ -261,7 +226,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < monitor->wayland.modesCount; i++)
|
||||
for (i = 0; i < monitor->wayland.modesCount; i++)
|
||||
{
|
||||
if (monitor->wayland.modes[i].flags & WL_OUTPUT_MODE_CURRENT)
|
||||
{
|
||||
@ -270,3 +235,4 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,26 +32,23 @@
|
||||
#include <wayland-egl.h>
|
||||
|
||||
|
||||
static void
|
||||
handlePing(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t serial)
|
||||
static void handlePing(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t serial)
|
||||
{
|
||||
wl_shell_surface_pong(shellSurface, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
handleConfigure(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t edges,
|
||||
int32_t width,
|
||||
int32_t height)
|
||||
static void handleConfigure(void* data,
|
||||
struct wl_shell_surface* shellSurface,
|
||||
uint32_t edges,
|
||||
int32_t width,
|
||||
int32_t height)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
handlePopupDone(void* data,
|
||||
struct wl_shell_surface* shellSurface)
|
||||
static void handlePopupDone(void* data,
|
||||
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)
|
||||
{
|
||||
// A Wayland client can not set its position, so just warn and set it
|
||||
// to (0, 0)
|
||||
// A Wayland client can not set its position, so just warn
|
||||
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland does not allow manual window positioning");
|
||||
@ -258,7 +254,7 @@ void _glfwPlatformPostEmptyEvent(void)
|
||||
|
||||
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,
|
||||
"Wayland does not allow cursor positioning");
|
||||
}
|
||||
@ -279,3 +275,4 @@ void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user