mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Mir: Get ready for Mir 1.0
Clean up CMake finding and check version. Change last remaining deprecations. Closes #979.
This commit is contained in:
parent
9f63a8abfa
commit
c9003b5547
@ -1,37 +1,34 @@
|
|||||||
# Try to find Mir on a Unix system
|
# FindMir
|
||||||
|
# -------
|
||||||
|
# Finds the Mir library
|
||||||
#
|
#
|
||||||
# This will define:
|
# This will will define the following variables::
|
||||||
#
|
#
|
||||||
# MIR_FOUND - System has Mir
|
# MIR_FOUND - the system has Mir
|
||||||
# MIR_LIBRARIES - Link these to use Mir
|
# MIR_INCLUDE_DIRS - the Mir include directory
|
||||||
# MIR_INCLUDE_DIR - Include directory for Mir
|
# MIR_LIBRARIES - the Mir libraries
|
||||||
# MIR_DEFINITIONS - Compiler switches required for using Mir
|
# MIR_DEFINITIONS - the Mir definitions
|
||||||
|
|
||||||
if (NOT WIN32)
|
|
||||||
|
|
||||||
find_package (PkgConfig)
|
find_package (PkgConfig)
|
||||||
pkg_check_modules (PKG_MIR QUIET mirclient)
|
if(PKG_CONFIG_FOUND)
|
||||||
set(MIR_DEFINITIONS ${PKG_MIR_CFLAGS_OTHER})
|
pkg_check_modules (PC_MIR mirclient>=0.26.2 QUIET)
|
||||||
|
|
||||||
find_path(MIR_INCLUDE_DIR
|
find_path(MIR_INCLUDE_DIR NAMES mir_toolkit/mir_client_library.h
|
||||||
NAMES xkbcommon/xkbcommon.h
|
PATHS ${PC_MIR_INCLUDE_DIRS})
|
||||||
HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(MIR_LIBRARY
|
find_library(MIR_LIBRARY NAMES mirclient
|
||||||
NAMES mirclient
|
PATHS ${PC_MIR_LIBRARIES} ${PC_MIR_LIBRARY_DIRS})
|
||||||
HINTS ${PKG_MIR_LIBRARIES} ${MIR_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
set (MIR_INCLUDE_DIR ${PKG_MIR_INCLUDE_DIRS})
|
|
||||||
set (MIR_LIBRARIES ${MIR_LIBRARY})
|
|
||||||
|
|
||||||
include (FindPackageHandleStandardArgs)
|
include (FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args (MIR DEFAULT_MSG
|
find_package_handle_standard_args (MIR
|
||||||
MIR_LIBRARIES
|
REQUIRED_VARS MIR_LIBRARY MIR_INCLUDE_DIR)
|
||||||
MIR_INCLUDE_DIR
|
|
||||||
)
|
|
||||||
|
|
||||||
mark_as_advanced (MIR_LIBRARIES MIR_INCLUDE_DIR)
|
if (MIR_FOUND)
|
||||||
|
set(MIR_LIBRARIES ${MIR_LIBRARY})
|
||||||
|
set(MIR_INCLUDE_DIRS ${PC_MIR_INCLUDE_DIRS})
|
||||||
|
set(MIR_DEFINITIONS -DHAVE_MIR=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif ()
|
mark_as_advanced (MIR_LIBRARY MIR_INCLUDE_DIR)
|
||||||
|
endif()
|
||||||
|
@ -308,7 +308,7 @@ if (_GLFW_MIR)
|
|||||||
find_package(Mir REQUIRED)
|
find_package(Mir REQUIRED)
|
||||||
list(APPEND glfw_PKG_DEPS "mirclient")
|
list(APPEND glfw_PKG_DEPS "mirclient")
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${MIR_INCLUDE_DIR}")
|
list(APPEND glfw_INCLUDE_DIRS "${MIR_INCLUDE_DIRS}")
|
||||||
list(APPEND glfw_LIBRARIES "${MIR_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
|
list(APPEND glfw_LIBRARIES "${MIR_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
|
|
||||||
find_package(XKBCommon REQUIRED)
|
find_package(XKBCommon REQUIRED)
|
||||||
|
@ -394,9 +394,9 @@ GLFWAPI MirConnection* glfwGetMirDisplay(void);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
|
GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @brief Returns the `MirSurface*` of the specified window.
|
/*! @brief Returns the `MirWindow*` of the specified window.
|
||||||
*
|
*
|
||||||
* @return The `MirSurface*` of the specified window, or `NULL` if an
|
* @return The `MirWindow*` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
@ -406,7 +406,7 @@ GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
|
|||||||
*
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* window);
|
GLFWAPI MirWindow* glfwGetMirWindow(GLFWwindow* window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW 3.3 Mir - www.glfw.org
|
// 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
|
// This software is provided 'as-is', without any express or implied
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
@ -195,10 +195,6 @@ int _glfwPlatformInit(void)
|
|||||||
|
|
||||||
_glfwInitTimerPOSIX();
|
_glfwInitTimerPOSIX();
|
||||||
|
|
||||||
// Need the default conf for when we set a NULL cursor
|
|
||||||
_glfw.mir.defaultConf = mir_cursor_configuration_from_name(mir_default_cursor_name);
|
|
||||||
_glfw.mir.disabledConf = mir_cursor_configuration_from_name(mir_disabled_cursor_name);
|
|
||||||
|
|
||||||
_glfw.mir.eventQueue = calloc(1, sizeof(EventQueue));
|
_glfw.mir.eventQueue = calloc(1, sizeof(EventQueue));
|
||||||
_glfwInitEventQueueMir(_glfw.mir.eventQueue);
|
_glfwInitEventQueueMir(_glfw.mir.eventQueue);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW 3.3 Mir - www.glfw.org
|
// 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
|
// This software is provided 'as-is', without any express or implied
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
@ -38,33 +38,41 @@
|
|||||||
void _glfwPollMonitorsMir(void)
|
void _glfwPollMonitorsMir(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
MirDisplayConfiguration* displayConfig =
|
MirDisplayConfig* displayConfig =
|
||||||
mir_connection_create_display_config(_glfw.mir.connection);
|
mir_connection_create_display_configuration(_glfw.mir.connection);
|
||||||
|
|
||||||
for (i = 0; i < displayConfig->num_outputs; i++)
|
int numOutputs = mir_display_config_get_num_outputs(displayConfig);
|
||||||
|
|
||||||
|
for (i = 0; i < numOutputs; i++)
|
||||||
{
|
{
|
||||||
const MirDisplayOutput* out = displayConfig->outputs + i;
|
const MirOutput* output = mir_display_config_get_output(displayConfig, i);
|
||||||
|
MirOutputConnectionState state = mir_output_get_connection_state(output);
|
||||||
|
bool enabled = mir_output_is_enabled(output);
|
||||||
|
|
||||||
if (out->used &&
|
if (enabled && state == mir_output_connection_state_connected)
|
||||||
out->connected &&
|
|
||||||
out->num_modes &&
|
|
||||||
out->current_mode < out->num_modes)
|
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor = _glfwAllocMonitor("Unknown",
|
int widthMM = mir_output_get_physical_width_mm(output);
|
||||||
out->physical_width_mm,
|
int heightMM = mir_output_get_physical_height_mm(output);
|
||||||
out->physical_height_mm);
|
int x = mir_output_get_position_x(output);
|
||||||
|
int y = mir_output_get_position_y(output);
|
||||||
|
int id = mir_output_get_id(output);
|
||||||
|
size_t currentMode = mir_output_get_current_mode_index(output);
|
||||||
|
const char* name = mir_output_type_name(mir_output_get_type(output));
|
||||||
|
|
||||||
monitor->mir.x = out->position_x;
|
_GLFWmonitor* monitor = _glfwAllocMonitor(name,
|
||||||
monitor->mir.y = out->position_y;
|
widthMM,
|
||||||
monitor->mir.outputId = out->output_id;
|
heightMM);
|
||||||
monitor->mir.curMode = out->current_mode;
|
monitor->mir.x = x;
|
||||||
|
monitor->mir.y = y;
|
||||||
|
monitor->mir.outputId = id;
|
||||||
|
monitor->mir.curMode = currentMode;
|
||||||
monitor->modes = _glfwPlatformGetVideoModes(monitor, &monitor->modeCount);
|
monitor->modes = _glfwPlatformGetVideoModes(monitor, &monitor->modeCount);
|
||||||
|
|
||||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mir_display_config_destroy(displayConfig);
|
mir_display_config_release(displayConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +88,7 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
|||||||
*ypos = monitor->mir.y;
|
*ypos = monitor->mir.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillInRGBBitsFromPixelFormat(GLFWvidmode* mode, const MirPixelFormat pf)
|
static void FillInRGBBitsFromPixelFormat(GLFWvidmode* mode, const MirPixelFormat pf)
|
||||||
{
|
{
|
||||||
switch (pf)
|
switch (pf)
|
||||||
{
|
{
|
||||||
@ -117,30 +125,52 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
GLFWvidmode* modes = NULL;
|
GLFWvidmode* modes = NULL;
|
||||||
MirDisplayConfiguration* displayConfig =
|
MirDisplayConfig* displayConfig =
|
||||||
mir_connection_create_display_config(_glfw.mir.connection);
|
mir_connection_create_display_configuration(_glfw.mir.connection);
|
||||||
|
|
||||||
for (i = 0; i < displayConfig->num_outputs; i++)
|
int numOutputs = mir_display_config_get_num_outputs(displayConfig);
|
||||||
|
|
||||||
|
for (i = 0; i < numOutputs; i++)
|
||||||
{
|
{
|
||||||
const MirDisplayOutput* out = displayConfig->outputs + i;
|
const MirOutput* output = mir_display_config_get_output(displayConfig, i);
|
||||||
if (out->output_id != monitor->mir.outputId)
|
int id = mir_output_get_id(output);
|
||||||
|
|
||||||
|
if (id != monitor->mir.outputId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
modes = calloc(out->num_modes, sizeof(GLFWvidmode));
|
MirOutputConnectionState state = mir_output_get_connection_state(output);
|
||||||
|
bool enabled = mir_output_is_enabled(output);
|
||||||
|
|
||||||
for (*found = 0; *found < out->num_modes; (*found)++)
|
// We must have been disconnected
|
||||||
|
if (!enabled || state != mir_output_connection_state_connected)
|
||||||
{
|
{
|
||||||
modes[*found].width = out->modes[*found].horizontal_resolution;
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
modes[*found].height = out->modes[*found].vertical_resolution;
|
"Mir: Monitor no longer connected");
|
||||||
modes[*found].refreshRate = out->modes[*found].refresh_rate;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FillInRGBBitsFromPixelFormat(&modes[*found], out->output_formats[*found]);
|
int numModes = mir_output_get_num_modes(output);
|
||||||
|
modes = calloc(numModes, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
|
for (*found = 0; *found < numModes; (*found)++)
|
||||||
|
{
|
||||||
|
const MirOutputMode* mode = mir_output_get_mode(output, *found);
|
||||||
|
int width = mir_output_mode_get_width(mode);
|
||||||
|
int height = mir_output_mode_get_height(mode);
|
||||||
|
double refreshRate = mir_output_mode_get_refresh_rate(mode);
|
||||||
|
MirPixelFormat currentFormat = mir_output_get_current_pixel_format(output);
|
||||||
|
|
||||||
|
modes[*found].width = width;
|
||||||
|
modes[*found].height = height;
|
||||||
|
modes[*found].refreshRate = refreshRate;
|
||||||
|
|
||||||
|
FillInRGBBitsFromPixelFormat(&modes[*found], currentFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mir_display_config_destroy(displayConfig);
|
mir_display_config_release(displayConfig);
|
||||||
|
|
||||||
return modes;
|
return modes;
|
||||||
}
|
}
|
||||||
@ -173,4 +203,3 @@ GLFWAPI int glfwGetMirMonitor(GLFWmonitor* handle)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||||
return monitor->mir.outputId;
|
return monitor->mir.outputId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW 3.3 Mir - www.glfw.org
|
// 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
|
// This software is provided 'as-is', without any express or implied
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
@ -33,18 +33,18 @@
|
|||||||
|
|
||||||
#include <mir_toolkit/mir_client_library.h>
|
#include <mir_toolkit/mir_client_library.h>
|
||||||
|
|
||||||
typedef VkFlags VkMirSurfaceCreateFlagsKHR;
|
typedef VkFlags VkMirWindowCreateFlagsKHR;
|
||||||
|
|
||||||
typedef struct VkMirSurfaceCreateInfoKHR
|
typedef struct VkMirWindowCreateInfoKHR
|
||||||
{
|
{
|
||||||
VkStructureType sType;
|
VkStructureType sType;
|
||||||
const void* pNext;
|
const void* pNext;
|
||||||
VkMirSurfaceCreateFlagsKHR flags;
|
VkMirWindowCreateFlagsKHR flags;
|
||||||
MirConnection* connection;
|
MirConnection* connection;
|
||||||
MirSurface* mirSurface;
|
MirWindow* mirWindow;
|
||||||
} VkMirSurfaceCreateInfoKHR;
|
} VkMirWindowCreateInfoKHR;
|
||||||
|
|
||||||
typedef VkResult (APIENTRY *PFN_vkCreateMirSurfaceKHR)(VkInstance,const VkMirSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
typedef VkResult (APIENTRY *PFN_vkCreateMirWindowKHR)(VkInstance,const VkMirWindowCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice,uint32_t,MirConnection*);
|
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice,uint32_t,MirConnection*);
|
||||||
|
|
||||||
#include "posix_tls.h"
|
#include "posix_tls.h"
|
||||||
@ -58,7 +58,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(Vk
|
|||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
#define _glfw_dlclose(handle) dlclose(handle)
|
||||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
||||||
|
|
||||||
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->mir.window)
|
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->mir.nativeWindow)
|
||||||
#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.mir.display)
|
#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.mir.display)
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowMir mir
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowMir mir
|
||||||
@ -81,10 +81,10 @@ typedef struct EventQueue
|
|||||||
//
|
//
|
||||||
typedef struct _GLFWwindowMir
|
typedef struct _GLFWwindowMir
|
||||||
{
|
{
|
||||||
MirSurface* surface;
|
MirWindow* window;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
MirEGLNativeWindowType window;
|
MirEGLNativeWindowType nativeWindow;
|
||||||
_GLFWcursor* currentCursor;
|
_GLFWcursor* currentCursor;
|
||||||
|
|
||||||
} _GLFWwindowMir;
|
} _GLFWwindowMir;
|
||||||
@ -106,18 +106,16 @@ typedef struct _GLFWlibraryMir
|
|||||||
{
|
{
|
||||||
MirConnection* connection;
|
MirConnection* connection;
|
||||||
MirEGLNativeDisplayType display;
|
MirEGLNativeDisplayType display;
|
||||||
MirCursorConfiguration* defaultConf;
|
|
||||||
MirCursorConfiguration* disabledConf;
|
|
||||||
EventQueue* eventQueue;
|
EventQueue* eventQueue;
|
||||||
|
|
||||||
short int keycodes[256];
|
short int keycodes[256];
|
||||||
short int scancodes[GLFW_KEY_LAST + 1];
|
short int scancodes[GLFW_KEY_LAST + 1];
|
||||||
|
|
||||||
pthread_mutex_t eventMutex;
|
pthread_mutex_t eventMutex;
|
||||||
pthread_cond_t eventCond;
|
pthread_cond_t eventCond;
|
||||||
|
|
||||||
// The window whose disabled cursor mode is active
|
// The window whose disabled cursor mode is active
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
|
||||||
} _GLFWlibraryMir;
|
} _GLFWlibraryMir;
|
||||||
|
|
||||||
@ -128,9 +126,11 @@ typedef struct _GLFWcursorMir
|
|||||||
{
|
{
|
||||||
MirCursorConfiguration* conf;
|
MirCursorConfiguration* conf;
|
||||||
MirBufferStream* customCursor;
|
MirBufferStream* customCursor;
|
||||||
|
char const* cursorName; // only needed for system cursors
|
||||||
} _GLFWcursorMir;
|
} _GLFWcursorMir;
|
||||||
|
|
||||||
|
|
||||||
|
extern void _glfwPollMonitorsMir(void);
|
||||||
extern void _glfwInitEventQueueMir(EventQueue* queue);
|
extern void _glfwInitEventQueueMir(EventQueue* queue);
|
||||||
extern void _glfwDeleteEventQueueMir(EventQueue* queue);
|
extern void _glfwDeleteEventQueueMir(EventQueue* queue);
|
||||||
|
|
||||||
|
254
src/mir_window.c
254
src/mir_window.c
@ -1,7 +1,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// GLFW 3.3 Mir - www.glfw.org
|
// 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
|
// This software is provided 'as-is', without any express or implied
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
@ -89,9 +89,6 @@ static EventNode* dequeueEvent(EventQueue* queue)
|
|||||||
return node;
|
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)
|
static MirPixelFormat findValidPixelFormat(void)
|
||||||
{
|
{
|
||||||
unsigned int i, validFormats, mirPixelFormats = 32;
|
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);
|
enqueueEvent(event, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLFWbool createSurface(_GLFWwindow* window)
|
static GLFWbool createWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
MirBufferUsage buffer_usage = mir_buffer_usage_hardware;
|
MirBufferUsage buffer_usage = mir_buffer_usage_hardware;
|
||||||
MirPixelFormat pixel_format = findValidPixelFormat();
|
MirPixelFormat pixel_format = findValidPixelFormat();
|
||||||
|
|
||||||
@ -301,40 +298,39 @@ static GLFWbool createSurface(_GLFWwindow* window)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_normal_surface(_glfw.mir.connection,
|
spec = mir_create_normal_window_spec(_glfw.mir.connection,
|
||||||
window->mir.width,
|
window->mir.width,
|
||||||
window->mir.height,
|
window->mir.height);
|
||||||
pixel_format);
|
|
||||||
|
|
||||||
mir_surface_spec_set_buffer_usage(spec, buffer_usage);
|
mir_window_spec_set_pixel_format(spec, pixel_format);
|
||||||
mir_surface_spec_set_name(spec, "MirSurface");
|
mir_window_spec_set_buffer_usage(spec, buffer_usage);
|
||||||
|
|
||||||
window->mir.surface = mir_surface_create_sync(spec);
|
window->mir.window = mir_create_window_sync(spec);
|
||||||
mir_surface_spec_release(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,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Mir: Unable to create surface: %s",
|
"Mir: Unable to create window: %s",
|
||||||
mir_surface_get_error_message(window->mir.surface));
|
mir_window_get_error_message(window->mir.window));
|
||||||
|
|
||||||
return GLFW_FALSE;
|
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;
|
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);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_pointer_confinement(spec, state);
|
mir_window_spec_set_pointer_confinement(spec, state);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -381,12 +377,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
GLFWvidmode mode;
|
GLFWvidmode mode;
|
||||||
_glfwPlatformGetVideoMode(window->monitor, &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)
|
if (wndconfig->width > mode.width || wndconfig->height > mode.height)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Mir: Requested surface size too large: %ix%i",
|
"Mir: Requested window size too large: %ix%i",
|
||||||
wndconfig->width, wndconfig->height);
|
wndconfig->width, wndconfig->height);
|
||||||
|
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -397,11 +393,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
window->mir.height = wndconfig->height;
|
window->mir.height = wndconfig->height;
|
||||||
window->mir.currentCursor = NULL;
|
window->mir.currentCursor = NULL;
|
||||||
|
|
||||||
if (!createSurface(window))
|
if (!createWindow(window))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
window->mir.window = mir_buffer_stream_get_egl_native_window(
|
window->mir.nativeWindow = mir_buffer_stream_get_egl_native_window(
|
||||||
mir_surface_get_buffer_stream(window->mir.surface));
|
mir_window_get_buffer_stream(window->mir.window));
|
||||||
|
|
||||||
if (ctxconfig->client != GLFW_NO_API)
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
{
|
{
|
||||||
@ -430,10 +426,10 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||||||
if (_glfw.mir.disabledCursorWindow == window)
|
if (_glfw.mir.disabledCursorWindow == window)
|
||||||
_glfw.mir.disabledCursorWindow = NULL;
|
_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);
|
mir_window_release_sync(window->mir.window);
|
||||||
window->mir.surface = NULL;
|
window->mir.window= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->context.destroy)
|
if (window->context.destroy)
|
||||||
@ -442,13 +438,12 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_name(spec, title);
|
mir_window_spec_set_name(spec, title);
|
||||||
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_spec_release(spec);
|
||||||
mir_surface_spec_release(spec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||||
@ -460,22 +455,30 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_width (spec, width);
|
mir_window_spec_set_width (spec, width);
|
||||||
mir_surface_spec_set_height(spec, height);
|
mir_window_spec_set_height(spec, height);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||||
int minwidth, int minheight,
|
int minwidth, int minheight,
|
||||||
int maxwidth, int maxheight)
|
int maxwidth, int maxheight)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
MirWindowSpec* spec;
|
||||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
|
||||||
|
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)
|
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
|
||||||
@ -514,57 +517,57 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
|||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_state(spec, mir_surface_state_minimized);
|
mir_window_spec_set_state(spec, mir_window_state_minimized);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_state(spec, mir_surface_state_restored);
|
mir_window_spec_set_state(spec, mir_window_state_restored);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_state(spec, mir_surface_state_maximized);
|
mir_window_spec_set_state(spec, mir_window_state_maximized);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_state(spec, mir_surface_state_hidden);
|
mir_window_spec_set_state(spec, mir_window_state_hidden);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
MirSurfaceSpec* spec;
|
MirWindowSpec* spec;
|
||||||
|
|
||||||
spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);
|
spec = mir_create_window_spec(_glfw.mir.connection);
|
||||||
mir_surface_spec_set_state(spec, mir_surface_state_restored);
|
mir_window_spec_set_state(spec, mir_window_state_restored);
|
||||||
|
|
||||||
mir_surface_apply_spec(window->mir.surface, spec);
|
mir_window_apply_spec(window->mir.window, spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_window_spec_release(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||||
@ -585,7 +588,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
|
|
||||||
int _glfwPlatformWindowFocused(_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)
|
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||||
@ -597,12 +600,12 @@ int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
|||||||
|
|
||||||
int _glfwPlatformWindowVisible(_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)
|
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)
|
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||||
@ -638,7 +641,7 @@ void _glfwPlatformWaitEvents(void)
|
|||||||
{
|
{
|
||||||
pthread_mutex_lock(&_glfw.mir.eventMutex);
|
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_cond_wait(&_glfw.mir.eventCond, &_glfw.mir.eventMutex);
|
||||||
|
|
||||||
pthread_mutex_unlock(&_glfw.mir.eventMutex);
|
pthread_mutex_unlock(&_glfw.mir.eventMutex);
|
||||||
@ -681,54 +684,40 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
|||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
MirBufferStream* stream;
|
MirBufferStream* stream;
|
||||||
MirPixelFormat pixel_format = findValidPixelFormat();
|
|
||||||
|
|
||||||
int i_w = image->width;
|
int i_w = image->width;
|
||||||
int i_h = image->height;
|
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,
|
stream = mir_connection_create_buffer_stream_sync(_glfw.mir.connection,
|
||||||
i_w, i_h,
|
i_w, i_h,
|
||||||
pixel_format,
|
mir_pixel_format_argb_8888,
|
||||||
mir_buffer_usage_software);
|
mir_buffer_usage_software);
|
||||||
|
|
||||||
cursor->mir.conf = mir_cursor_configuration_from_buffer_stream(stream, xhot, yhot);
|
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;
|
MirGraphicsRegion region;
|
||||||
mir_buffer_stream_get_graphics_region(stream, ®ion);
|
mir_buffer_stream_get_graphics_region(stream, ®ion);
|
||||||
|
|
||||||
// FIXME Figure this out based on the current_pf
|
unsigned char* pixels = image->pixels;
|
||||||
bytes_per_pixel = 4;
|
char* dest = region.vaddr;
|
||||||
bytes_per_row = bytes_per_pixel * i_w;
|
int i;
|
||||||
|
|
||||||
dest = region.vaddr;
|
for (i = 0; i < i_w * i_h; i++, pixels += 4)
|
||||||
pixels = image->pixels;
|
|
||||||
|
|
||||||
r_stride = region.stride;
|
|
||||||
|
|
||||||
for (i = 0; i < i_h; i++)
|
|
||||||
{
|
{
|
||||||
memcpy(dest, pixels, bytes_per_row);
|
unsigned int alpha = pixels[3];
|
||||||
dest += r_stride;
|
*dest++ = (char)(pixels[2] * alpha / 255);
|
||||||
pixels += r_stride;
|
*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;
|
cursor->mir.customCursor = stream;
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getSystemCursorName(int shape)
|
static const char* getSystemCursorName(int shape)
|
||||||
{
|
{
|
||||||
switch (shape)
|
switch (shape)
|
||||||
{
|
{
|
||||||
@ -751,17 +740,11 @@ const char* getSystemCursorName(int shape)
|
|||||||
|
|
||||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
const char* cursor_name = getSystemCursorName(shape);
|
cursor->mir.conf = NULL;
|
||||||
|
cursor->mir.customCursor = NULL;
|
||||||
|
cursor->mir.cursorName = getSystemCursorName(shape);
|
||||||
|
|
||||||
if (cursor_name)
|
return cursor->mir.cursorName != NULL;
|
||||||
{
|
|
||||||
cursor->mir.conf = mir_cursor_configuration_from_name(cursor_name);
|
|
||||||
cursor->mir.customCursor = NULL;
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||||
@ -772,21 +755,32 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
|||||||
mir_buffer_stream_release_sync(cursor->mir.customCursor);
|
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)
|
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
if (cursor && cursor->mir.conf)
|
if (cursor)
|
||||||
{
|
{
|
||||||
window->mir.currentCursor = cursor;
|
window->mir.currentCursor = cursor;
|
||||||
|
|
||||||
mir_wait_for(mir_surface_configure_cursor(window->mir.surface, cursor->mir.conf));
|
if (cursor->mir.cursorName)
|
||||||
if (cursor->mir.customCursor)
|
|
||||||
{
|
{
|
||||||
mir_buffer_stream_swap_buffers_sync(cursor->mir.customCursor);
|
setCursorNameForWindow(window->mir.window, cursor->mir.cursorName);
|
||||||
|
}
|
||||||
|
else if (cursor->mir.conf)
|
||||||
|
{
|
||||||
|
mir_window_configure_cursor(window->mir.window, cursor->mir.conf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
_glfw.mir.disabledCursorWindow = window;
|
_glfw.mir.disabledCursorWindow = window;
|
||||||
setSurfaceConfinement(window, mir_pointer_confined_to_surface);
|
setWindowConfinement(window, mir_pointer_confined_to_window);
|
||||||
mir_wait_for(mir_surface_configure_cursor(window->mir.surface, _glfw.mir.disabledConf));
|
setCursorNameForWindow(window->mir.window, mir_disabled_cursor_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -816,7 +810,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||||||
if (_glfw.mir.disabledCursorWindow == window)
|
if (_glfw.mir.disabledCursorWindow == window)
|
||||||
{
|
{
|
||||||
_glfw.mir.disabledCursorWindow = NULL;
|
_glfw.mir.disabledCursorWindow = NULL;
|
||||||
setSurfaceConfinement(window, mir_pointer_unconfined);
|
setWindowConfinement(window, mir_pointer_unconfined);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
||||||
@ -825,7 +819,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||||||
}
|
}
|
||||||
else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
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)
|
VkSurfaceKHR* surface)
|
||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
VkMirSurfaceCreateInfoKHR sci;
|
VkMirWindowCreateInfoKHR sci;
|
||||||
PFN_vkCreateMirSurfaceKHR vkCreateMirSurfaceKHR;
|
PFN_vkCreateMirWindowKHR vkCreateMirWindowKHR;
|
||||||
|
|
||||||
vkCreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)
|
vkCreateMirWindowKHR = (PFN_vkCreateMirWindowKHR)
|
||||||
vkGetInstanceProcAddr(instance, "vkCreateMirSurfaceKHR");
|
vkGetInstanceProcAddr(instance, "vkCreateMirWindowKHR");
|
||||||
if (!vkCreateMirSurfaceKHR)
|
if (!vkCreateMirWindowKHR)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
"Mir: Vulkan instance missing VK_KHR_mir_surface extension");
|
"Mir: Vulkan instance missing VK_KHR_mir_surface extension");
|
||||||
@ -905,9 +899,9 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|||||||
memset(&sci, 0, sizeof(sci));
|
memset(&sci, 0, sizeof(sci));
|
||||||
sci.sType = VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR;
|
sci.sType = VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR;
|
||||||
sci.connection = _glfw.mir.connection;
|
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)
|
if (err)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -929,10 +923,10 @@ GLFWAPI MirConnection* glfwGetMirDisplay(void)
|
|||||||
return _glfw.mir.connection;
|
return _glfw.mir.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* handle)
|
GLFWAPI MirWindow* glfwGetMirWindow(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
return window->mir.surface;
|
return window->mir.window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user