mirror of
https://github.com/labwc/labwc.git
synced 2025-10-31 22:25:34 -04:00
decorations: add SetDecorations action
This commit is contained in:
parent
e2590f10fd
commit
41a3b68846
6 changed files with 62 additions and 0 deletions
|
|
@ -120,6 +120,17 @@ Actions are used in menus and keyboard/mouse bindings.
|
||||||
upper-left corner of the window associated with the action. Default is
|
upper-left corner of the window associated with the action. Default is
|
||||||
yes.
|
yes.
|
||||||
|
|
||||||
|
*<action name="SetDecorations" decorations="value" forceSSD="no" />*
|
||||||
|
Set decorations of focused window.
|
||||||
|
|
||||||
|
*decorations* [full|border|none] *full* enables the whole server side
|
||||||
|
decorations. With *border*. only the borders and invisible resize area
|
||||||
|
are enabled. *none* disables everything.
|
||||||
|
|
||||||
|
*forceSSD* [yes|no] If this is no, this action will be ignored for
|
||||||
|
windows that have client side decorations if it would increase the
|
||||||
|
amount of decoration. Default is no.
|
||||||
|
|
||||||
*<action name="ToggleDecorations" />*
|
*<action name="ToggleDecorations" />*
|
||||||
Toggle decorations of focused window.
|
Toggle decorations of focused window.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ enum ssd_part_type ssd_get_part_type(const struct ssd *ssd,
|
||||||
uint32_t ssd_resize_edges(enum ssd_part_type type);
|
uint32_t ssd_resize_edges(enum ssd_part_type type);
|
||||||
bool ssd_is_button(enum ssd_part_type type);
|
bool ssd_is_button(enum ssd_part_type type);
|
||||||
bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate);
|
bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate);
|
||||||
|
enum ssd_mode ssd_mode_parse(const char *mode);
|
||||||
|
|
||||||
/* TODO: clean up / update */
|
/* TODO: clean up / update */
|
||||||
struct border ssd_thickness(struct view *view);
|
struct border ssd_thickness(struct view *view);
|
||||||
|
|
|
||||||
|
|
@ -486,6 +486,7 @@ bool view_is_floating(struct view *view);
|
||||||
void view_move_to_workspace(struct view *view, struct workspace *workspace);
|
void view_move_to_workspace(struct view *view, struct workspace *workspace);
|
||||||
enum ssd_mode view_get_ssd_mode(struct view *view);
|
enum ssd_mode view_get_ssd_mode(struct view *view);
|
||||||
void view_set_ssd_mode(struct view *view, enum ssd_mode mode);
|
void view_set_ssd_mode(struct view *view, enum ssd_mode mode);
|
||||||
|
void view_set_decorations(struct view *view, enum ssd_mode mode, bool force_ssd);
|
||||||
void view_toggle_fullscreen(struct view *view);
|
void view_toggle_fullscreen(struct view *view);
|
||||||
void view_invalidate_last_layout_geometry(struct view *view);
|
void view_invalidate_last_layout_geometry(struct view *view);
|
||||||
void view_adjust_for_layout_change(struct view *view);
|
void view_adjust_for_layout_change(struct view *view);
|
||||||
|
|
|
||||||
22
src/action.c
22
src/action.c
|
|
@ -79,6 +79,7 @@ enum action_type {
|
||||||
ACTION_TYPE_TOGGLE_MAXIMIZE,
|
ACTION_TYPE_TOGGLE_MAXIMIZE,
|
||||||
ACTION_TYPE_MAXIMIZE,
|
ACTION_TYPE_MAXIMIZE,
|
||||||
ACTION_TYPE_TOGGLE_FULLSCREEN,
|
ACTION_TYPE_TOGGLE_FULLSCREEN,
|
||||||
|
ACTION_TYPE_SET_DECORATIONS,
|
||||||
ACTION_TYPE_TOGGLE_DECORATIONS,
|
ACTION_TYPE_TOGGLE_DECORATIONS,
|
||||||
ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP,
|
ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP,
|
||||||
ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM,
|
ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM,
|
||||||
|
|
@ -135,6 +136,7 @@ const char *action_names[] = {
|
||||||
"ToggleMaximize",
|
"ToggleMaximize",
|
||||||
"Maximize",
|
"Maximize",
|
||||||
"ToggleFullscreen",
|
"ToggleFullscreen",
|
||||||
|
"SetDecorations",
|
||||||
"ToggleDecorations",
|
"ToggleDecorations",
|
||||||
"ToggleAlwaysOnTop",
|
"ToggleAlwaysOnTop",
|
||||||
"ToggleAlwaysOnBottom",
|
"ToggleAlwaysOnBottom",
|
||||||
|
|
@ -347,6 +349,17 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACTION_TYPE_SET_DECORATIONS:
|
||||||
|
if (!strcmp(argument, "decorations")) {
|
||||||
|
enum ssd_mode mode = ssd_mode_parse(content);
|
||||||
|
action_arg_add_int(action, argument, mode);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (!strcasecmp(argument, "forceSSD")) {
|
||||||
|
action_arg_add_bool(action, argument, parse_bool(content, false));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ACTION_TYPE_RESIZE_RELATIVE:
|
case ACTION_TYPE_RESIZE_RELATIVE:
|
||||||
if (!strcmp(argument, "left") || !strcmp(argument, "right") ||
|
if (!strcmp(argument, "left") || !strcmp(argument, "right") ||
|
||||||
!strcmp(argument, "top") || !strcmp(argument, "bottom")) {
|
!strcmp(argument, "top") || !strcmp(argument, "bottom")) {
|
||||||
|
|
@ -806,6 +819,15 @@ actions_run(struct view *activator, struct server *server,
|
||||||
view_toggle_fullscreen(view);
|
view_toggle_fullscreen(view);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACTION_TYPE_SET_DECORATIONS:
|
||||||
|
if (view) {
|
||||||
|
enum ssd_mode mode = action_get_int(action,
|
||||||
|
"decorations", LAB_SSD_MODE_FULL);
|
||||||
|
bool force_ssd = action_get_bool(action,
|
||||||
|
"forceSSD", false);
|
||||||
|
view_set_decorations(view, mode, force_ssd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ACTION_TYPE_TOGGLE_DECORATIONS:
|
case ACTION_TYPE_TOGGLE_DECORATIONS:
|
||||||
if (view) {
|
if (view) {
|
||||||
view_toggle_decorations(view);
|
view_toggle_decorations(view);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <strings.h>
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "common/scene-helpers.h"
|
#include "common/scene-helpers.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
|
@ -344,6 +345,21 @@ ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ssd_mode
|
||||||
|
ssd_mode_parse(const char *mode)
|
||||||
|
{
|
||||||
|
if (!mode) {
|
||||||
|
return LAB_SSD_MODE_FULL;
|
||||||
|
}
|
||||||
|
if (!strcasecmp(mode, "none")) {
|
||||||
|
return LAB_SSD_MODE_NONE;
|
||||||
|
} else if (!strcasecmp(mode, "border")) {
|
||||||
|
return LAB_SSD_MODE_BORDER;
|
||||||
|
} else {
|
||||||
|
return LAB_SSD_MODE_FULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ssd_set_active(struct ssd *ssd, bool active)
|
ssd_set_active(struct ssd *ssd, bool active)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
11
src/view.c
11
src/view.c
|
|
@ -1249,6 +1249,17 @@ view_wants_decorations(struct view *view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
view_set_decorations(struct view *view, enum ssd_mode mode, bool force_ssd)
|
||||||
|
{
|
||||||
|
assert(view);
|
||||||
|
|
||||||
|
if (force_ssd || !view_wants_decorations(view)
|
||||||
|
|| mode < view_get_ssd_mode(view)) {
|
||||||
|
view_set_ssd_mode(view, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view_toggle_decorations(struct view *view)
|
view_toggle_decorations(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue