Shortened Wayland platform prefix.

This commit is contained in:
Camilla Berglund 2014-03-19 16:20:32 +01:00
parent 5491bd4fd2
commit ede7a585bf
4 changed files with 88 additions and 93 deletions

View File

@ -65,16 +65,14 @@ static void registryHandleGlobal(void* data,
const char* interface,
uint32_t version)
{
_GLFWlibraryWayland* wayland = &_glfw.wayland;
if (strcmp(interface, "wl_compositor") == 0)
{
wayland->compositor =
_glfw.wl.compositor =
wl_registry_bind(registry, name, &wl_compositor_interface, 1);
}
else if (strcmp(interface, "wl_shell") == 0)
{
wayland->shell =
_glfw.wl.shell =
wl_registry_bind(registry, name, &wl_shell_interface, 1);
}
else if (strcmp(interface, "wl_output") == 0)
@ -102,21 +100,21 @@ static const struct wl_registry_listener registryListener = {
int _glfwPlatformInit(void)
{
_glfw.wayland.display = wl_display_connect(NULL);
if (!_glfw.wayland.display)
_glfw.wl.display = wl_display_connect(NULL);
if (!_glfw.wl.display)
return GL_FALSE;
_glfw.wayland.registry = wl_display_get_registry(_glfw.wayland.display);
wl_registry_add_listener(_glfw.wayland.registry, &registryListener, NULL);
_glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
_glfw.wayland.monitors = calloc(4, sizeof(_GLFWmonitor*));
_glfw.wayland.monitorsSize = 4;
_glfw.wl.monitors = calloc(4, sizeof(_GLFWmonitor*));
_glfw.wl.monitorsSize = 4;
// Sync so we got all registry objects
wl_display_roundtrip(_glfw.wayland.display);
wl_display_roundtrip(_glfw.wl.display);
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wayland.display);
wl_display_roundtrip(_glfw.wl.display);
if (!_glfwInitContextAPI())
return GL_FALSE;
@ -131,12 +129,12 @@ void _glfwPlatformTerminate(void)
{
_glfwTerminateContextAPI();
if (_glfw.wayland.registry)
wl_registry_destroy(_glfw.wayland.registry);
if (_glfw.wayland.display)
wl_display_flush(_glfw.wayland.display);
if (_glfw.wayland.display)
wl_display_disconnect(_glfw.wayland.display);
if (_glfw.wl.registry)
wl_registry_destroy(_glfw.wl.registry);
if (_glfw.wl.display)
wl_display_flush(_glfw.wl.display);
if (_glfw.wl.display)
wl_display_disconnect(_glfw.wl.display);
}
const char* _glfwPlatformGetVersionString(void)

View File

@ -51,8 +51,8 @@ static void geometry(void* data,
{
struct _GLFWmonitor *monitor = data;
monitor->wayland.x = x;
monitor->wayland.y = y;
monitor->wl.x = x;
monitor->wl.y = y;
monitor->widthMM = physicalWidth;
monitor->heightMM = physicalHeight;
}
@ -72,17 +72,17 @@ static void mode(void* data,
mode.base.refreshRate = refresh;
mode.flags = flags;
if (monitor->wayland.modesCount + 1 >= monitor->wayland.modesSize)
if (monitor->wl.modesCount + 1 >= monitor->wl.modesSize)
{
int size = monitor->wayland.modesSize * 2;
int size = monitor->wl.modesSize * 2;
_GLFWvidmodeWayland* modes =
realloc(monitor->wayland.modes,
monitor->wayland.modesSize * sizeof(_GLFWvidmodeWayland));
monitor->wayland.modes = modes;
monitor->wayland.modesSize = size;
realloc(monitor->wl.modes,
monitor->wl.modesSize * sizeof(_GLFWvidmodeWayland));
monitor->wl.modes = modes;
monitor->wl.modesSize = size;
}
monitor->wayland.modes[monitor->wayland.modesCount++] = mode;
monitor->wl.modes[monitor->wl.modesCount++] = mode;
}
static void done(void* data,
@ -90,7 +90,7 @@ static void done(void* data,
{
struct _GLFWmonitor *monitor = data;
monitor->wayland.done = GL_TRUE;
monitor->wl.done = GL_TRUE;
}
static void scale(void* data,
@ -129,7 +129,7 @@ void _glfwAddOutput(uint32_t name, uint32_t version)
monitor = _glfwAllocMonitor(name_str, 0, 0);
output = wl_registry_bind(_glfw.wayland.registry,
output = wl_registry_bind(_glfw.wl.registry,
name,
&wl_output_interface,
2);
@ -139,24 +139,24 @@ void _glfwAddOutput(uint32_t name, uint32_t version)
return;
}
monitor->wayland.modes = calloc(4, sizeof(_GLFWvidmodeWayland));
monitor->wayland.modesSize = 4;
monitor->wl.modes = calloc(4, sizeof(_GLFWvidmodeWayland));
monitor->wl.modesSize = 4;
monitor->wayland.output = output;
monitor->wl.output = output;
wl_output_add_listener(output, &output_listener, monitor);
if (_glfw.wayland.monitorsCount + 1 >= _glfw.wayland.monitorsSize)
if (_glfw.wl.monitorsCount + 1 >= _glfw.wl.monitorsSize)
{
_GLFWmonitor** monitors = _glfw.wayland.monitors;
int size = _glfw.wayland.monitorsSize * 2;
_GLFWmonitor** monitors = _glfw.wl.monitors;
int size = _glfw.wl.monitorsSize * 2;
monitors = realloc(monitors, size * sizeof(_GLFWmonitor*));
_glfw.wayland.monitors = monitors;
_glfw.wayland.monitorsSize = size;
_glfw.wl.monitors = monitors;
_glfw.wl.monitorsSize = size;
}
_glfw.wayland.monitors[_glfw.wayland.monitorsCount++] = monitor;
_glfw.wl.monitors[_glfw.wl.monitorsCount++] = monitor;
}
@ -168,22 +168,22 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
{
_GLFWmonitor** monitors;
_GLFWmonitor* monitor;
int i, monitorsCount = _glfw.wayland.monitorsCount;
int i, monitorsCount = _glfw.wl.monitorsCount;
if (_glfw.wayland.monitorsCount == 0)
if (_glfw.wl.monitorsCount == 0)
goto err;
monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*));
for (i = 0; i < monitorsCount; i++)
{
_GLFWmonitor* origMonitor = _glfw.wayland.monitors[i];
_GLFWmonitor* origMonitor = _glfw.wl.monitors[i];
monitor = calloc(1, sizeof(_GLFWmonitor));
monitor->modes =
_glfwPlatformGetVideoModes(origMonitor,
&origMonitor->wayland.modesCount);
*monitor = *_glfw.wayland.monitors[i];
&origMonitor->wl.modesCount);
*monitor = *_glfw.wl.monitors[i];
monitors[i] = monitor;
}
@ -197,26 +197,26 @@ err:
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
{
return first->wayland.output == second->wayland.output;
return first->wl.output == second->wl.output;
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
if (xpos)
*xpos = monitor->wayland.x;
*xpos = monitor->wl.x;
if (ypos)
*ypos = monitor->wayland.y;
*ypos = monitor->wl.y;
}
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
{
GLFWvidmode *modes;
int i, modesCount = monitor->wayland.modesCount;
int i, modesCount = monitor->wl.modesCount;
modes = calloc(modesCount, sizeof(GLFWvidmode));
for (i = 0; i < modesCount; i++)
modes[i] = monitor->wayland.modes[i].base;
modes[i] = monitor->wl.modes[i].base;
*found = modesCount;
return modes;
@ -226,11 +226,11 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
int i;
for (i = 0; i < monitor->wayland.modesCount; i++)
for (i = 0; i < monitor->wl.modesCount; i++)
{
if (monitor->wayland.modes[i].flags & WL_OUTPUT_MODE_CURRENT)
if (monitor->wl.modes[i].flags & WL_OUTPUT_MODE_CURRENT)
{
*mode = monitor->wayland.modes[i].base;
*mode = monitor->wl.modes[i].base;
return;
}
}

View File

@ -38,16 +38,16 @@
#include "linux_joystick.h"
#define _GLFW_UNIX_TIME_CONTEXT _glfw.wayland.timer
#define _GLFW_UNIX_TIME_CONTEXT _glfw.wl.timer
#include "unix_time.h"
#define _GLFW_X11_CONTEXT_VISUAL window->egl.visual
#define _GLFW_EGL_NATIVE_WINDOW window->wayland.native
#define _GLFW_EGL_NATIVE_DISPLAY _glfw.wayland.display
#define _GLFW_EGL_NATIVE_WINDOW window->wl.native
#define _GLFW_EGL_NATIVE_DISPLAY _glfw.wl.display
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wayland
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wayland
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wayland
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
typedef struct _GLFWvidmodeWayland _GLFWvidmodeWayland;

View File

@ -61,30 +61,27 @@ static const struct wl_shell_surface_listener shellSurfaceListener = {
static GLboolean createSurface(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig)
{
window->wayland.surface =
wl_compositor_create_surface(_glfw.wayland.compositor);
if (!window->wayland.surface)
window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
if (!window->wl.surface)
return GL_FALSE;
window->wayland.native =
wl_egl_window_create(window->wayland.surface,
wndconfig->width,
wndconfig->height);
if (!window->wayland.native)
window->wl.native = wl_egl_window_create(window->wl.surface,
wndconfig->width,
wndconfig->height);
if (!window->wl.native)
return GL_FALSE;
window->wayland.shell_surface =
wl_shell_get_shell_surface(_glfw.wayland.shell,
window->wayland.surface);
if (!window->wayland.shell_surface)
window->wl.shell_surface = wl_shell_get_shell_surface(_glfw.wl.shell,
window->wl.surface);
if (!window->wl.shell_surface)
return GL_FALSE;
wl_shell_surface_add_listener(window->wayland.shell_surface,
wl_shell_surface_add_listener(window->wl.shell_surface,
&shellSurfaceListener,
window);
window->wayland.width = wndconfig->width;
window->wayland.height = wndconfig->height;
window->wl.width = wndconfig->width;
window->wl.height = wndconfig->height;
return GL_TRUE;
}
@ -108,14 +105,14 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (wndconfig->monitor)
{
wl_shell_surface_set_fullscreen(
window->wayland.shell_surface,
window->wl.shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
0,
wndconfig->monitor->wayland.output);
wndconfig->monitor->wl.output);
}
else
{
wl_shell_surface_set_toplevel(window->wayland.shell_surface);
wl_shell_surface_set_toplevel(window->wl.shell_surface);
}
return GL_TRUE;
@ -123,21 +120,21 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
if (window->wayland.native)
wl_egl_window_destroy(window->wayland.native);
if (window->wl.native)
wl_egl_window_destroy(window->wl.native);
_glfwDestroyContext(window);
if (window->wayland.shell_surface)
wl_shell_surface_destroy(window->wayland.shell_surface);
if (window->wl.shell_surface)
wl_shell_surface_destroy(window->wl.shell_surface);
if (window->wayland.surface)
wl_surface_destroy(window->wayland.surface);
if (window->wl.surface)
wl_surface_destroy(window->wl.surface);
}
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{
wl_shell_surface_set_title(window->wayland.shell_surface, title);
wl_shell_surface_set_title(window->wl.shell_surface, title);
}
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
@ -165,16 +162,16 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
{
if (width)
*width = window->wayland.width;
*width = window->wl.width;
if (height)
*height = window->wayland.height;
*height = window->wl.height;
}
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
wl_egl_window_resize(window->wayland.native, width, height, 0, 0);
window->wayland.width = width;
window->wayland.height = height;
wl_egl_window_resize(window->wl.native, width, height, 0, 0);
window->wl.width = width;
window->wl.height = height;
}
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
@ -196,18 +193,18 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
wl_shell_surface_set_toplevel(window->wayland.shell_surface);
wl_shell_surface_set_toplevel(window->wl.shell_surface);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
wl_surface_attach(window->wayland.surface, NULL, 0, 0);
wl_surface_commit(window->wayland.surface);
wl_surface_attach(window->wl.surface, NULL, 0, 0);
wl_surface_commit(window->wl.surface);
}
void _glfwPlatformPollEvents(void)
{
struct wl_display* display = _glfw.wayland.display;
struct wl_display* display = _glfw.wl.display;
struct pollfd fds[] = {
{ wl_display_get_fd(display), POLLIN },
};
@ -228,7 +225,7 @@ void _glfwPlatformPollEvents(void)
void _glfwPlatformWaitEvents(void)
{
struct wl_display* display = _glfw.wayland.display;
struct wl_display* display = _glfw.wl.display;
struct pollfd fds[] = {
{ wl_display_get_fd(display), POLLIN },
};
@ -249,7 +246,7 @@ void _glfwPlatformWaitEvents(void)
void _glfwPlatformPostEmptyEvent(void)
{
wl_display_sync(_glfw.wayland.display);
wl_display_sync(_glfw.wl.display);
}
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)