From 2b904ccef43f88b53b23f9a9159f7bad72d37574 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 21 Apr 2022 06:47:14 +0200 Subject: Apply changes from upstream: https://gitlab.gnome.org/jadahl/libdecor --- libdecor/src/plugins/cairo/libdecor-cairo.c | 143 ++++++-------------------- libdecor/src/plugins/dummy/libdecor-dummy.c | 49 +-------- libdecor/src/plugins/gtk/libdecor-gtk.c | 154 ++++++---------------------- 3 files changed, 64 insertions(+), 282 deletions(-) (limited to 'libdecor/src/plugins') diff --git a/libdecor/src/plugins/cairo/libdecor-cairo.c b/libdecor/src/plugins/cairo/libdecor-cairo.c index 704939b50..642bcb4e4 100644 --- a/libdecor/src/plugins/cairo/libdecor-cairo.c +++ b/libdecor/src/plugins/cairo/libdecor-cairo.c @@ -1007,13 +1007,11 @@ ensure_border_surfaces(struct libdecor_frame_cairo *frame_cairo) frame_cairo->shadow.opaque = false; ensure_component(frame_cairo, &frame_cairo->shadow); -#if 1 // ! APPLY_FLTK_CHANGES // activate this to get feedback about its impact libdecor_frame_get_min_content_size(&frame_cairo->frame, &min_width, &min_height); - libdecor_frame_set_min_content_size(&frame_cairo->frame, - MAX(min_width, (int)MAX(56, 4 * BUTTON_WIDTH)), + libdecor_frame_set_min_content_size(&frame_cairo->frame, + MAX(min_width, (int)MAX(56, 4 * BUTTON_WIDTH)), MAX(min_height, (int)MAX(56, TITLE_HEIGHT + 1))); -#endif } static void @@ -1335,8 +1333,7 @@ draw_component_content(struct libdecor_frame_cairo *frame_cairo, cairo_rel_line_to(cr, small - 1, 0); cairo_rel_line_to(cr, 0, small - 1); cairo_line_to(cr, x + small - 1, y + small - 1); - } - else { + } else { cairo_rectangle(cr, x, y, SYM_DIM - 1, SYM_DIM - 1); } cairo_stroke(cr); @@ -1670,32 +1667,6 @@ draw_decoration(struct libdecor_frame_cairo *frame_cairo) } } -static void -set_window_geometry(struct libdecor_frame_cairo *frame_cairo) -{ - struct libdecor_frame *frame = &frame_cairo->frame; - int x = 0, y = 0, width = 0, height = 0; - - switch (frame_cairo->decoration_type) { - case DECORATION_TYPE_NONE: - x = 0; - y = 0; - width = libdecor_frame_get_content_width(frame); - height = libdecor_frame_get_content_height(frame); - break; - case DECORATION_TYPE_ALL: - case DECORATION_TYPE_TILED: - case DECORATION_TYPE_MAXIMIZED: - x = 0; - y = -(int)TITLE_HEIGHT; - width = libdecor_frame_get_content_width(frame); - height = libdecor_frame_get_content_height(frame) + TITLE_HEIGHT; - break; - } - - libdecor_frame_set_window_geometry(frame, x, y, width, height); -} - static enum decoration_type window_state_to_decoration_type(enum libdecor_window_state window_state) { @@ -1753,7 +1724,6 @@ libdecor_plugin_cairo_frame_commit(struct libdecor_plugin *plugin, frame_cairo->window_state = new_window_state; draw_decoration(frame_cairo); - set_window_geometry(frame_cairo); } static void @@ -1791,24 +1761,6 @@ libdecor_plugin_cairo_frame_property_changed(struct libdecor_plugin *plugin, } } -static void -libdecor_plugin_cairo_frame_translate_coordinate(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - int content_x, - int content_y, - int *frame_x, - int *frame_y) -{ - struct libdecor_frame_cairo *frame_cairo = - (struct libdecor_frame_cairo *) frame; - - *frame_x = content_x; - *frame_y = content_y; - - if (frame_cairo->title_bar.is_showing) - *frame_y += TITLE_HEIGHT; -} - static bool streq(const char *str1, const char *str2) @@ -1876,63 +1828,38 @@ libdecor_plugin_cairo_frame_popup_ungrab(struct libdecor_plugin *plugin, } static bool -libdecor_plugin_cairo_configuration_get_content_size( - struct libdecor_plugin *plugin, - struct libdecor_configuration *configuration, - struct libdecor_frame *frame, - int *content_width, - int *content_height) -{ - int win_width, win_height; - if (!libdecor_configuration_get_window_size(configuration, - &win_width, - &win_height)) - return false; - - enum libdecor_window_state state; - if (!libdecor_configuration_get_window_state(configuration, &state)) { - return false; - } +libdecor_plugin_cairo_frame_get_border_size(struct libdecor_plugin *plugin, + struct libdecor_frame *frame, + struct libdecor_configuration *configuration, + int *left, + int *right, + int *top, + int *bottom) +{ + enum libdecor_window_state window_state; - switch (window_state_to_decoration_type(state)) { - case DECORATION_TYPE_NONE: - *content_width = win_width; - *content_height = win_height; - break; - case DECORATION_TYPE_ALL: - case DECORATION_TYPE_TILED: - case DECORATION_TYPE_MAXIMIZED: - *content_width = win_width; - *content_height = win_height - TITLE_HEIGHT; - break; + if (configuration) { + if (!libdecor_configuration_get_window_state( + configuration, &window_state)) + return false; + } else { + window_state = libdecor_frame_get_window_state(frame); } - return true; -} + if (left) + *left = 0; + if (right) + *right = 0; + if (bottom) + *bottom = 0; + if (top) { + enum decoration_type type = window_state_to_decoration_type(window_state); -static bool -libdecor_plugin_cairo_frame_get_window_size_for( - struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - struct libdecor_state *state, - int *window_width, - int *window_height) -{ - enum libdecor_window_state window_state = - libdecor_state_get_window_state(state); - - switch (window_state_to_decoration_type(window_state)) { - case DECORATION_TYPE_NONE: - *window_width = libdecor_state_get_content_width(state); - *window_height = libdecor_state_get_content_height(state); - break; - case DECORATION_TYPE_ALL: - case DECORATION_TYPE_TILED: - case DECORATION_TYPE_MAXIMIZED: - *window_width = libdecor_state_get_content_width(state); - *window_height = - libdecor_state_get_content_height(state) + TITLE_HEIGHT; - break; + if (((struct libdecor_frame_cairo *)frame)->title_bar.is_showing && + (type != DECORATION_TYPE_NONE)) + *top = TITLE_HEIGHT; + else + *top = 0; } return true; @@ -1947,15 +1874,9 @@ static struct libdecor_plugin_interface cairo_plugin_iface = { .frame_free = libdecor_plugin_cairo_frame_free, .frame_commit = libdecor_plugin_cairo_frame_commit, .frame_property_changed = libdecor_plugin_cairo_frame_property_changed, - .frame_translate_coordinate = - libdecor_plugin_cairo_frame_translate_coordinate, .frame_popup_grab = libdecor_plugin_cairo_frame_popup_grab, .frame_popup_ungrab = libdecor_plugin_cairo_frame_popup_ungrab, - - .configuration_get_content_size = - libdecor_plugin_cairo_configuration_get_content_size, - .frame_get_window_size_for = - libdecor_plugin_cairo_frame_get_window_size_for, + .frame_get_border_size = libdecor_plugin_cairo_frame_get_border_size, }; static void diff --git a/libdecor/src/plugins/dummy/libdecor-dummy.c b/libdecor/src/plugins/dummy/libdecor-dummy.c index 1891b7e51..7dc2428ca 100644 --- a/libdecor/src/plugins/dummy/libdecor-dummy.c +++ b/libdecor/src/plugins/dummy/libdecor-dummy.c @@ -46,6 +46,7 @@ libdecor_plugin_dummy_destroy(struct libdecor_plugin *plugin) struct libdecor_plugin_dummy *plugin_dummy = (struct libdecor_plugin_dummy *) plugin; + libdecor_plugin_release(plugin); free(plugin_dummy); } @@ -79,18 +80,6 @@ libdecor_plugin_dummy_frame_property_changed(struct libdecor_plugin *plugin, { } -static void -libdecor_plugin_dummy_frame_translate_coordinate(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - int content_x, - int content_y, - int *frame_x, - int *frame_y) -{ - *frame_x = content_x; - *frame_y = content_y; -} - static void libdecor_plugin_dummy_frame_popup_grab(struct libdecor_plugin *plugin, struct libdecor_frame *frame, @@ -105,32 +94,6 @@ libdecor_plugin_dummy_frame_popup_ungrab(struct libdecor_plugin *plugin, { } -static bool -libdecor_plugin_dummy_configuration_get_content_size( - struct libdecor_plugin *plugin, - struct libdecor_configuration *configuration, - struct libdecor_frame *frame, - int *content_width, - int *content_height) -{ - return libdecor_configuration_get_window_size(configuration, - content_width, - content_height); -} - -static bool -libdecor_plugin_dummy_frame_get_window_size_for( - struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - struct libdecor_state *state, - int *window_width, - int *window_height) -{ - *window_width = libdecor_state_get_content_width (state); - *window_height = libdecor_state_get_content_height (state); - return true; -} - static struct libdecor_plugin_interface dummy_plugin_iface = { .destroy = libdecor_plugin_dummy_destroy, @@ -138,15 +101,8 @@ static struct libdecor_plugin_interface dummy_plugin_iface = { .frame_free = libdecor_plugin_dummy_frame_free, .frame_commit = libdecor_plugin_dummy_frame_commit, .frame_property_changed = libdecor_plugin_dummy_frame_property_changed, - .frame_translate_coordinate = - libdecor_plugin_dummy_frame_translate_coordinate, .frame_popup_grab = libdecor_plugin_dummy_frame_popup_grab, .frame_popup_ungrab = libdecor_plugin_dummy_frame_popup_ungrab, - - .configuration_get_content_size = - libdecor_plugin_dummy_configuration_get_content_size, - .frame_get_window_size_for = - libdecor_plugin_dummy_frame_get_window_size_for, }; static struct libdecor_plugin * @@ -155,7 +111,7 @@ libdecor_plugin_new(struct libdecor *context) struct libdecor_plugin_dummy *plugin_dummy; plugin_dummy = zalloc(sizeof *plugin_dummy); - plugin_dummy->plugin.iface = &dummy_plugin_iface; + libdecor_plugin_init(&plugin_dummy->plugin, context, &dummy_plugin_iface); plugin_dummy->context = context; libdecor_notify_plugin_ready(context); @@ -170,6 +126,7 @@ static struct libdecor_plugin_priority priorities[] = { LIBDECOR_EXPORT const struct libdecor_plugin_description libdecor_plugin_description = { .api_version = LIBDECOR_PLUGIN_API_VERSION, + .capabilities = LIBDECOR_PLUGIN_CAPABILITY_BASE, .description = "dummy libdecor plugin", .priorities = priorities, .constructor = libdecor_plugin_new, diff --git a/libdecor/src/plugins/gtk/libdecor-gtk.c b/libdecor/src/plugins/gtk/libdecor-gtk.c index c5658bce9..e23115c23 100644 --- a/libdecor/src/plugins/gtk/libdecor-gtk.c +++ b/libdecor/src/plugins/gtk/libdecor-gtk.c @@ -1486,36 +1486,6 @@ draw_decoration(struct libdecor_frame_gtk *frame_gtk) } } -static void -set_window_geometry(struct libdecor_frame_gtk *frame_gtk) -{ - struct libdecor_frame *frame = &frame_gtk->frame; - int x = 0, y = 0, width = 0, height = 0; -#if APPLY_FLTK_CHANGES - const int title_height = GTK_IS_WIDGET(frame_gtk->header) ? gtk_widget_get_allocated_height(frame_gtk->header) : 0; -#else - const int title_height = gtk_widget_get_allocated_height(frame_gtk->header); -#endif - - switch (frame_gtk->decoration_type) { - case DECORATION_TYPE_NONE: - x = 0; - y = 0; - width = libdecor_frame_get_content_width(frame); - height = libdecor_frame_get_content_height(frame); - break; - case DECORATION_TYPE_ALL: - case DECORATION_TYPE_TITLE_ONLY: - x = 0; - y = -title_height; - width = libdecor_frame_get_content_width(frame); - height = libdecor_frame_get_content_height(frame) + title_height; - break; - } - - libdecor_frame_set_window_geometry(frame, x, y, width, height); -} - static enum decoration_type window_state_to_decoration_type(enum libdecor_window_state window_state) { @@ -1571,7 +1541,6 @@ libdecor_plugin_gtk_frame_commit(struct libdecor_plugin *plugin, frame_gtk->decoration_type = new_decoration_type; draw_decoration(frame_gtk); - set_window_geometry(frame_gtk); /* set fixed window size */ if (!resizable(frame_gtk)) { @@ -1626,27 +1595,6 @@ libdecor_plugin_gtk_frame_property_changed(struct libdecor_plugin *plugin, } } -static void -libdecor_plugin_gtk_frame_translate_coordinate(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - int content_x, - int content_y, - int *frame_x, - int *frame_y) -{ - struct libdecor_frame_gtk *frame_gtk = - (struct libdecor_frame_gtk *) frame; - - *frame_x = content_x; - *frame_y = content_y; - -#if APPLY_FLTK_CHANGES - *frame_y += (frame_gtk->header ? gtk_widget_get_allocated_height(frame_gtk->header) : 0); -#else - *frame_y += gtk_widget_get_allocated_height(frame_gtk->header); -#endif -} - static void update_component_focus(struct libdecor_frame_gtk *frame_gtk, struct wl_surface *surface, @@ -1807,78 +1755,38 @@ libdecor_plugin_gtk_frame_popup_ungrab(struct libdecor_plugin *plugin, } static bool -libdecor_plugin_gtk_configuration_get_content_size( - struct libdecor_plugin *plugin, - struct libdecor_configuration *configuration, - struct libdecor_frame *frame, - int *content_width, - int *content_height) +libdecor_plugin_gtk_frame_get_border_size(struct libdecor_plugin *plugin, + struct libdecor_frame *frame, + struct libdecor_configuration *configuration, + int *left, + int *right, + int *top, + int *bottom) { - struct libdecor_frame_gtk *frame_gtk = - (struct libdecor_frame_gtk *) frame; - int win_width, win_height; - enum libdecor_window_state state; - - if (!libdecor_configuration_get_window_size(configuration, - &win_width, - &win_height)) - return false; - - if (!libdecor_configuration_get_window_state(configuration, &state)) - return false; -#if APPLY_FLTK_CHANGES - const int title_bar_height = GTK_IS_WIDGET(frame_gtk->header)? gtk_widget_get_allocated_height(frame_gtk->header) : 0; -#else - const int title_bar_height = gtk_widget_get_allocated_height(frame_gtk->header); -#endif + enum libdecor_window_state window_state; - switch (window_state_to_decoration_type(state)) { - case DECORATION_TYPE_NONE: - *content_width = win_width; - *content_height = win_height; - break; - case DECORATION_TYPE_ALL: - case DECORATION_TYPE_TITLE_ONLY: - *content_width = win_width; - *content_height = win_height - title_bar_height; - break; + if (configuration) { + if (!libdecor_configuration_get_window_state( + configuration, &window_state)) + return false; + } else { + window_state = libdecor_frame_get_window_state(frame); } - return true; -} - -static bool -libdecor_plugin_gtk_frame_get_window_size_for( - struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - struct libdecor_state *state, - int *window_width, - int *window_height) -{ - enum libdecor_window_state window_state = - libdecor_state_get_window_state (state); - -#if APPLY_FLTK_CHANGES - struct libdecor_frame_gtk *frame_gtk = (struct libdecor_frame_gtk *)frame; - const int title_bar_height = (GTK_IS_WIDGET(frame_gtk->header) ? gtk_widget_get_allocated_height( - frame_gtk->header) : 0); -#else - GtkWidget *header = ((struct libdecor_frame_gtk *)frame)->header; - - const int title_bar_height = header ? gtk_widget_get_allocated_height(header) : 0; -#endif + if (left) + *left = 0; + if (right) + *right = 0; + if (bottom) + *bottom = 0; + if (top) { + GtkWidget *header = ((struct libdecor_frame_gtk *)frame)->header; + enum decoration_type type = window_state_to_decoration_type(window_state); - switch (window_state_to_decoration_type(window_state)) { - case DECORATION_TYPE_NONE: - *window_width = libdecor_state_get_content_width(state); - *window_height = libdecor_state_get_content_height(state); - break; - case DECORATION_TYPE_ALL: - case DECORATION_TYPE_TITLE_ONLY: - *window_width = libdecor_state_get_content_width(state); - *window_height = - libdecor_state_get_content_height(state) + title_bar_height; - break; + if (header && (type != DECORATION_TYPE_NONE)) + *top = gtk_widget_get_allocated_height(header); + else + *top = 0; } return true; @@ -1893,15 +1801,11 @@ static struct libdecor_plugin_interface gtk_plugin_iface = { .frame_free = libdecor_plugin_gtk_frame_free, .frame_commit = libdecor_plugin_gtk_frame_commit, .frame_property_changed = libdecor_plugin_gtk_frame_property_changed, - .frame_translate_coordinate = - libdecor_plugin_gtk_frame_translate_coordinate, + .frame_popup_grab = libdecor_plugin_gtk_frame_popup_grab, .frame_popup_ungrab = libdecor_plugin_gtk_frame_popup_ungrab, - .configuration_get_content_size = - libdecor_plugin_gtk_configuration_get_content_size, - .frame_get_window_size_for = - libdecor_plugin_gtk_frame_get_window_size_for, + .frame_get_border_size = libdecor_plugin_gtk_frame_get_border_size, }; static void -- cgit v1.2.3