diff --git a/.editorconfig b/.editorconfig index 5a6a39b8..3e3ab27e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,12 @@ indent_style = tab indent_size = 8 max_line_length = 80 -[*.{xml,build}] +[*.{xml,build,md}] indent_style = space indent_size = 2 +[*.md] +max_line_length = 80 + +[COMMIT_EDITMSG] +max_line_length = 74 diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index 3353fcfa..b7e7db68 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -178,8 +178,8 @@ Actions are used in menus and keyboard/mouse bindings. If *output* is specified, the window will be sent directly to the specified output and *direction* is ignored. If *output* is omitted, - *direction* may be one of "left", "right", "up" or "down" to indicate - that the window should be moved to the next output in that direction + *direction* may be one of "left", "right", "up" or "down" to indicate + that the window should be moved to the next output in that direction (if one exists). *wrap* [yes|no] When using the direction attribute, wrap around from @@ -238,7 +238,7 @@ Actions are used in menus and keyboard/mouse bindings. smaller than "eDP-1" output to cut off bottom panel from screen sharing. Virtual output is also useful for extending the desktop to (maybe - mobile) remote systems like tablets. E.g. simply adding a virtual + mobile) remote systems like tablets. E.g. simply adding a virtual output, attaching wayvnc to it and running a VNC client on the remote system. diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index b6071017..d86634a8 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -103,7 +103,7 @@ However, there are some caveats: 1. In menu.xml, the attributes *id*, *label* and *execute* must be expressed as attributes rather than as separate child elements. - 2. Ordering of attributes can sometimes be singificant. For example, + 2. Ordering of attributes can sometimes be significant. For example, when setting fonts via attributes rather than children, ** @@ -257,14 +257,15 @@ this is for compatibility with Openbox. - 'o' - output name (show if more than 1 monitor active) - 'T' - title of window - 't' - title of window (if different than wm-class/app-id) - Recommend using with a mono space font, to keep alignment. + Recommend using with a monospace font, to keep alignment. - *custom - subset of printf options allowed -- man 3 printf* - random text may be inserted - field length, example "%10" use 10 spaces, even if text uses less - - left jusify text, example "%-" + - left justify text, example "%-" - right justify text, example "%" instead of "%-" - - example, %-10 would left justify and make room for 10 charaters - - Only one custom format allowed now. Future enhancements may allow more than one. + - example, %-10 would left justify and make room for 10 characters + - Only one custom format allowed now. Future enhancements may + allow more than one. *width* defines the width of the field expressed as a percentage of the overall window switcher width. The "%" character is required. @@ -492,7 +493,7 @@ extending outward from the snapped edge. Default is no. ** - Keybind action. See labwc-action(5). + Keybind action. See labwc-actions(5). ** Load the default keybinds listed below. This is an addition to the @@ -658,7 +659,7 @@ extending outward from the snapped edge. ** Tablet buttons emulate regular mouse buttons. If not specified otherwise, the tip (Tip) is mapped to left mouse click, the first pen - button (Stylus) is mapped to right mouse button click and the second pen + button (Stylus) is mapped to right mouse button click and the second pen button (Stylus2) emulates a middle mouse button click. Supported map *buttons* are: @@ -890,6 +891,24 @@ situation. can be caused by ** settings or exclusive layer-shell clients such as panels. +## MENU + +``` + + 250 + +``` + +** + How long (in milliseconds) the initial button release event is ignored + for. The reason for this logic and behaviour is to avoid a fast + press-move-release sequence indended to just open the menu resulting in + the closure of the menu or the selection of (typically the first) menu + item. This behaviour only affects the first button-release. It is not + anticipated that most users will want to change this, but the config + option has been exposed for unusual use-cases. It is equivalent to + Openbox's ``. Default is 250 ms. + ## ENVIRONMENT VARIABLES *XCURSOR_THEME* and *XCURSOR_SIZE* are supported to set cursor theme diff --git a/docs/labwc-menu.5.scd b/docs/labwc-menu.5.scd index 507f33b3..b4688a07 100644 --- a/docs/labwc-menu.5.scd +++ b/docs/labwc-menu.5.scd @@ -57,7 +57,7 @@ The menu file must be entirely enclosed within and The visible name of the menu item. *menu.item.action* - See labwc-action(5). Note: XML CDATA is supported for this node in + See labwc-actions(5). Note: XML CDATA is supported for this node in order to maintain compatibility with obmenu-generator. *menu.separator* @@ -107,4 +107,4 @@ interpreted as a user-override. # SEE ALSO -labwc(1), labwc-action(5), labwc-config(5), labwc-theme(5) +labwc(1), labwc-actions(5), labwc-config(5), labwc-theme(5) diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index 3ebc82c8..51bdc5c3 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -131,18 +131,20 @@ openbox and is used by many popular themes. For the sake of brevity, these elements are not listed here, but are supported. *window.active.shadow.size* - Size of the drop-shadow for the focused window, in pixels. Default is 60. + Size of the drop-shadow for the focused window, in pixels. + Default is 60. *window.inactive.shadow.size* - Size of drop-shadows for non-focused windows, in pixels. Default is 40. + Size of drop-shadows for non-focused windows, in pixels. + Default is 40. *window.active.shadow.color* - Color of the drop-shadow for the focused window, including opacity. Default - is #00000060 (black with 38% opacity). + Color of the drop-shadow for the focused window, including opacity. + Default is #00000060 (black with 38% opacity). *window.inactive.shadow.color* - Color of drop-shadows for non-focused windows, including opacity. Default is - #00000040 (black with 25% opacity). + Color of drop-shadows for non-focused windows, including opacity. + Default is #00000040 (black with 25% opacity). *menu.items.bg.color* Background color of inactive menu items. @@ -173,15 +175,15 @@ elements are not listed here, but are supported. *window.active.title.bg.color* if not set. *osd.border.color* - Border color of on-screen-display. Inherits *osd.label.text.color* if not - set. + Border color of on-screen-display. Inherits *osd.label.text.color* if + not set. *osd.border.width* Border width of on-screen-display. Inherits *border.width* if not set. *osd.label.text.color* - Text color of on-screen-display. Inherits *window.active.label.text.color* if - not set. + Text color of on-screen-display. Inherits + *window.active.label.text.color* if not set. *osd.window-switcher.width* Width of window switcher in pixels. Default is 600. @@ -205,15 +207,15 @@ elements are not listed here, but are supported. Default is 2. *osd.window-switcher.preview.border.width* - Border width of the outlines shown as the preview of the window selected by - window switcher. Inherits *osd.border.width* if not set. + Border width of the outlines shown as the preview of the window selected + by window switcher. Inherits *osd.border.width* if not set. *osd.window-switcher.preview.border.color* Color(s) of the outlines shown as the preview of the window selected by window switcher. Possible value is a color or up to 3 colors separated by commas (e.g. "#ffffff,#000000,#ffffff"). When multiple colors are - specified, a multi-line rectangle with each line having the specified color - is drawn. If not set, this inherits the on-screen-display theme + specified, a multi-line rectangle with each line having the specified + color is drawn. If not set, this inherits the on-screen-display theme ("[*osd.bg.color*],[*osd.label.text.color*],[*osd.bg.color*]"). *osd.workspace-switcher.boxes.width* @@ -225,55 +227,55 @@ elements are not listed here, but are supported. boxes. Default is 20. *snapping.overlay.region.bg.enabled* [yes|no] - Show a filled rectangle as an overlay when a window is snapped to a region. - Default is yes for hardware-based renderers and no for software-based - renderers. + Show a filled rectangle as an overlay when a window is snapped to a + region. Default is yes for hardware-based renderers and no for + software-based renderers. *snapping.overlay.edge.bg.enabled* [yes|no] - Show a filled rectangle as an overlay when a window is snapped to an edge. - Default is yes for hardware-based renderer and no for software-based - renderers. + Show a filled rectangle as an overlay when a window is snapped to an + edge. Default is yes for hardware-based renderer and no for + software-based renderers. *snapping.overlay.region.border.enabled* [yes|no] Show an outlined rectangle as an overlay when a window is snapped to a - region. Default is no for hardware-based renderers and yes for software-based - renderers. + region. Default is no for hardware-based renderers and yes for + software-based renderers. *snapping.overlay.edge.border.enabled* [yes|no] - Show an outlined rectangle as an overlay when a window is snapped to an edge. - Default is no for hardware-based renderer and yes for software-based - renderers. + Show an outlined rectangle as an overlay when a window is snapped to an + edge. Default is no for hardware-based renderer and yes for + software-based renderers. *snapping.overlay.region.bg.color* - Color of a filled rectangle shown as an overlay when a window is snapped to - a region. Default is #8080b380. + Color of a filled rectangle shown as an overlay when a window is snapped + to a region. Default is #8080b380. *snapping.overlay.edge.bg.color* - Color of a filled rectangle shown as an overlay when a window is snapped to - an edge. Default is #8080b380. + Color of a filled rectangle shown as an overlay when a window is snapped + to an edge. Default is #8080b380. *snapping.overlay.region.border.width* - Border width of an outlined rectangle shown as an overlay when a window is - snapped to a region. Inherits `osd.border.width` if not set. + Border width of an outlined rectangle shown as an overlay when a window + is snapped to a region. Inherits `osd.border.width` if not set. *snapping.overlay.edge.border.width* - Border width of an outlined rectangle shown as the preview when a window is - snapped to an edge. Inherits `osd.border.width` if not set. + Border width of an outlined rectangle shown as the preview when a window + is snapped to an edge. Inherits `osd.border.width` if not set. *snapping.overlay.region.border.color* Color(s) of an outlined rectangle shown as an overlay when a window is - snapped to a region. Possible values and the default value are the same as - those of *osd.window-switcher.preview.border.color*. + snapped to a region. Possible values and the default value are the same + as those of *osd.window-switcher.preview.border.color*. *snapping.overlay.edge.border.color* Color(s) of an outlined rectangle shown as an overlay when a window is - snapped to an edge. Possible values and the default value are the same as - those of *osd.window-switcher.preview.border.color*. + snapped to an edge. Possible values and the default value are the same + as those of *osd.window-switcher.preview.border.color*. *border.color* - Set both *window.active.border.color* and *window.inactive.border.color*. - This is obsolete, but supported for backward compatibility as some themes - still contain it. + Set both *window.active.border.color* and + *window.inactive.border.color*. This is obsolete, but supported for + backward compatibility as some themes still contain it. # BUTTONS diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 2044ecd7..cc507dc8 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -586,4 +586,7 @@ --> + + 250 + diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 60081db0..210d92f2 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -137,6 +137,9 @@ struct rcxml { } window_switcher; struct wl_list window_rules; /* struct window_rule.link */ + + /* Menu */ + unsigned int menu_ignore_button_release_period; }; extern struct rcxml rc; diff --git a/include/view.h b/include/view.h index 182a28b8..b688f104 100644 --- a/include/view.h +++ b/include/view.h @@ -3,14 +3,15 @@ #define LABWC_VIEW_H #include "config.h" +#include "ssd.h" #include #include #include #include #include -#define LAB_MIN_VIEW_WIDTH 100 -#define LAB_MIN_VIEW_HEIGHT 60 +#define LAB_MIN_VIEW_WIDTH (SSD_BUTTON_WIDTH * SSD_BUTTON_COUNT) +#define LAB_MIN_VIEW_HEIGHT 60 /* * In labwc, a view is a container for surfaces which can be moved around by diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 0d844119..1e268f47 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1034,6 +1034,8 @@ entry(xmlNode *node, char *nodename, char *content) } else { wlr_log(WLR_ERROR, "Missing 'button' argument for tablet button mapping"); } + } else if (!strcasecmp(nodename, "ignoreButtonReleasePeriod.menu")) { + rc.menu_ignore_button_release_period = atoi(content); } } @@ -1238,6 +1240,8 @@ rcxml_init(void) rc.workspace_config.popuptime = INT_MIN; rc.workspace_config.min_nr_workspaces = 1; + + rc.menu_ignore_button_release_period = 250; } static void diff --git a/src/input/cursor.c b/src/input/cursor.c index df03dcf2..6e0e81aa 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -929,6 +929,8 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx, return consumed_by_frame_context; } +static uint32_t press_msec; + static void cursor_button_press(struct seat *seat, uint32_t button, enum wlr_button_state button_state, uint32_t time_msec) @@ -936,6 +938,9 @@ cursor_button_press(struct seat *seat, uint32_t button, struct server *server = seat->server; struct cursor_context ctx = get_cursor_context(server); + /* Used on next button release to check if it can close menu or select menu item */ + press_msec = time_msec; + /* Determine closest resize edges in case action is Resize */ uint32_t resize_edges = cursor_get_resize_edges(seat->cursor, &ctx); @@ -946,6 +951,11 @@ cursor_button_press(struct seat *seat, uint32_t button, } if (server->input_mode == LAB_INPUT_STATE_MENU) { + /* + * If menu was already opened on press, set a very small value + * so subsequent release always closes menu or selects menu item. + */ + press_msec = 0; return; } @@ -1011,12 +1021,15 @@ cursor_button_release(struct seat *seat, uint32_t button, seat_reset_pressed(seat); if (server->input_mode == LAB_INPUT_STATE_MENU) { - if (ctx.type == LAB_SSD_MENU) { - menu_call_selected_actions(server); - } else { - menu_close_root(server); - cursor_update_common(server, &ctx, time_msec, - /*cursor_has_moved*/ false); + /* TODO: take into account overflow of time_msec */ + if (time_msec - press_msec > rc.menu_ignore_button_release_period) { + if (ctx.type == LAB_SSD_MENU) { + menu_call_selected_actions(server); + } else { + menu_close_root(server); + cursor_update_common(server, &ctx, time_msec, + /*cursor_has_moved*/ false); + } } return; } diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index 518602a6..9c96ef7b 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -229,6 +229,16 @@ ssd_update_geometry(struct ssd *ssd) int eff_width = current.width; int eff_height = view_effective_height(ssd->view, /* use_pending */ false); + if (eff_width > 0 && eff_width < LAB_MIN_VIEW_WIDTH) { + /* + * Prevent negative values in calculations like + * `width - SSD_BUTTON_WIDTH * SSD_BUTTON_COUNT` + */ + wlr_log(WLR_ERROR, + "view width is smaller than its minimal value"); + return; + } + if (eff_width == cached.width && eff_height == cached.height) { if (current.x != cached.x || current.y != cached.y) { /* Dynamically resize extents based on position and usable_area */ diff --git a/src/view-impl-common.c b/src/view-impl-common.c index 0b7bc9a1..2440ba36 100644 --- a/src/view-impl-common.c +++ b/src/view-impl-common.c @@ -46,6 +46,12 @@ view_impl_map(struct view *view) } } + /* + * Some clients (e.g. Steam's Big Picture Mode window) request + * fullscreen before mapping. + */ + desktop_update_top_layer_visiblity(view->server); + wlr_log(WLR_DEBUG, "[map] identifier=%s, title=%s\n", view_get_string_prop(view, "app_id"), view_get_string_prop(view, "title"));