mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
Wayland: Fix specifying the output name for the panel kitten not working
Fixes #7573
This commit is contained in:
parent
a8daf06737
commit
190566be8e
@ -74,6 +74,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Wayland: Allow fractional scales less than one (:pull:`7549`)
|
- Wayland: Allow fractional scales less than one (:pull:`7549`)
|
||||||
|
|
||||||
|
- Wayland: Fix specifying the output name for the panel kitten not working (:iss:`7573`)
|
||||||
|
|
||||||
|
|
||||||
0.35.2 [2024-06-22]
|
0.35.2 [2024-06-22]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -323,7 +323,7 @@ def generate_wrappers(glfw_header: str) -> None:
|
|||||||
void glfwWaylandRunWithActivationToken(GLFWwindow *handle, GLFWactivationcallback cb, void *cb_data)
|
void glfwWaylandRunWithActivationToken(GLFWwindow *handle, GLFWactivationcallback cb, void *cb_data)
|
||||||
bool glfwWaylandSetTitlebarColor(GLFWwindow *handle, uint32_t color, bool use_system_color)
|
bool glfwWaylandSetTitlebarColor(GLFWwindow *handle, uint32_t color, bool use_system_color)
|
||||||
void glfwWaylandRedrawCSDWindowTitle(GLFWwindow *handle)
|
void glfwWaylandRedrawCSDWindowTitle(GLFWwindow *handle)
|
||||||
void glfwWaylandSetupLayerShellForNextWindow(GLFWLayerShellConfig c)
|
void glfwWaylandSetupLayerShellForNextWindow(const GLFWLayerShellConfig *c)
|
||||||
pid_t glfwWaylandCompositorPID(void)
|
pid_t glfwWaylandCompositorPID(void)
|
||||||
unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, \
|
unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, \
|
||||||
const char *action_text, int32_t timeout, int urgency, GLFWDBusnotificationcreatedfun callback, void *data)
|
const char *action_text, int32_t timeout, int urgency, GLFWDBusnotificationcreatedfun callback, void *data)
|
||||||
|
2
glfw/glfw3.h
vendored
2
glfw/glfw3.h
vendored
@ -1309,7 +1309,7 @@ typedef enum { GLFW_FOCUS_NOT_ALLOWED, GLFW_FOCUS_EXCLUSIVE, GLFW_FOCUS_ON_DEMAN
|
|||||||
typedef struct GLFWLayerShellConfig {
|
typedef struct GLFWLayerShellConfig {
|
||||||
GLFWLayerShellType type;
|
GLFWLayerShellType type;
|
||||||
GLFWEdge edge;
|
GLFWEdge edge;
|
||||||
const char *output_name;
|
char output_name[64];
|
||||||
GLFWFocusPolicy focus_policy;
|
GLFWFocusPolicy focus_policy;
|
||||||
unsigned size_in_cells;
|
unsigned size_in_cells;
|
||||||
void (*size_callback)(GLFWwindow *window, const struct GLFWLayerShellConfig *config, unsigned monitor_width, unsigned monitor_height, uint32_t *width, uint32_t *height);
|
void (*size_callback)(GLFWwindow *window, const struct GLFWLayerShellConfig *config, unsigned monitor_width, unsigned monitor_height, uint32_t *width, uint32_t *height);
|
||||||
|
21
glfw/wl_monitor.c
vendored
21
glfw/wl_monitor.c
vendored
@ -31,7 +31,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +89,6 @@ static void outputHandleDone(void* data, struct wl_output* output UNUSED)
|
|||||||
for (int i = 0; i < _glfw.monitorCount; i++) {
|
for (int i = 0; i < _glfw.monitorCount; i++) {
|
||||||
if (_glfw.monitors[i] == monitor) return;
|
if (_glfw.monitors[i] == monitor) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +101,28 @@ static void outputHandleScale(void* data,
|
|||||||
monitor->wl.scale = factor;
|
monitor->wl.scale = factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void outputHandleName(void* data,
|
||||||
|
struct wl_output* output UNUSED,
|
||||||
|
const char* name) {
|
||||||
|
struct _GLFWmonitor *monitor = data;
|
||||||
|
if (name) strncpy(monitor->wl.friendly_name, name, sizeof(monitor->wl.friendly_name)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void outputHandleDescription(void* data,
|
||||||
|
struct wl_output* output UNUSED,
|
||||||
|
const char* description) {
|
||||||
|
struct _GLFWmonitor *monitor = data;
|
||||||
|
if (description) strncpy(monitor->wl.description, description, sizeof(monitor->wl.description)-1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static const struct wl_output_listener outputListener = {
|
static const struct wl_output_listener outputListener = {
|
||||||
outputHandleGeometry,
|
outputHandleGeometry,
|
||||||
outputHandleMode,
|
outputHandleMode,
|
||||||
outputHandleDone,
|
outputHandleDone,
|
||||||
outputHandleScale,
|
outputHandleScale,
|
||||||
|
outputHandleName,
|
||||||
|
outputHandleDescription,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +148,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
|||||||
output = wl_registry_bind(_glfw.wl.registry,
|
output = wl_registry_bind(_glfw.wl.registry,
|
||||||
name,
|
name,
|
||||||
&wl_output_interface,
|
&wl_output_interface,
|
||||||
2);
|
MIN(version, (unsigned)WL_OUTPUT_NAME_SINCE_VERSION));
|
||||||
if (!output)
|
if (!output)
|
||||||
{
|
{
|
||||||
_glfwFreeMonitor(monitor);
|
_glfwFreeMonitor(monitor);
|
||||||
|
1
glfw/wl_platform.h
vendored
1
glfw/wl_platform.h
vendored
@ -395,6 +395,7 @@ typedef struct _GLFWmonitorWayland
|
|||||||
{
|
{
|
||||||
struct wl_output* output;
|
struct wl_output* output;
|
||||||
uint32_t name;
|
uint32_t name;
|
||||||
|
char friendly_name[64], description[64];
|
||||||
int currentMode;
|
int currentMode;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
20
glfw/wl_window.c
vendored
20
glfw/wl_window.c
vendored
@ -953,14 +953,10 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled UNUSED) {
|
|||||||
|
|
||||||
static struct wl_output*
|
static struct wl_output*
|
||||||
find_output_by_name(const char* name) {
|
find_output_by_name(const char* name) {
|
||||||
if (!name) return NULL;
|
if (!name || !name[0]) return NULL;
|
||||||
int count;
|
for (int i = 0; i < _glfw.monitorCount; i++) {
|
||||||
GLFWmonitor** monitors = glfwGetMonitors(&count);
|
_GLFWmonitor *m = _glfw.monitors[i];
|
||||||
for (int i = 0; i < count; ++i) {
|
if (strcmp(m->wl.friendly_name, name) == 0) return m->wl.output;
|
||||||
_GLFWmonitor *m = (_GLFWmonitor*)monitors + i;
|
|
||||||
if (strcmp(m->name, name) == 0) {
|
|
||||||
return m->wl.output;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1399,7 +1395,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||||||
wp_viewport_destroy(window->wl.wp_viewport);
|
wp_viewport_destroy(window->wl.wp_viewport);
|
||||||
if (window->wl.org_kde_kwin_blur)
|
if (window->wl.org_kde_kwin_blur)
|
||||||
org_kde_kwin_blur_release(window->wl.org_kde_kwin_blur);
|
org_kde_kwin_blur_release(window->wl.org_kde_kwin_blur);
|
||||||
if (window->wl.layer_shell.config.output_name) free((void*)window->wl.layer_shell.config.output_name);
|
|
||||||
|
|
||||||
if (window->context.destroy)
|
if (window->context.destroy)
|
||||||
window->context.destroy(window);
|
window->context.destroy(window);
|
||||||
@ -2747,11 +2742,8 @@ GLFWAPI void glfwWaylandRedrawCSDWindowTitle(GLFWwindow *handle) {
|
|||||||
if (csd_change_title(window)) commit_window_surface_if_safe(window);
|
if (csd_change_title(window)) commit_window_surface_if_safe(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwWaylandSetupLayerShellForNextWindow(GLFWLayerShellConfig c) {
|
GLFWAPI void glfwWaylandSetupLayerShellForNextWindow(const GLFWLayerShellConfig *c) {
|
||||||
if (layer_shell_config_for_next_window.output_name) free((void*)layer_shell_config_for_next_window.output_name);
|
layer_shell_config_for_next_window = *c;
|
||||||
layer_shell_config_for_next_window = c;
|
|
||||||
if (layer_shell_config_for_next_window.output_name && !layer_shell_config_for_next_window.output_name[0]) layer_shell_config_for_next_window.output_name = NULL;
|
|
||||||
if (layer_shell_config_for_next_window.output_name) layer_shell_config_for_next_window.output_name = strdup(layer_shell_config_for_next_window.output_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
4
kitty/glfw-wrapper.h
generated
4
kitty/glfw-wrapper.h
generated
@ -1047,7 +1047,7 @@ typedef enum { GLFW_FOCUS_NOT_ALLOWED, GLFW_FOCUS_EXCLUSIVE, GLFW_FOCUS_ON_DEMAN
|
|||||||
typedef struct GLFWLayerShellConfig {
|
typedef struct GLFWLayerShellConfig {
|
||||||
GLFWLayerShellType type;
|
GLFWLayerShellType type;
|
||||||
GLFWEdge edge;
|
GLFWEdge edge;
|
||||||
const char *output_name;
|
char output_name[64];
|
||||||
GLFWFocusPolicy focus_policy;
|
GLFWFocusPolicy focus_policy;
|
||||||
unsigned size_in_cells;
|
unsigned size_in_cells;
|
||||||
void (*size_callback)(GLFWwindow *window, const struct GLFWLayerShellConfig *config, unsigned monitor_width, unsigned monitor_height, uint32_t *width, uint32_t *height);
|
void (*size_callback)(GLFWwindow *window, const struct GLFWLayerShellConfig *config, unsigned monitor_width, unsigned monitor_height, uint32_t *width, uint32_t *height);
|
||||||
@ -2320,7 +2320,7 @@ typedef void (*glfwWaylandRedrawCSDWindowTitle_func)(GLFWwindow*);
|
|||||||
GFW_EXTERN glfwWaylandRedrawCSDWindowTitle_func glfwWaylandRedrawCSDWindowTitle_impl;
|
GFW_EXTERN glfwWaylandRedrawCSDWindowTitle_func glfwWaylandRedrawCSDWindowTitle_impl;
|
||||||
#define glfwWaylandRedrawCSDWindowTitle glfwWaylandRedrawCSDWindowTitle_impl
|
#define glfwWaylandRedrawCSDWindowTitle glfwWaylandRedrawCSDWindowTitle_impl
|
||||||
|
|
||||||
typedef void (*glfwWaylandSetupLayerShellForNextWindow_func)(GLFWLayerShellConfig);
|
typedef void (*glfwWaylandSetupLayerShellForNextWindow_func)(const GLFWLayerShellConfig*);
|
||||||
GFW_EXTERN glfwWaylandSetupLayerShellForNextWindow_func glfwWaylandSetupLayerShellForNextWindow_impl;
|
GFW_EXTERN glfwWaylandSetupLayerShellForNextWindow_func glfwWaylandSetupLayerShellForNextWindow_impl;
|
||||||
#define glfwWaylandSetupLayerShellForNextWindow glfwWaylandSetupLayerShellForNextWindow_impl
|
#define glfwWaylandSetupLayerShellForNextWindow glfwWaylandSetupLayerShellForNextWindow_impl
|
||||||
|
|
||||||
|
27
kitty/glfw.c
27
kitty/glfw.c
@ -1090,17 +1090,26 @@ calculate_layer_shell_window_size(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLFWLayerShellConfig
|
static bool
|
||||||
translate_layer_shell_config(PyObject *p) {
|
translate_layer_shell_config(PyObject *p, GLFWLayerShellConfig *ans) {
|
||||||
GLFWLayerShellConfig ans = {.size_callback=calculate_layer_shell_window_size};
|
memset(ans, 0, sizeof(GLFWLayerShellConfig));
|
||||||
#define A(attr, type_check, convert) RAII_PyObject(attr, PyObject_GetAttrString(p, #attr)); if (attr == NULL) return ans; if (!type_check(attr)) { PyErr_SetString(PyExc_TypeError, #attr " not of the correct type"); return ans; }; ans.attr = convert(attr);
|
ans->size_callback = calculate_layer_shell_window_size;
|
||||||
A(output_name, PyUnicode_Check, PyUnicode_AsUTF8);
|
#define A(attr, type_check, convert) RAII_PyObject(attr, PyObject_GetAttrString(p, #attr)); if (attr == NULL) return false; if (!type_check(attr)) { PyErr_SetString(PyExc_TypeError, #attr " not of the correct type"); return false; }; ans->attr = convert(attr);
|
||||||
A(type, PyLong_Check, PyLong_AsLong);
|
A(type, PyLong_Check, PyLong_AsLong);
|
||||||
A(edge, PyLong_Check, PyLong_AsLong);
|
A(edge, PyLong_Check, PyLong_AsLong);
|
||||||
A(focus_policy, PyLong_Check, PyLong_AsLong);
|
A(focus_policy, PyLong_Check, PyLong_AsLong);
|
||||||
A(size_in_cells, PyLong_Check, PyLong_AsLong);
|
A(size_in_cells, PyLong_Check, PyLong_AsLong);
|
||||||
#undef A
|
#undef A
|
||||||
return ans;
|
#define A(attr) { \
|
||||||
|
RAII_PyObject(attr, PyObject_GetAttrString(p, #attr)); if (attr == NULL) return false; \
|
||||||
|
if (!PyUnicode_Check(attr)) { PyErr_SetString(PyExc_TypeError, #attr " not a string"); return false; };\
|
||||||
|
Py_ssize_t sz; const char *t = PyUnicode_AsUTF8AndSize(attr, &sz); \
|
||||||
|
if (sz > (ssize_t)sizeof(ans->attr)-1) { PyErr_Format(PyExc_ValueError, "%s: %s is too long", #attr, t); return false; } \
|
||||||
|
memcpy(ans->attr, t, sz); }
|
||||||
|
|
||||||
|
A(output_name);
|
||||||
|
return true;
|
||||||
|
#undef A
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
@ -1204,7 +1213,11 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
|
|||||||
if (ret == NULL) return NULL;
|
if (ret == NULL) return NULL;
|
||||||
int width = PyLong_AsLong(PyTuple_GET_ITEM(ret, 0)), height = PyLong_AsLong(PyTuple_GET_ITEM(ret, 1));
|
int width = PyLong_AsLong(PyTuple_GET_ITEM(ret, 0)), height = PyLong_AsLong(PyTuple_GET_ITEM(ret, 1));
|
||||||
Py_CLEAR(ret);
|
Py_CLEAR(ret);
|
||||||
if (is_layer_shell) glfwWaylandSetupLayerShellForNextWindow(translate_layer_shell_config(layer_shell_config));
|
if (is_layer_shell) {
|
||||||
|
GLFWLayerShellConfig lsc = {0};
|
||||||
|
if (!translate_layer_shell_config(layer_shell_config, &lsc)) return NULL;
|
||||||
|
glfwWaylandSetupLayerShellForNextWindow(&lsc);
|
||||||
|
}
|
||||||
GLFWwindow *glfw_window = glfwCreateWindow(width, height, title, NULL, temp_window ? temp_window : common_context);
|
GLFWwindow *glfw_window = glfwCreateWindow(width, height, title, NULL, temp_window ? temp_window : common_context);
|
||||||
if (temp_window) { glfwDestroyWindow(temp_window); temp_window = NULL; }
|
if (temp_window) { glfwDestroyWindow(temp_window); temp_window = NULL; }
|
||||||
if (glfw_window == NULL) { PyErr_SetString(PyExc_ValueError, "Failed to create GLFWwindow"); return NULL; }
|
if (glfw_window == NULL) { PyErr_SetString(PyExc_ValueError, "Failed to create GLFWwindow"); return NULL; }
|
||||||
|
Loading…
Reference in New Issue
Block a user