mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
view: avoid raising same view over and over
Since view_move_to_front() now does more work than it used to (updating XWayland server stacking order), try to avoid doing that work unnecessarily.
This commit is contained in:
parent
0ddf3c43ad
commit
db591d1400
3 changed files with 31 additions and 4 deletions
19
src/view.c
19
src/view.c
|
|
@ -1345,6 +1345,7 @@ move_to_front(struct view *view)
|
|||
if (view->impl->move_to_front) {
|
||||
view->impl->move_to_front(view);
|
||||
}
|
||||
view->server->last_raised_view = view;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1353,6 +1354,9 @@ move_to_back(struct view *view)
|
|||
if (view->impl->move_to_back) {
|
||||
view->impl->move_to_back(view);
|
||||
}
|
||||
if (view == view->server->last_raised_view) {
|
||||
view->server->last_raised_view = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1365,6 +1369,17 @@ void
|
|||
view_move_to_front(struct view *view)
|
||||
{
|
||||
assert(view);
|
||||
/*
|
||||
* This function is called often, generally on every mouse
|
||||
* button press (more often for focus-follows-mouse). Avoid
|
||||
* unnecessarily raising the same view over and over, or
|
||||
* attempting to raise a root view above its own sub-view.
|
||||
*/
|
||||
struct view *last = view->server->last_raised_view;
|
||||
if (view == last || (last && view == view_get_root(last))) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct view *root = view_get_root(view);
|
||||
assert(root);
|
||||
|
||||
|
|
@ -1517,6 +1532,10 @@ view_destroy(struct view *view)
|
|||
need_cursor_update = true;
|
||||
}
|
||||
|
||||
if (server->last_raised_view == view) {
|
||||
server->last_raised_view = NULL;
|
||||
}
|
||||
|
||||
if (server->seat.pressed.view == view) {
|
||||
seat_reset_pressed(&server->seat);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue