Merge branch 'magnifier' of github.com:raspberrypi-ui/labwc into magnifier

This commit is contained in:
Simon Long 2024-05-03 12:26:50 +01:00
commit ed3d9ff6c6
5 changed files with 50 additions and 7 deletions

View file

@ -892,6 +892,24 @@ situation.
can be caused by *<margin>* settings or exclusive layer-shell clients
such as panels.
## MENU
```
<menu>
<ignoreButtonReleasePeriod>250</ignoreButtonReleasePeriod>
</menu>
```
*<menu><ignoreButtonReleasePeriod>*
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 `<hideDelay>`. Default is 250 ms.
## ENVIRONMENT VARIABLES
*XCURSOR_THEME* and *XCURSOR_SIZE* are supported to set cursor theme

View file

@ -586,6 +586,10 @@
</windowRules>
-->
<menu>
<ignoreButtonReleasePeriod>250</ignoreButtonReleasePeriod>
</menu>
<!--
Magnifier settings

View file

@ -144,13 +144,17 @@ struct rcxml {
struct wl_list window_rules; /* struct window_rule.link */
/* magnifier */
/* Menu */
unsigned int menu_ignore_button_release_period;
/* magnifier */
int mag_scale;
int mag_width;
int mag_height;
struct rgb_colour mag_border_col;
int mag_border_width;
bool mag_filter;
};
extern struct rcxml rc;

View file

@ -1047,6 +1047,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);
} else if (!strcasecmp(nodename, "width.magnifier")) {
rc.mag_width = atoi(content);
} else if (!strcasecmp(nodename, "height.magnifier")) {
@ -1265,6 +1267,8 @@ rcxml_init(void)
rc.workspace_config.popuptime = INT_MIN;
rc.workspace_config.min_nr_workspaces = 1;
rc.menu_ignore_button_release_period = 250;
rc.mag_scale = 2;
rc.mag_width = 400;
rc.mag_height = 400;

View file

@ -935,6 +935,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)
@ -942,6 +944,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);
@ -952,6 +957,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;
}
@ -1017,12 +1027,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;
}