mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
src/view.c: Prevent crash by killing a moving application
When a view is destroyed labwc calls interactive_end(view) which may reposition the view which is partly destroyed and doesn't own any surface anymore. To prevent this scenario from happening don't call interactive_end() at all and just reset server->grabbed_view and server->input_mode directly. Before this patch, the bug could be reproduced by: - xcalc & - sleep 5; killall xcalc - move the xcalc window completely to one of the edges The change in src/xwayland.c is not required for this bug to be fixed but may prevent something similar in the future.
This commit is contained in:
parent
1f0055a7e0
commit
f1ba0a89fc
2 changed files with 21 additions and 6 deletions
23
src/view.c
23
src/view.c
|
|
@ -759,25 +759,36 @@ view_update_app_id(struct view *view)
|
||||||
void
|
void
|
||||||
view_destroy(struct view *view)
|
view_destroy(struct view *view)
|
||||||
{
|
{
|
||||||
|
struct server *server = view->server;
|
||||||
|
|
||||||
if (view->toplevel_handle) {
|
if (view->toplevel_handle) {
|
||||||
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel_handle);
|
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel_handle);
|
||||||
}
|
}
|
||||||
interactive_end(view);
|
|
||||||
|
|
||||||
struct server *server = view->server;
|
if (server->grabbed_view == view) {
|
||||||
|
/* Application got killed while moving around */
|
||||||
|
server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
||||||
|
server->grabbed_view = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (server->seat.pressed.view == view) {
|
if (server->seat.pressed.view == view) {
|
||||||
|
/* Mouse was pressed on surface and is still pressed */
|
||||||
server->seat.pressed.view = NULL;
|
server->seat.pressed.view = NULL;
|
||||||
server->seat.pressed.surface = NULL;
|
server->seat.pressed.surface = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server->cycle_view == view) {
|
if (server->cycle_view == view) {
|
||||||
/* If we are the current OSD selected view, cycle
|
/*
|
||||||
* to the next because we are dying. */
|
* If we are the current OSD selected view, cycle
|
||||||
|
* to the next because we are dying.
|
||||||
|
*/
|
||||||
server->cycle_view = desktop_cycle_view(server,
|
server->cycle_view = desktop_cycle_view(server,
|
||||||
server->cycle_view, LAB_CYCLE_DIR_BACKWARD);
|
server->cycle_view, LAB_CYCLE_DIR_BACKWARD);
|
||||||
|
|
||||||
/* If we cycled back to ourselves, then we have no windows.
|
/*
|
||||||
* just remove it and close the OSD for good. */
|
* If we cycled back to ourselves, then we have no windows.
|
||||||
|
* just remove it and close the OSD for good.
|
||||||
|
*/
|
||||||
if (server->cycle_view == view || !server->cycle_view) {
|
if (server->cycle_view == view || !server->cycle_view) {
|
||||||
server->cycle_view = NULL;
|
server->cycle_view = NULL;
|
||||||
osd_finish(server);
|
osd_finish(server);
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,10 @@ handle_set_class(struct wl_listener *listener, void *data)
|
||||||
static void
|
static void
|
||||||
configure(struct view *view, struct wlr_box geo)
|
configure(struct view *view, struct wlr_box geo)
|
||||||
{
|
{
|
||||||
|
if (!view->xwayland_surface) {
|
||||||
|
wlr_log(WLR_ERROR, "Not configuring view without xwayland_surface");
|
||||||
|
return;
|
||||||
|
}
|
||||||
view->pending_move_resize.update_x = geo.x != view->x;
|
view->pending_move_resize.update_x = geo.x != view->x;
|
||||||
view->pending_move_resize.update_y = geo.y != view->y;
|
view->pending_move_resize.update_y = geo.y != view->y;
|
||||||
view->pending_move_resize.x = geo.x;
|
view->pending_move_resize.x = geo.x;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue