From 5491bd4fd28431cbeb59f8418e2119a0850a0dc1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 19 Mar 2014 16:11:19 +0100 Subject: [PATCH] Formatting and cleanup. --- src/wayland_clipboard.c | 1 + src/wayland_gamma.c | 1 + src/wayland_init.c | 28 +++++++++---------- src/wayland_monitor.c | 60 +++++++++-------------------------------- src/wayland_window.c | 29 +++++++++----------- 5 files changed, 40 insertions(+), 79 deletions(-) diff --git a/src/wayland_clipboard.c b/src/wayland_clipboard.c index 247e8ef1..8e25cad4 100644 --- a/src/wayland_clipboard.c +++ b/src/wayland_clipboard.c @@ -45,3 +45,4 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) fprintf(stderr, "_glfwPlatformGetClipboardString not implemented yet\n"); return NULL; } + diff --git a/src/wayland_gamma.c b/src/wayland_gamma.c index 5197a236..803e3c50 100644 --- a/src/wayland_gamma.c +++ b/src/wayland_gamma.c @@ -44,3 +44,4 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) // TODO fprintf(stderr, "_glfwPlatformSetGammaRamp not implemented yet\n"); } + diff --git a/src/wayland_init.c b/src/wayland_init.c index 0e825bdc..27ef6059 100644 --- a/src/wayland_init.c +++ b/src/wayland_init.c @@ -34,25 +34,22 @@ #include -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; } + diff --git a/src/wayland_monitor.c b/src/wayland_monitor.c index ae77e7f9..ff9f10b4 100644 --- a/src/wayland_monitor.c +++ b/src/wayland_monitor.c @@ -32,7 +32,8 @@ #include -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) } } } + diff --git a/src/wayland_window.c b/src/wayland_window.c index 862426ba..bf71bb63 100644 --- a/src/wayland_window.c +++ b/src/wayland_window.c @@ -32,26 +32,23 @@ #include -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; } } +