Merge branch 'diff_glfw_upstream' of https://github.com/Luflosi/kitty

This commit is contained in:
Kovid Goyal
2019-06-12 19:40:07 +05:30
4 changed files with 43 additions and 32 deletions

7
glfw/wl_init.c vendored
View File

@@ -46,7 +46,8 @@ static inline int min(int n1, int n2)
return n1 < n2 ? n1 : n2;
}
static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, int* which)
static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
int* which)
{
int focus;
_GLFWwindow* window = _glfw.windowListHead;
@@ -174,7 +175,8 @@ static void pointerHandleMotion(void* data,
switch (window->wl.decorations.focus)
{
case mainWindow:
_glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY);
_glfwInputCursorPos(window,
window->wl.cursorPosX, window->wl.cursorPosY);
return;
case topDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
@@ -217,7 +219,6 @@ static void pointerHandleButton(void* data,
{
_GLFWwindow* window = _glfw.wl.pointerFocus;
int glfwButton;
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
if (!window)

42
glfw/wl_monitor.c vendored
View File

@@ -34,15 +34,15 @@
static void outputHandleGeometry(void* data,
struct wl_output* output,
int32_t x,
int32_t y,
int32_t physicalWidth,
int32_t physicalHeight,
int32_t subpixel,
const char* make,
const char* model,
int32_t transform)
struct wl_output* output,
int32_t x,
int32_t y,
int32_t physicalWidth,
int32_t physicalHeight,
int32_t subpixel,
const char* make,
const char* model,
int32_t transform)
{
struct _GLFWmonitor *monitor = data;
char name[1024];
@@ -57,11 +57,11 @@ static void outputHandleGeometry(void* data,
}
static void outputHandleMode(void* data,
struct wl_output* output,
uint32_t flags,
int32_t width,
int32_t height,
int32_t refresh)
struct wl_output* output,
uint32_t flags,
int32_t width,
int32_t height,
int32_t refresh)
{
struct _GLFWmonitor *monitor = data;
GLFWvidmode mode;
@@ -71,7 +71,7 @@ static void outputHandleMode(void* data,
mode.redBits = 8;
mode.greenBits = 8;
mode.blueBits = 8;
mode.refreshRate = (int)round(refresh / 1000.0);
mode.refreshRate = (int) round(refresh / 1000.0);
monitor->modeCount++;
monitor->modes =
@@ -93,8 +93,8 @@ static void outputHandleDone(void* data, struct wl_output* output)
}
static void outputHandleScale(void* data,
struct wl_output* output,
int32_t factor)
struct wl_output* output,
int32_t factor)
{
struct _GLFWmonitor *monitor = data;
if (factor > 0 && factor < 24)
@@ -173,7 +173,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
*yscale = (float) monitor->wl.scale;
}
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height)
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
int* xpos, int* ypos,
int* width, int* height)
{
if (xpos)
*xpos = monitor->wl.x;
@@ -203,7 +205,8 @@ bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
return false;
}
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
const GLFWgammaramp* ramp)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Gamma ramp access is not available");
@@ -220,3 +223,4 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->wl.output;
}

13
glfw/wl_platform.h vendored
View File

@@ -133,10 +133,10 @@ typedef struct _GLFWdecorationWayland
typedef struct _GLFWwindowWayland
{
int width, height;
bool visible;
bool maximized;
bool hovered;
bool transparent;
bool visible;
bool maximized;
bool hovered;
bool transparent;
struct wl_surface* surface;
struct wl_egl_window* native;
struct wl_callback* callback;
@@ -167,10 +167,10 @@ typedef struct _GLFWwindowWayland
struct zwp_idle_inhibitor_v1* idleInhibitor;
bool fullscreened;
bool fullscreened;
struct {
bool serverSide;
bool serverSide;
struct wl_buffer* buffer;
_GLFWdecorationWayland top, left, right, bottom;
int focus;
@@ -321,3 +321,4 @@ void _glfwSetupWaylandDataDevice(void);
void _glfwSetupWaylandPrimarySelectionDevice(void);
void animateCursorImage(id_type timer_id, void *data);
struct wl_cursor* _glfwLoadCursor(GLFWCursorShape);

13
glfw/wl_window.c vendored
View File

@@ -367,8 +367,8 @@ static void xdgDecorationHandleConfigure(void* data,
uint32_t mode)
{
_GLFWwindow* window = data;
window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
if (!window->wl.decorations.serverSide)
window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
if (!window->wl.decorations.serverSide)
createDecorations(window);
}
@@ -914,6 +914,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
destroyDecorations(window);
if (window->wl.xdg.decoration)
zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
if (window->wl.decorations.buffer)
wl_buffer_destroy(window->wl.decorations.buffer);
@@ -1001,13 +1002,15 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
}
}
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
int numer, int denom)
{
// TODO: find out how to trigger a resize.
// The actual limits are checked in the xdg_toplevel::configure handler.
}
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
int* width, int* height)
{
_glfwPlatformGetWindowSize(window, width, height);
*width *= window->wl.scale;
@@ -2001,6 +2004,7 @@ frame_handle_redraw(void *data, struct wl_callback *callback, uint32_t time) {
wl_callback_destroy(callback);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
@@ -2042,3 +2046,4 @@ GLFWAPI unsigned long long glfwDBusUserNotify(const char *app_name, const char*
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {
glfw_dbus_set_user_notification_activated_handler(handler);
}