mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
cursor: rate-limit resize events respecting monitor's refresh rate
This fixes the lag when resizing windows of some apps on XWayland (e.g. Chromium and Steam).
This commit is contained in:
parent
2388f37cc7
commit
4073a6b923
1 changed files with 22 additions and 0 deletions
|
|
@ -248,6 +248,28 @@ process_cursor_move(struct server *server, uint32_t time)
|
|||
static void
|
||||
process_cursor_resize(struct server *server, uint32_t time)
|
||||
{
|
||||
/* Rate-limit resize events respecting monitor refresh rate */
|
||||
static uint32_t last_resize_time = 0;
|
||||
static struct view *last_resize_view = NULL;
|
||||
|
||||
if (server->grabbed_view == last_resize_view) {
|
||||
int32_t refresh = 0;
|
||||
if (output_is_usable(last_resize_view->output)) {
|
||||
refresh = last_resize_view->output->wlr_output->refresh;
|
||||
}
|
||||
/* Limit to 250Hz if refresh rate is not available */
|
||||
if (refresh <= 0) {
|
||||
refresh = 250000;
|
||||
}
|
||||
/* Not caring overflow, but it won't be observable */
|
||||
if (time - last_resize_time < 1000000 / (uint32_t)refresh) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
last_resize_time = time;
|
||||
last_resize_view = server->grabbed_view;
|
||||
|
||||
double dx = server->seat.cursor->x - server->grab_x;
|
||||
double dy = server->seat.cursor->y - server->grab_y;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue