From d76d56ce74af819d4f91b6e5496d853c45439372 Mon Sep 17 00:00:00 2001 From: BrandonSchaefer Date: Thu, 6 Nov 2014 00:26:39 -0800 Subject: [PATCH] Add the start of size of each monitor and modes. --- src/mir_init.c | 1 - src/mir_monitor.c | 54 ++++++++++++++++++++++++++++++++++++++++------ src/mir_platform.h | 8 +++++-- src/mir_window.c | 42 ++++++++++++++++++++---------------- 4 files changed, 78 insertions(+), 27 deletions(-) diff --git a/src/mir_init.c b/src/mir_init.c index a25c1c6b..f28f8e37 100644 --- a/src/mir_init.c +++ b/src/mir_init.c @@ -43,7 +43,6 @@ int _glfwPlatformInit(void) _glfw.mir.native_display = mir_connection_get_egl_native_display(_glfw.mir.connection); - // TODO Add in bits to get the correct monitors and screen sizes... // Ill just hard code in my own right now to jump ahead to surface and events. diff --git a/src/mir_monitor.c b/src/mir_monitor.c index 419d8f94..3010be85 100644 --- a/src/mir_monitor.c +++ b/src/mir_monitor.c @@ -34,26 +34,68 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) { - // FIXME Work out the best way to get this from mir, as we'll end up looping - // through all of that info... best to store it before we get here. - _GLFWmonitor** monitors = calloc(1, sizeof(_GLFWmonitor*)); - return monitors; + int d, found = 0; + MirDisplayConfiguration* display_config = mir_connection_create_display_config(_glfw.mir.connection); + + *count = display_config->num_outputs; + _GLFWmonitor** monitors = calloc(*count, sizeof(_GLFWmonitor*)); + + // TODO Break this loop down into the other functions there + for (d = 0; d < display_config->num_outputs; d++) + { + MirDisplayOutput const* out = display_config->outputs + d; + + if (out->used && + out->connected && + out->num_modes && + out->current_mode < out->num_modes) + { + _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor)); + + monitor->mir.x = out->position_x; + monitor->mir.y = out->position_y; + monitor->mir.output_id = out->output_id; + monitor->modes = calloc(out->num_modes, sizeof(GLFWvidmode)); + found++; + + int n_mode; + for (n_mode = 0; n_mode < out->num_modes; n_mode++) + { + monitor->modes[n_mode].width = out->modes[n_mode].horizontal_resolution; + monitor->modes[n_mode].height = out->modes[n_mode].vertical_resolution; + monitor->modes[n_mode].refreshRate = out->modes[n_mode].refresh_rate; + } + + monitors[d] = monitor; + } + } + + *count = found; + mir_display_config_destroy(display_config); + + return monitors; } GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second) { - return 0; + return first->mir.output_id == second->mir.output_id; } void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) { + if (xpos) + *xpos = monitor->mir.x; + if (ypos) + *ypos = monitor->mir.y; } +// FIXME Break down the top function into these functions GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) { - return NULL; + return NULL; } +// FIXME Break down the top function into these functions void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) { } diff --git a/src/mir_platform.h b/src/mir_platform.h index 837c0347..b288c21d 100644 --- a/src/mir_platform.h +++ b/src/mir_platform.h @@ -60,17 +60,21 @@ typedef struct _GLFWwindowMir typedef struct _GLFWmonitorMir { + int num_modes; + int output_id; + int x; + int y; + } _GLFWmonitorMir; typedef struct _GLFWlibraryMir { MirConnection* connection; - MirEGLNativeDisplayType native_display; - } _GLFWlibraryMir; +// TODO Only system cursors are implemented in mir atm. Need to wait for support. typedef struct _GLFWcursorMir { } _GLFWcursorMir; diff --git a/src/mir_window.c b/src/mir_window.c index dbc8ab0c..1c6f9087 100644 --- a/src/mir_window.c +++ b/src/mir_window.c @@ -381,6 +381,18 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) "Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__); } +void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__); +} + +void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__); +} + void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -401,9 +413,19 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window) void _glfwPlatformRestoreWindow(_GLFWwindow* window) { + mir_surface_set_type(window->mir.surface, mir_surface_state_restored); } void _glfwPlatformHideWindow(_GLFWwindow* window) +{ + mir_surface_set_type(window->mir.surface, mir_surface_state_minimized); +} + +void _glfwPlatformShowWindow(_GLFWwindow* window) +{ +} + +void _glfwPlatformUnhideWindow(_GLFWwindow* window) { } @@ -426,24 +448,6 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh *height = window->mir.height; } -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) -{ - _glfwInputError(GLFW_PLATFORM_ERROR, - "Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__); -} - -void _glfwPlatformShowWindow(_GLFWwindow* window) -{ -} - -void _glfwPlatformUnhideWindow(_GLFWwindow* window) -{ -} - -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) -{ -} - int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -458,6 +462,8 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__); } void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)