|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
//========================================================================
|
|
|
|
|
// GLFW 3.3 Mir - www.glfw.org
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>
|
|
|
|
|
// Copyright (c) 2014-2017 Brandon Schaefer <brandon.schaefer@canonical.com>
|
|
|
|
|
//
|
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
@ -89,9 +89,6 @@ static EventNode* dequeueEvent(EventQueue* queue) |
|
|
|
|
return node; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* FIXME Soon to be changed upstream mir! So we can use an egl config to figure out
|
|
|
|
|
the best pixel format! |
|
|
|
|
*/ |
|
|
|
|
static MirPixelFormat findValidPixelFormat(void) |
|
|
|
|
{ |
|
|
|
|
unsigned int i, validFormats, mirPixelFormats = 32; |
|
|
|
@ -283,14 +280,14 @@ static void handleEvent(const MirEvent* event, _GLFWwindow* window) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void addNewEvent(MirSurface* surface, const MirEvent* event, void* context) |
|
|
|
|
static void addNewEvent(MirWindow* window, const MirEvent* event, void* context) |
|
|
|
|
{ |
|
|
|
|
enqueueEvent(event, context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static GLFWbool createSurface(_GLFWwindow* window) |
|
|
|
|
static GLFWbool createWindow(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
MirBufferUsage buffer_usage = mir_buffer_usage_hardware; |
|
|
|
|
MirPixelFormat pixel_format = findValidPixelFormat(); |
|
|
|
|
|
|
|
|
@ -301,40 +298,39 @@ static GLFWbool createSurface(_GLFWwindow* window) |
|
|
|
|
return GLFW_FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_normal_surface(_glfw.mir.connection, |
|
|
|
|
window->mir.width, |
|
|
|
|
window->mir.height, |
|
|
|
|
pixel_format); |
|
|
|
|
spec = mir_create_normal_window_spec(_glfw.mir.connection, |
|
|
|
|
window->mir.width, |
|
|
|
|
window->mir.height); |
|
|
|
|
|
|
|
|
|
mir_surface_spec_set_buffer_usage(spec, buffer_usage); |
|
|
|
|
mir_surface_spec_set_name(spec, "MirSurface"); |
|
|
|
|
mir_window_spec_set_pixel_format(spec, pixel_format); |
|
|
|
|
mir_window_spec_set_buffer_usage(spec, buffer_usage); |
|
|
|
|
|
|
|
|
|
window->mir.surface = mir_surface_create_sync(spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
window->mir.window = mir_create_window_sync(spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
|
|
|
|
|
if (!mir_surface_is_valid(window->mir.surface)) |
|
|
|
|
if (!mir_window_is_valid(window->mir.window)) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, |
|
|
|
|
"Mir: Unable to create surface: %s", |
|
|
|
|
mir_surface_get_error_message(window->mir.surface)); |
|
|
|
|
"Mir: Unable to create window: %s", |
|
|
|
|
mir_window_get_error_message(window->mir.window)); |
|
|
|
|
|
|
|
|
|
return GLFW_FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mir_surface_set_event_handler(window->mir.surface, addNewEvent, window); |
|
|
|
|
mir_window_set_event_handler(window->mir.window, addNewEvent, window); |
|
|
|
|
|
|
|
|
|
return GLFW_TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void setSurfaceConfinement(_GLFWwindow* window, MirPointerConfinementState state) |
|
|
|
|
static void setWindowConfinement(_GLFWwindow* window, MirPointerConfinementState state) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_pointer_confinement(spec, state); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_pointer_confinement(spec, state); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
@ -381,12 +377,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, |
|
|
|
|
GLFWvidmode mode; |
|
|
|
|
_glfwPlatformGetVideoMode(window->monitor, &mode); |
|
|
|
|
|
|
|
|
|
mir_surface_set_state(window->mir.surface, mir_surface_state_fullscreen); |
|
|
|
|
mir_window_set_state(window->mir.window, mir_window_state_fullscreen); |
|
|
|
|
|
|
|
|
|
if (wndconfig->width > mode.width || wndconfig->height > mode.height) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, |
|
|
|
|
"Mir: Requested surface size too large: %ix%i", |
|
|
|
|
"Mir: Requested window size too large: %ix%i", |
|
|
|
|
wndconfig->width, wndconfig->height); |
|
|
|
|
|
|
|
|
|
return GLFW_FALSE; |
|
|
|
@ -397,11 +393,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, |
|
|
|
|
window->mir.height = wndconfig->height; |
|
|
|
|
window->mir.currentCursor = NULL; |
|
|
|
|
|
|
|
|
|
if (!createSurface(window)) |
|
|
|
|
if (!createWindow(window)) |
|
|
|
|
return GLFW_FALSE; |
|
|
|
|
|
|
|
|
|
window->mir.window = mir_buffer_stream_get_egl_native_window( |
|
|
|
|
mir_surface_get_buffer_stream(window->mir.surface)); |
|
|
|
|
window->mir.nativeWindow = mir_buffer_stream_get_egl_native_window( |
|
|
|
|
mir_window_get_buffer_stream(window->mir.window)); |
|
|
|
|
|
|
|
|
|
if (ctxconfig->client != GLFW_NO_API) |
|
|
|
|
{ |
|
|
|
@ -430,10 +426,10 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) |
|
|
|
|
if (_glfw.mir.disabledCursorWindow == window) |
|
|
|
|
_glfw.mir.disabledCursorWindow = NULL; |
|
|
|
|
|
|
|
|
|
if (mir_surface_is_valid(window->mir.surface)) |
|
|
|
|
if (mir_window_is_valid(window->mir.window)) |
|
|
|
|
{ |
|
|
|
|
mir_surface_release_sync(window->mir.surface); |
|
|
|
|
window->mir.surface = NULL; |
|
|
|
|
mir_window_release_sync(window->mir.window); |
|
|
|
|
window->mir.window= NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (window->context.destroy) |
|
|
|
@ -442,13 +438,12 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_name(spec, title); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_name(spec, title); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, |
|
|
|
@ -460,22 +455,30 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_width (spec, width); |
|
|
|
|
mir_surface_spec_set_height(spec, height); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_width (spec, width); |
|
|
|
|
mir_window_spec_set_height(spec, height); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, |
|
|
|
|
int minwidth, int minheight, |
|
|
|
|
int maxwidth, int maxheight) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, |
|
|
|
|
"Mir: Unsupported function %s", __PRETTY_FUNCTION__); |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_max_width (spec, maxwidth); |
|
|
|
|
mir_window_spec_set_max_height(spec, maxheight); |
|
|
|
|
mir_window_spec_set_min_width (spec, minwidth); |
|
|
|
|
mir_window_spec_set_min_height(spec, minheight); |
|
|
|
|
|
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom) |
|
|
|
@ -514,57 +517,57 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) |
|
|
|
|
|
|
|
|
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_state(spec, mir_surface_state_minimized); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_state(spec, mir_window_state_minimized); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformRestoreWindow(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_state(spec, mir_surface_state_restored); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_state(spec, mir_window_state_restored); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformMaximizeWindow(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_state(spec, mir_surface_state_maximized); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_state(spec, mir_window_state_maximized); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformHideWindow(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_state(spec, mir_surface_state_hidden); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_state(spec, mir_window_state_hidden); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformShowWindow(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
MirSurfaceSpec* spec; |
|
|
|
|
MirWindowSpec* spec; |
|
|
|
|
|
|
|
|
|
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection); |
|
|
|
|
mir_surface_spec_set_state(spec, mir_surface_state_restored); |
|
|
|
|
spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_state(spec, mir_window_state_restored); |
|
|
|
|
|
|
|
|
|
mir_surface_apply_spec(window->mir.surface, spec); |
|
|
|
|
mir_surface_spec_release(spec); |
|
|
|
|
mir_window_apply_spec(window->mir.window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformFocusWindow(_GLFWwindow* window) |
|
|
|
@ -585,7 +588,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, |
|
|
|
|
|
|
|
|
|
int _glfwPlatformWindowFocused(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
return mir_surface_get_focus(window->mir.surface) == mir_surface_focused; |
|
|
|
|
return mir_window_get_focus_state(window->mir.window) == mir_window_focus_state_focused; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int _glfwPlatformWindowIconified(_GLFWwindow* window) |
|
|
|
@ -597,12 +600,12 @@ int _glfwPlatformWindowIconified(_GLFWwindow* window) |
|
|
|
|
|
|
|
|
|
int _glfwPlatformWindowVisible(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
return mir_surface_get_visibility(window->mir.surface) == mir_surface_visibility_exposed; |
|
|
|
|
return mir_window_get_visibility(window->mir.window) == mir_window_visibility_exposed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int _glfwPlatformWindowMaximized(_GLFWwindow* window) |
|
|
|
|
{ |
|
|
|
|
return mir_surface_get_state(window->mir.surface) == mir_surface_state_maximized; |
|
|
|
|
return mir_window_get_state(window->mir.window) == mir_window_state_maximized; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) |
|
|
|
@ -638,7 +641,7 @@ void _glfwPlatformWaitEvents(void) |
|
|
|
|
{ |
|
|
|
|
pthread_mutex_lock(&_glfw.mir.eventMutex); |
|
|
|
|
|
|
|
|
|
if (emptyEventQueue(_glfw.mir.eventQueue)) |
|
|
|
|
while (emptyEventQueue(_glfw.mir.eventQueue)) |
|
|
|
|
pthread_cond_wait(&_glfw.mir.eventCond, &_glfw.mir.eventMutex); |
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&_glfw.mir.eventMutex); |
|
|
|
@ -681,54 +684,40 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, |
|
|
|
|
int xhot, int yhot) |
|
|
|
|
{ |
|
|
|
|
MirBufferStream* stream; |
|
|
|
|
MirPixelFormat pixel_format = findValidPixelFormat(); |
|
|
|
|
|
|
|
|
|
int i_w = image->width; |
|
|
|
|
int i_h = image->height; |
|
|
|
|
|
|
|
|
|
if (pixel_format == mir_pixel_format_invalid) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, |
|
|
|
|
"Mir: Unable to find a correct pixel format"); |
|
|
|
|
return GLFW_FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stream = mir_connection_create_buffer_stream_sync(_glfw.mir.connection, |
|
|
|
|
i_w, i_h, |
|
|
|
|
pixel_format, |
|
|
|
|
mir_pixel_format_argb_8888, |
|
|
|
|
mir_buffer_usage_software); |
|
|
|
|
|
|
|
|
|
cursor->mir.conf = mir_cursor_configuration_from_buffer_stream(stream, xhot, yhot); |
|
|
|
|
|
|
|
|
|
char* dest; |
|
|
|
|
unsigned char *pixels; |
|
|
|
|
int i, r_stride, bytes_per_pixel, bytes_per_row; |
|
|
|
|
|
|
|
|
|
MirGraphicsRegion region; |
|
|
|
|
mir_buffer_stream_get_graphics_region(stream, ®ion); |
|
|
|
|
|
|
|
|
|
// FIXME Figure this out based on the current_pf
|
|
|
|
|
bytes_per_pixel = 4; |
|
|
|
|
bytes_per_row = bytes_per_pixel * i_w; |
|
|
|
|
|
|
|
|
|
dest = region.vaddr; |
|
|
|
|
pixels = image->pixels; |
|
|
|
|
unsigned char* pixels = image->pixels; |
|
|
|
|
char* dest = region.vaddr; |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
r_stride = region.stride; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < i_h; i++) |
|
|
|
|
for (i = 0; i < i_w * i_h; i++, pixels += 4) |
|
|
|
|
{ |
|
|
|
|
memcpy(dest, pixels, bytes_per_row); |
|
|
|
|
dest += r_stride; |
|
|
|
|
pixels += r_stride; |
|
|
|
|
unsigned int alpha = pixels[3]; |
|
|
|
|
*dest++ = (char)(pixels[2] * alpha / 255); |
|
|
|
|
*dest++ = (char)(pixels[1] * alpha / 255); |
|
|
|
|
*dest++ = (char)(pixels[0] * alpha / 255); |
|
|
|
|
*dest++ = (char)alpha; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mir_buffer_stream_swap_buffers_sync(stream); |
|
|
|
|
cursor->mir.customCursor = stream; |
|
|
|
|
|
|
|
|
|
return GLFW_TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const char* getSystemCursorName(int shape) |
|
|
|
|
static const char* getSystemCursorName(int shape) |
|
|
|
|
{ |
|
|
|
|
switch (shape) |
|
|
|
|
{ |
|
|
|
@ -751,17 +740,11 @@ const char* getSystemCursorName(int shape) |
|
|
|
|
|
|
|
|
|
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) |
|
|
|
|
{ |
|
|
|
|
const char* cursor_name = getSystemCursorName(shape); |
|
|
|
|
|
|
|
|
|
if (cursor_name) |
|
|
|
|
{ |
|
|
|
|
cursor->mir.conf = mir_cursor_configuration_from_name(cursor_name); |
|
|
|
|
cursor->mir.customCursor = NULL; |
|
|
|
|
|
|
|
|
|
return GLFW_TRUE; |
|
|
|
|
} |
|
|
|
|
cursor->mir.conf = NULL; |
|
|
|
|
cursor->mir.customCursor = NULL; |
|
|
|
|
cursor->mir.cursorName = getSystemCursorName(shape); |
|
|
|
|
|
|
|
|
|
return GLFW_FALSE; |
|
|
|
|
return cursor->mir.cursorName != NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) |
|
|
|
@ -772,21 +755,32 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) |
|
|
|
|
mir_buffer_stream_release_sync(cursor->mir.customCursor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void setCursorNameForWindow(MirWindow* window, char const* name) |
|
|
|
|
{ |
|
|
|
|
MirWindowSpec* spec = mir_create_window_spec(_glfw.mir.connection); |
|
|
|
|
mir_window_spec_set_cursor_name(spec, name); |
|
|
|
|
mir_window_apply_spec(window, spec); |
|
|
|
|
mir_window_spec_release(spec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) |
|
|
|
|
{ |
|
|
|
|
if (cursor && cursor->mir.conf) |
|
|
|
|
if (cursor) |
|
|
|
|
{ |
|
|
|
|
window->mir.currentCursor = cursor; |
|
|
|
|
|
|
|
|
|
mir_wait_for(mir_surface_configure_cursor(window->mir.surface, cursor->mir.conf)); |
|
|
|
|
if (cursor->mir.customCursor) |
|
|
|
|
if (cursor->mir.cursorName) |
|
|
|
|
{ |
|
|
|
|
setCursorNameForWindow(window->mir.window, cursor->mir.cursorName); |
|
|
|
|
} |
|
|
|
|
else if (cursor->mir.conf) |
|
|
|
|
{ |
|
|
|
|
mir_buffer_stream_swap_buffers_sync(cursor->mir.customCursor); |
|
|
|
|
mir_window_configure_cursor(window->mir.window, cursor->mir.conf); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
mir_wait_for(mir_surface_configure_cursor(window->mir.surface, _glfw.mir.defaultConf)); |
|
|
|
|
setCursorNameForWindow(window->mir.window, mir_default_cursor_name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -807,8 +801,8 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) |
|
|
|
|
if (mode == GLFW_CURSOR_DISABLED) |
|
|
|
|
{ |
|
|
|
|
_glfw.mir.disabledCursorWindow = window; |
|
|
|
|
setSurfaceConfinement(window, mir_pointer_confined_to_surface); |
|
|
|
|
mir_wait_for(mir_surface_configure_cursor(window->mir.surface, _glfw.mir.disabledConf)); |
|
|
|
|
setWindowConfinement(window, mir_pointer_confined_to_window); |
|
|
|
|
setCursorNameForWindow(window->mir.window, mir_disabled_cursor_name); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -816,7 +810,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) |
|
|
|
|
if (_glfw.mir.disabledCursorWindow == window) |
|
|
|
|
{ |
|
|
|
|
_glfw.mir.disabledCursorWindow = NULL; |
|
|
|
|
setSurfaceConfinement(window, mir_pointer_unconfined); |
|
|
|
|
setWindowConfinement(window, mir_pointer_unconfined); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (window->cursorMode == GLFW_CURSOR_NORMAL) |
|
|
|
@ -825,7 +819,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) |
|
|
|
|
} |
|
|
|
|
else if (window->cursorMode == GLFW_CURSOR_HIDDEN) |
|
|
|
|
{ |
|
|
|
|
mir_wait_for(mir_surface_configure_cursor(window->mir.surface, _glfw.mir.disabledConf)); |
|
|
|
|
setCursorNameForWindow(window->mir.window, mir_disabled_cursor_name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -890,12 +884,12 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, |
|
|
|
|
VkSurfaceKHR* surface) |
|
|
|
|
{ |
|
|
|
|
VkResult err; |
|
|
|
|
VkMirSurfaceCreateInfoKHR sci; |
|
|
|
|
PFN_vkCreateMirSurfaceKHR vkCreateMirSurfaceKHR; |
|
|
|
|
VkMirWindowCreateInfoKHR sci; |
|
|
|
|
PFN_vkCreateMirWindowKHR vkCreateMirWindowKHR; |
|
|
|
|
|
|
|
|
|
vkCreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) |
|
|
|
|
vkGetInstanceProcAddr(instance, "vkCreateMirSurfaceKHR"); |
|
|
|
|
if (!vkCreateMirSurfaceKHR) |
|
|
|
|
vkCreateMirWindowKHR = (PFN_vkCreateMirWindowKHR) |
|
|
|
|
vkGetInstanceProcAddr(instance, "vkCreateMirWindowKHR"); |
|
|
|
|
if (!vkCreateMirWindowKHR) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE, |
|
|
|
|
"Mir: Vulkan instance missing VK_KHR_mir_surface extension"); |
|
|
|
@ -905,9 +899,9 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, |
|
|
|
|
memset(&sci, 0, sizeof(sci)); |
|
|
|
|
sci.sType = VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR; |
|
|
|
|
sci.connection = _glfw.mir.connection; |
|
|
|
|
sci.mirSurface = window->mir.surface; |
|
|
|
|
sci.mirWindow = window->mir.window; |
|
|
|
|
|
|
|
|
|
err = vkCreateMirSurfaceKHR(instance, &sci, allocator, surface); |
|
|
|
|
err = vkCreateMirWindowKHR(instance, &sci, allocator, surface); |
|
|
|
|
if (err) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, |
|
|
|
@ -929,10 +923,10 @@ GLFWAPI MirConnection* glfwGetMirDisplay(void) |
|
|
|
|
return _glfw.mir.connection; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* handle) |
|
|
|
|
GLFWAPI MirWindow* glfwGetMirWindow(GLFWwindow* handle) |
|
|
|
|
{ |
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle; |
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); |
|
|
|
|
return window->mir.surface; |
|
|
|
|
return window->mir.window; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|