This commit is contained in:
ManoloFLTK 2022-04-21 06:47:14 +02:00
parent 804c48515d
commit 2b904ccef4
7 changed files with 171 additions and 437 deletions

View File

@ -656,8 +656,7 @@ keyboard_key(void *data,
printf("set fixed-size\n"); printf("set fixed-size\n");
libdecor_frame_unset_capabilities(window->frame, libdecor_frame_unset_capabilities(window->frame,
LIBDECOR_ACTION_RESIZE); LIBDECOR_ACTION_RESIZE);
} } else {
else {
printf("set resizeable\n"); printf("set resizeable\n");
libdecor_frame_set_capabilities(window->frame, libdecor_frame_set_capabilities(window->frame,
LIBDECOR_ACTION_RESIZE); LIBDECOR_ACTION_RESIZE);

View File

@ -127,18 +127,6 @@ libdecor_plugin_fallback_frame_property_changed(struct libdecor_plugin *plugin,
{ {
} }
static void
libdecor_plugin_fallback_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 static void
libdecor_plugin_fallback_frame_popup_grab(struct libdecor_plugin *plugin, libdecor_plugin_fallback_frame_popup_grab(struct libdecor_plugin *plugin,
struct libdecor_frame *frame, struct libdecor_frame *frame,
@ -154,27 +142,16 @@ libdecor_plugin_fallback_frame_popup_ungrab(struct libdecor_plugin *plugin,
} }
static bool static bool
libdecor_plugin_fallback_configuration_get_content_size(struct libdecor_plugin *plugin, libdecor_plugin_fallback_frame_get_border_size(struct libdecor_plugin *plugin,
struct libdecor_configuration *configuration, struct libdecor_frame *frame,
struct libdecor_frame *frame, struct libdecor_configuration *configuration,
int *content_width, int *left,
int *content_height) int *right,
int *top,
int *bottom)
{ {
return libdecor_configuration_get_window_size(configuration, *left = *right = *top = *bottom = 0;
content_width,
content_height);
}
static bool
libdecor_plugin_fallback_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; return true;
} }
@ -186,12 +163,9 @@ static struct libdecor_plugin_interface fallback_plugin_iface = {
.frame_free = libdecor_plugin_fallback_frame_free, .frame_free = libdecor_plugin_fallback_frame_free,
.frame_commit = libdecor_plugin_fallback_frame_commit, .frame_commit = libdecor_plugin_fallback_frame_commit,
.frame_property_changed = libdecor_plugin_fallback_frame_property_changed, .frame_property_changed = libdecor_plugin_fallback_frame_property_changed,
.frame_translate_coordinate =
libdecor_plugin_fallback_frame_translate_coordinate,
.frame_popup_grab = libdecor_plugin_fallback_frame_popup_grab, .frame_popup_grab = libdecor_plugin_fallback_frame_popup_grab,
.frame_popup_ungrab = libdecor_plugin_fallback_frame_popup_ungrab, .frame_popup_ungrab = libdecor_plugin_fallback_frame_popup_ungrab,
.configuration_get_content_size = libdecor_plugin_fallback_configuration_get_content_size, .frame_get_border_size = libdecor_plugin_fallback_frame_get_border_size,
.frame_get_window_size_for = libdecor_plugin_fallback_frame_get_window_size_for,
}; };
struct libdecor_plugin * struct libdecor_plugin *

View File

@ -97,12 +97,6 @@ struct libdecor_plugin_interface {
struct libdecor_configuration *configuration); struct libdecor_configuration *configuration);
void (*frame_property_changed)(struct libdecor_plugin *plugin, void (*frame_property_changed)(struct libdecor_plugin *plugin,
struct libdecor_frame *frame); struct libdecor_frame *frame);
void (* frame_translate_coordinate)(struct libdecor_plugin *plugin,
struct libdecor_frame *frame,
int content_x,
int content_y,
int *window_x,
int *window_y);
void (* frame_popup_grab)(struct libdecor_plugin *plugin, void (* frame_popup_grab)(struct libdecor_plugin *plugin,
struct libdecor_frame *frame, struct libdecor_frame *frame,
const char *seat_name); const char *seat_name);
@ -110,17 +104,13 @@ struct libdecor_plugin_interface {
struct libdecor_frame *frame, struct libdecor_frame *frame,
const char *seat_name); const char *seat_name);
bool (* frame_get_window_size_for)(struct libdecor_plugin *plugin, bool (* frame_get_border_size)(struct libdecor_plugin *plugin,
struct libdecor_frame *frame, struct libdecor_frame *frame,
struct libdecor_state *state, struct libdecor_configuration *configuration,
int *window_width, int *left,
int *window_height); int *right,
int *top,
bool (* configuration_get_content_size)(struct libdecor_plugin *plugin, int *bottom);
struct libdecor_configuration *configuration,
struct libdecor_frame *frame,
int *content_width,
int *content_height);
/* Reserved */ /* Reserved */
void (* reserved0)(void); void (* reserved0)(void);
@ -147,11 +137,6 @@ libdecor_frame_get_content_height(struct libdecor_frame *frame);
enum libdecor_window_state enum libdecor_window_state
libdecor_frame_get_window_state(struct libdecor_frame *frame); libdecor_frame_get_window_state(struct libdecor_frame *frame);
void
libdecor_frame_set_window_geometry(struct libdecor_frame *frame,
int32_t x, int32_t y,
int32_t width, int32_t height);
enum libdecor_capabilities enum libdecor_capabilities
libdecor_frame_get_capabilities(const struct libdecor_frame *frame); libdecor_frame_get_capabilities(const struct libdecor_frame *frame);
@ -183,11 +168,6 @@ libdecor_state_get_content_height (struct libdecor_state *state);
enum libdecor_window_state enum libdecor_window_state
libdecor_state_get_window_state(struct libdecor_state *state); libdecor_state_get_window_state(struct libdecor_state *state);
bool
libdecor_configuration_get_window_size(struct libdecor_configuration *configuration,
int *width,
int *height);
int int
libdecor_plugin_init(struct libdecor_plugin *plugin, libdecor_plugin_init(struct libdecor_plugin *plugin,
struct libdecor *context, struct libdecor *context,

View File

@ -245,36 +245,37 @@ frame_get_window_size_for(struct libdecor_frame *frame,
struct libdecor *context = frame_priv->context; struct libdecor *context = frame_priv->context;
struct libdecor_plugin *plugin = context->plugin; struct libdecor_plugin *plugin = context->plugin;
if (frame_has_visible_client_side_decoration(frame)) { *window_width = state->content_width;
return plugin->priv->iface->frame_get_window_size_for( *window_height = state->content_height;
plugin, frame, state,
window_width, window_height); if (frame_has_visible_client_side_decoration(frame) &&
} else { plugin->priv->iface->frame_get_border_size) {
*window_width = state->content_width; int left, right, top, bottom;
*window_height = state->content_height; if (!plugin->priv->iface->frame_get_border_size(
return true; plugin, frame, NULL, &left, &right, &top, &bottom))
return false;
*window_width += left + right;
*window_height += top + bottom;
} }
return true;
} }
static bool static void
window_size_to_content_size(struct libdecor_configuration *configuration, frame_set_window_geometry(struct libdecor_frame *frame,
struct libdecor_frame *frame, int32_t content_width, int32_t content_height)
int *content_width,
int *content_height)
{ {
struct libdecor_frame_private *frame_priv = frame->priv; struct libdecor_plugin *plugin = frame->priv->context->plugin;
struct libdecor *context = frame_priv->context; int x, y, width, height;
struct libdecor_plugin *plugin = context->plugin; int left, right, top, bottom;
if (frame_has_visible_client_side_decoration(frame)) { plugin->priv->iface->frame_get_border_size(plugin, frame, NULL,
return plugin->priv->iface->configuration_get_content_size( &left, &right, &top, &bottom);
plugin, configuration, frame, x = -left;
content_width, content_height); y = -top;
} else { width = content_width + left + right;
*content_width = configuration->window_width; height = content_height + top + bottom;
*content_height = configuration->window_height; xdg_surface_set_window_geometry(frame->priv->xdg_surface, x, y, width, height);
return true;
}
} }
LIBDECOR_EXPORT bool LIBDECOR_EXPORT bool
@ -283,36 +284,9 @@ libdecor_configuration_get_content_size(struct libdecor_configuration *configura
int *width, int *width,
int *height) int *height)
{ {
int content_width; struct libdecor_plugin *plugin = frame->priv->context->plugin;
int content_height;
if (!configuration->has_size) /* get configured toplevel dimensions */
return false;
if (configuration->window_width == 0 || configuration->window_height == 0)
return false;
if (!window_size_to_content_size(configuration,
frame,
&content_width,
&content_height))
return false;
*width = content_width;
*height = content_height;
if (state_is_floating(configuration->window_state)) {
constrain_content_size(frame, width, height);
}
return true;
}
LIBDECOR_EXPORT bool
libdecor_configuration_get_window_size(struct libdecor_configuration *configuration,
int *width,
int *height)
{
if (!configuration->has_size) if (!configuration->has_size)
return false; return false;
@ -321,6 +295,24 @@ libdecor_configuration_get_window_size(struct libdecor_configuration *configurat
*width = configuration->window_width; *width = configuration->window_width;
*height = configuration->window_height; *height = configuration->window_height;
/* remove plugin-specific border size */
if (frame_has_visible_client_side_decoration(frame) &&
plugin->priv->iface->frame_get_border_size) {
int left, right, top, bottom;
if (!plugin->priv->iface->frame_get_border_size(
plugin, frame, configuration, &left, &right, &top, &bottom))
return false;
*width -= (left + right);
*height -= (top + bottom);
}
/* constrain content dimensions manually */
if (state_is_floating(configuration->window_state)) {
constrain_content_size(frame, width, height);
}
return true; return true;
} }
@ -632,12 +624,12 @@ libdecor_frame_set_visibility(struct libdecor_frame *frame,
} else { } else {
/* destroy client-side decorations */ /* destroy client-side decorations */
plugin->priv->iface->frame_free(plugin, frame); plugin->priv->iface->frame_free(plugin, frame);
libdecor_frame_set_window_geometry(frame, 0, 0,
frame_priv->content_width,
frame_priv->content_height);
} }
frame_set_window_geometry(frame,
frame_priv->content_width,
frame_priv->content_height);
libdecor_frame_toplevel_commit(frame); libdecor_frame_toplevel_commit(frame);
} }
@ -677,7 +669,7 @@ libdecor_frame_set_title(struct libdecor_frame *frame,
return; return;
xdg_toplevel_set_title(frame_priv->xdg_toplevel, title); xdg_toplevel_set_title(frame_priv->xdg_toplevel, title);
plugin->priv->iface->frame_property_changed(plugin, frame); plugin->priv->iface->frame_property_changed(plugin, frame);
} }
} }
@ -833,9 +825,17 @@ libdecor_frame_translate_coordinate(struct libdecor_frame *frame,
struct libdecor *context = frame_priv->context; struct libdecor *context = frame_priv->context;
struct libdecor_plugin *plugin = context->plugin; struct libdecor_plugin *plugin = context->plugin;
plugin->priv->iface->frame_translate_coordinate(plugin, frame, *frame_x = content_x;
content_x, content_y, *frame_y = content_y;
frame_x, frame_y);
if (frame_has_visible_client_side_decoration(frame) &&
plugin->priv->iface->frame_get_border_size) {
int left, top;
plugin->priv->iface->frame_get_border_size(plugin, frame, NULL,
&left, NULL, &top, NULL);
*frame_x += left;
*frame_y += top;
}
} }
LIBDECOR_EXPORT void LIBDECOR_EXPORT void
@ -882,14 +882,6 @@ libdecor_frame_get_max_content_size(struct libdecor_frame *frame,
*pcontent_height = frame_priv->state.content_limits.max_height; *pcontent_height = frame_priv->state.content_limits.max_height;
} }
LIBDECOR_EXPORT void
libdecor_frame_set_window_geometry(struct libdecor_frame *frame,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
xdg_surface_set_window_geometry(frame->priv->xdg_surface, x, y, width, height);
}
LIBDECOR_EXPORT enum libdecor_capabilities LIBDECOR_EXPORT enum libdecor_capabilities
libdecor_frame_get_capabilities(const struct libdecor_frame *frame) libdecor_frame_get_capabilities(const struct libdecor_frame *frame)
{ {
@ -1122,12 +1114,12 @@ libdecor_frame_commit(struct libdecor_frame *frame,
configuration); configuration);
} else { } else {
plugin->priv->iface->frame_free(plugin, frame); plugin->priv->iface->frame_free(plugin, frame);
libdecor_frame_set_window_geometry(frame, 0, 0,
frame_priv->content_width,
frame_priv->content_height);
} }
frame_set_window_geometry(frame,
frame_priv->content_width,
frame_priv->content_height);
if (configuration) { if (configuration) {
xdg_surface_ack_configure(frame_priv->xdg_surface, xdg_surface_ack_configure(frame_priv->xdg_surface,
configuration->serial); configuration->serial);
@ -1260,6 +1252,12 @@ registry_handle_global(void *user_data,
if (!strcmp(interface, xdg_wm_base_interface.name)) { if (!strcmp(interface, xdg_wm_base_interface.name)) {
init_xdg_wm_base(context, id, version); init_xdg_wm_base(context, id, version);
} else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name)) { } else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name)) {
const char *force_csd = getenv("LIBDECOR_FORCE_CSD");
if (force_csd && atoi(force_csd)) {
return;
}
context->decoration_manager = wl_registry_bind( context->decoration_manager = wl_registry_bind(
context->wl_registry, id, context->wl_registry, id,
&zxdg_decoration_manager_v1_interface, &zxdg_decoration_manager_v1_interface,
@ -1488,25 +1486,26 @@ init_plugins(struct libdecor *context)
if (!dir) { if (!dir) {
fprintf(stderr, "Couldn't open plugin directory: %s\n", fprintf(stderr, "Couldn't open plugin directory: %s\n",
strerror(errno)); strerror(errno));
continue; } else {
while (true) {
struct dirent *de;
de = readdir(dir);
if (!de)
break;
plugin_loader = load_plugin_loader(context,
plugin_dir,
de->d_name);
if (!plugin_loader)
continue;
wl_list_insert(plugin_loaders.prev, &plugin_loader->link);
}
closedir(dir);
} }
while (true) {
struct dirent *de;
de = readdir(dir);
if (!de)
break;
plugin_loader = load_plugin_loader(context, plugin_dir, de->d_name);
if (!plugin_loader)
continue;
wl_list_insert(plugin_loaders.prev, &plugin_loader->link);
}
closedir(dir);
plugin_dir = strtok_r(NULL, ":", &saveptr); plugin_dir = strtok_r(NULL, ":", &saveptr);
} }
free(all_plugin_dirs); free(all_plugin_dirs);

View File

@ -1007,13 +1007,11 @@ ensure_border_surfaces(struct libdecor_frame_cairo *frame_cairo)
frame_cairo->shadow.opaque = false; frame_cairo->shadow.opaque = false;
ensure_component(frame_cairo, &frame_cairo->shadow); 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, libdecor_frame_get_min_content_size(&frame_cairo->frame,
&min_width, &min_height); &min_width, &min_height);
libdecor_frame_set_min_content_size(&frame_cairo->frame, libdecor_frame_set_min_content_size(&frame_cairo->frame,
MAX(min_width, (int)MAX(56, 4 * BUTTON_WIDTH)), MAX(min_width, (int)MAX(56, 4 * BUTTON_WIDTH)),
MAX(min_height, (int)MAX(56, TITLE_HEIGHT + 1))); MAX(min_height, (int)MAX(56, TITLE_HEIGHT + 1)));
#endif
} }
static void 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, small - 1, 0);
cairo_rel_line_to(cr, 0, small - 1); cairo_rel_line_to(cr, 0, small - 1);
cairo_line_to(cr, x + small - 1, y + 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_rectangle(cr, x, y, SYM_DIM - 1, SYM_DIM - 1);
} }
cairo_stroke(cr); 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 static enum decoration_type
window_state_to_decoration_type(enum libdecor_window_state window_state) 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; frame_cairo->window_state = new_window_state;
draw_decoration(frame_cairo); draw_decoration(frame_cairo);
set_window_geometry(frame_cairo);
} }
static void 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 static bool
streq(const char *str1, streq(const char *str1,
const char *str2) const char *str2)
@ -1876,63 +1828,38 @@ libdecor_plugin_cairo_frame_popup_ungrab(struct libdecor_plugin *plugin,
} }
static bool static bool
libdecor_plugin_cairo_configuration_get_content_size( libdecor_plugin_cairo_frame_get_border_size(struct libdecor_plugin *plugin,
struct libdecor_plugin *plugin, struct libdecor_frame *frame,
struct libdecor_configuration *configuration, struct libdecor_configuration *configuration,
struct libdecor_frame *frame, int *left,
int *content_width, int *right,
int *content_height) int *top,
int *bottom)
{ {
int win_width, win_height; enum libdecor_window_state window_state;
if (!libdecor_configuration_get_window_size(configuration,
&win_width,
&win_height))
return false;
enum libdecor_window_state state; if (configuration) {
if (!libdecor_configuration_get_window_state(configuration, &state)) { if (!libdecor_configuration_get_window_state(
return false; configuration, &window_state))
return false;
} else {
window_state = libdecor_frame_get_window_state(frame);
} }
switch (window_state_to_decoration_type(state)) { if (left)
case DECORATION_TYPE_NONE: *left = 0;
*content_width = win_width; if (right)
*content_height = win_height; *right = 0;
break; if (bottom)
case DECORATION_TYPE_ALL: *bottom = 0;
case DECORATION_TYPE_TILED: if (top) {
case DECORATION_TYPE_MAXIMIZED: enum decoration_type type = window_state_to_decoration_type(window_state);
*content_width = win_width;
*content_height = win_height - TITLE_HEIGHT;
break;
}
return true; if (((struct libdecor_frame_cairo *)frame)->title_bar.is_showing &&
} (type != DECORATION_TYPE_NONE))
*top = TITLE_HEIGHT;
static bool else
libdecor_plugin_cairo_frame_get_window_size_for( *top = 0;
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;
} }
return true; return true;
@ -1947,15 +1874,9 @@ static struct libdecor_plugin_interface cairo_plugin_iface = {
.frame_free = libdecor_plugin_cairo_frame_free, .frame_free = libdecor_plugin_cairo_frame_free,
.frame_commit = libdecor_plugin_cairo_frame_commit, .frame_commit = libdecor_plugin_cairo_frame_commit,
.frame_property_changed = libdecor_plugin_cairo_frame_property_changed, .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_grab = libdecor_plugin_cairo_frame_popup_grab,
.frame_popup_ungrab = libdecor_plugin_cairo_frame_popup_ungrab, .frame_popup_ungrab = libdecor_plugin_cairo_frame_popup_ungrab,
.frame_get_border_size = libdecor_plugin_cairo_frame_get_border_size,
.configuration_get_content_size =
libdecor_plugin_cairo_configuration_get_content_size,
.frame_get_window_size_for =
libdecor_plugin_cairo_frame_get_window_size_for,
}; };
static void static void

View File

@ -46,6 +46,7 @@ libdecor_plugin_dummy_destroy(struct libdecor_plugin *plugin)
struct libdecor_plugin_dummy *plugin_dummy = struct libdecor_plugin_dummy *plugin_dummy =
(struct libdecor_plugin_dummy *) plugin; (struct libdecor_plugin_dummy *) plugin;
libdecor_plugin_release(plugin);
free(plugin_dummy); 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 static void
libdecor_plugin_dummy_frame_popup_grab(struct libdecor_plugin *plugin, libdecor_plugin_dummy_frame_popup_grab(struct libdecor_plugin *plugin,
struct libdecor_frame *frame, 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 = { static struct libdecor_plugin_interface dummy_plugin_iface = {
.destroy = libdecor_plugin_dummy_destroy, .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_free = libdecor_plugin_dummy_frame_free,
.frame_commit = libdecor_plugin_dummy_frame_commit, .frame_commit = libdecor_plugin_dummy_frame_commit,
.frame_property_changed = libdecor_plugin_dummy_frame_property_changed, .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_grab = libdecor_plugin_dummy_frame_popup_grab,
.frame_popup_ungrab = libdecor_plugin_dummy_frame_popup_ungrab, .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 * static struct libdecor_plugin *
@ -155,7 +111,7 @@ libdecor_plugin_new(struct libdecor *context)
struct libdecor_plugin_dummy *plugin_dummy; struct libdecor_plugin_dummy *plugin_dummy;
plugin_dummy = zalloc(sizeof *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; plugin_dummy->context = context;
libdecor_notify_plugin_ready(context); libdecor_notify_plugin_ready(context);
@ -170,6 +126,7 @@ static struct libdecor_plugin_priority priorities[] = {
LIBDECOR_EXPORT const struct libdecor_plugin_description LIBDECOR_EXPORT const struct libdecor_plugin_description
libdecor_plugin_description = { libdecor_plugin_description = {
.api_version = LIBDECOR_PLUGIN_API_VERSION, .api_version = LIBDECOR_PLUGIN_API_VERSION,
.capabilities = LIBDECOR_PLUGIN_CAPABILITY_BASE,
.description = "dummy libdecor plugin", .description = "dummy libdecor plugin",
.priorities = priorities, .priorities = priorities,
.constructor = libdecor_plugin_new, .constructor = libdecor_plugin_new,

View File

@ -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 static enum decoration_type
window_state_to_decoration_type(enum libdecor_window_state window_state) 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; frame_gtk->decoration_type = new_decoration_type;
draw_decoration(frame_gtk); draw_decoration(frame_gtk);
set_window_geometry(frame_gtk);
/* set fixed window size */ /* set fixed window size */
if (!resizable(frame_gtk)) { 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 static void
update_component_focus(struct libdecor_frame_gtk *frame_gtk, update_component_focus(struct libdecor_frame_gtk *frame_gtk,
struct wl_surface *surface, struct wl_surface *surface,
@ -1807,78 +1755,38 @@ libdecor_plugin_gtk_frame_popup_ungrab(struct libdecor_plugin *plugin,
} }
static bool static bool
libdecor_plugin_gtk_configuration_get_content_size( libdecor_plugin_gtk_frame_get_border_size(struct libdecor_plugin *plugin,
struct libdecor_plugin *plugin, struct libdecor_frame *frame,
struct libdecor_configuration *configuration, struct libdecor_configuration *configuration,
struct libdecor_frame *frame, int *left,
int *content_width, int *right,
int *content_height) int *top,
int *bottom)
{ {
struct libdecor_frame_gtk *frame_gtk = enum libdecor_window_state window_state;
(struct libdecor_frame_gtk *) frame;
int win_width, win_height;
enum libdecor_window_state state;
if (!libdecor_configuration_get_window_size(configuration, if (configuration) {
&win_width, if (!libdecor_configuration_get_window_state(
&win_height)) configuration, &window_state))
return false; return false;
} else {
if (!libdecor_configuration_get_window_state(configuration, &state)) window_state = libdecor_frame_get_window_state(frame);
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
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;
} }
return true; 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);
static bool if (header && (type != DECORATION_TYPE_NONE))
libdecor_plugin_gtk_frame_get_window_size_for( *top = gtk_widget_get_allocated_height(header);
struct libdecor_plugin *plugin, else
struct libdecor_frame *frame, *top = 0;
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
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;
} }
return true; return true;
@ -1893,15 +1801,11 @@ static struct libdecor_plugin_interface gtk_plugin_iface = {
.frame_free = libdecor_plugin_gtk_frame_free, .frame_free = libdecor_plugin_gtk_frame_free,
.frame_commit = libdecor_plugin_gtk_frame_commit, .frame_commit = libdecor_plugin_gtk_frame_commit,
.frame_property_changed = libdecor_plugin_gtk_frame_property_changed, .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_grab = libdecor_plugin_gtk_frame_popup_grab,
.frame_popup_ungrab = libdecor_plugin_gtk_frame_popup_ungrab, .frame_popup_ungrab = libdecor_plugin_gtk_frame_popup_ungrab,
.configuration_get_content_size = .frame_get_border_size = libdecor_plugin_gtk_frame_get_border_size,
libdecor_plugin_gtk_configuration_get_content_size,
.frame_get_window_size_for =
libdecor_plugin_gtk_frame_get_window_size_for,
}; };
static void static void