mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Make CSD API functions naming consistent
This commit is contained in:
24
glfw/wl_client_side_decorations.c
vendored
24
glfw/wl_client_side_decorations.c
vendored
@@ -136,7 +136,7 @@ alloc_buffer_pair(uintptr_t window_id, _GLFWWaylandBufferPair *pair, struct wl_s
|
||||
#define st decs.shadow_tile
|
||||
|
||||
void
|
||||
initialize_csd_metrics(_GLFWwindow *window) {
|
||||
csd_initialize_metrics(_GLFWwindow *window) {
|
||||
decs.metrics.width = 12;
|
||||
decs.metrics.top = 36;
|
||||
decs.metrics.visible_titlebar_height = decs.metrics.top - decs.metrics.width;
|
||||
@@ -450,25 +450,27 @@ csd_set_visible(_GLFWwindow *window, bool visible) {
|
||||
}
|
||||
|
||||
void
|
||||
free_all_csd_resources(_GLFWwindow *window) {
|
||||
csd_free_all_resources(_GLFWwindow *window) {
|
||||
free_csd_surfaces(window);
|
||||
free_csd_buffers(window);
|
||||
if (decs.shadow_tile.data) free(decs.shadow_tile.data);
|
||||
decs.shadow_tile.data = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
change_csd_title(_GLFWwindow *window) {
|
||||
if (!window_is_csd_capable(window)) return;
|
||||
if (ensure_csd_resources(window)) return; // CSD were re-rendered for other reasons
|
||||
bool
|
||||
csd_change_title(_GLFWwindow *window) {
|
||||
if (!window_is_csd_capable(window)) return false;
|
||||
if (ensure_csd_resources(window)) return true; // CSD were re-rendered for other reasons
|
||||
if (decs.top.surface) {
|
||||
update_title_bar(window);
|
||||
damage_csd(top, decs.top.buffer.front);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height) {
|
||||
csd_set_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height) {
|
||||
bool has_csd = window_is_csd_capable(window) && decs.top.surface && !(window->wl.current.toplevel_states & TOPLEVEL_STATE_FULLSCREEN);
|
||||
bool size_specified_by_compositor = *width > 0 && *height > 0;
|
||||
if (!size_specified_by_compositor) {
|
||||
@@ -486,12 +488,12 @@ set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
set_titlebar_color(_GLFWwindow *window, uint32_t color, bool use_system_color) {
|
||||
bool
|
||||
csd_set_titlebar_color(_GLFWwindow *window, uint32_t color, bool use_system_color) {
|
||||
bool use_custom_color = !use_system_color;
|
||||
decs.use_custom_titlebar_color = use_custom_color;
|
||||
decs.titlebar_color = color;
|
||||
change_csd_title(window);
|
||||
return csd_change_title(window);
|
||||
}
|
||||
|
||||
#define x window->wl.allCursorPosX
|
||||
@@ -701,7 +703,7 @@ csd_handle_pointer_event(_GLFWwindow *window, int button, int state) {
|
||||
default: handle_pointer_button(window, button, state); break;
|
||||
}
|
||||
if (decs.titlebar_needs_update) {
|
||||
change_csd_title(window);
|
||||
csd_change_title(window);
|
||||
if (!window->wl.waiting_for_swap_to_commit) wl_surface_commit(window->wl.surface);
|
||||
}
|
||||
}
|
||||
|
||||
10
glfw/wl_client_side_decorations.h
vendored
10
glfw/wl_client_side_decorations.h
vendored
@@ -8,10 +8,10 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
void initialize_csd_metrics(_GLFWwindow *window);
|
||||
void free_all_csd_resources(_GLFWwindow *window);
|
||||
void change_csd_title(_GLFWwindow *window);
|
||||
void set_csd_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height);
|
||||
void set_titlebar_color(_GLFWwindow *window, uint32_t color, bool use_system_color);
|
||||
void csd_initialize_metrics(_GLFWwindow *window);
|
||||
void csd_free_all_resources(_GLFWwindow *window);
|
||||
bool csd_change_title(_GLFWwindow *window);
|
||||
void csd_set_window_geometry(_GLFWwindow *window, int32_t *width, int32_t *height);
|
||||
bool csd_set_titlebar_color(_GLFWwindow *window, uint32_t color, bool use_system_color);
|
||||
void csd_set_visible(_GLFWwindow *window, bool visible);
|
||||
void csd_handle_pointer_event(_GLFWwindow *window, int button, int state);
|
||||
|
||||
23
glfw/wl_window.c
vendored
23
glfw/wl_window.c
vendored
@@ -765,7 +765,7 @@ apply_xdg_configure_changes(_GLFWwindow *window) {
|
||||
|
||||
if (window->wl.pending_state) {
|
||||
int width = window->wl.pending.width, height = window->wl.pending.height;
|
||||
set_csd_window_geometry(window, &width, &height);
|
||||
csd_set_window_geometry(window, &width, &height);
|
||||
bool resized = dispatchChangesAfterConfigure(window, width, height);
|
||||
csd_set_visible(window, !(window->wl.decorations.serverSide || window->monitor || window->wl.current.toplevel_states & TOPLEVEL_STATE_FULLSCREEN));
|
||||
debug("Final window content size: %dx%d resized: %d\n", width, height, resized);
|
||||
@@ -1277,7 +1277,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
{
|
||||
window->wl.layer_shell.config = layer_shell_config_for_next_window;
|
||||
memset(&layer_shell_config_for_next_window, 0, sizeof(layer_shell_config_for_next_window));
|
||||
initialize_csd_metrics(window);
|
||||
csd_initialize_metrics(window);
|
||||
window->wl.transparent = fbconfig->transparent;
|
||||
strncpy(window->wl.appId, wndconfig->wl.appId, sizeof(window->wl.appId));
|
||||
window->swaps_disallowed = true;
|
||||
@@ -1363,7 +1363,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
if (window->context.destroy)
|
||||
window->context.destroy(window);
|
||||
|
||||
free_all_csd_resources(window);
|
||||
csd_free_all_resources(window);
|
||||
if (window->wl.xdg.decoration)
|
||||
zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
|
||||
|
||||
@@ -1395,8 +1395,11 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
// one causes an abort(). Since titles this large are meaningless anyway
|
||||
// ensure they do not happen.
|
||||
window->wl.title = utf_8_strndup(title, 2048);
|
||||
if (window->wl.xdg.toplevel) xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
|
||||
change_csd_title(window);
|
||||
if (window->wl.xdg.toplevel) {
|
||||
xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
|
||||
csd_change_title(window);
|
||||
commit_window_surface_if_safe(window);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED,
|
||||
@@ -1440,7 +1443,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
window->wl.user_requested_content_size.width = width;
|
||||
window->wl.user_requested_content_size.height = height;
|
||||
int32_t w = 0, h = 0;
|
||||
set_csd_window_geometry(window, &w, &h);
|
||||
csd_set_window_geometry(window, &w, &h);
|
||||
window->wl.width = w; window->wl.height = h;
|
||||
resizeFramebuffer(window);
|
||||
csd_set_visible(window, true); // resizes the csd iff the window currently has csd
|
||||
@@ -2691,7 +2694,7 @@ GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun
|
||||
GLFWAPI bool glfwWaylandSetTitlebarColor(GLFWwindow *handle, uint32_t color, bool use_system_color) {
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
if (!window->wl.decorations.serverSide) {
|
||||
set_titlebar_color(window, color, use_system_color);
|
||||
csd_set_titlebar_color(window, color, use_system_color);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -2699,7 +2702,7 @@ GLFWAPI bool glfwWaylandSetTitlebarColor(GLFWwindow *handle, uint32_t color, boo
|
||||
|
||||
GLFWAPI void glfwWaylandRedrawCSDWindowTitle(GLFWwindow *handle) {
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
change_csd_title(window);
|
||||
if (csd_change_title(window)) commit_window_surface_if_safe(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWaylandSetupLayerShellForNextWindow(GLFWLayerShellConfig c) {
|
||||
@@ -2713,9 +2716,7 @@ void
|
||||
_glfwPlatformInputColorScheme(GLFWColorScheme appearance UNUSED) {
|
||||
_GLFWwindow* window = _glfw.windowListHead;
|
||||
while (window) {
|
||||
change_csd_title(window);
|
||||
commit_window_surface_if_safe(window);
|
||||
|
||||
glfwWaylandRedrawCSDWindowTitle((GLFWwindow*)window);
|
||||
window = window->next;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user