shell: run surface bindings only when focus surface is not NULL
This fixes the crash when move, rotate or resize binding is activated
while exposay effect is active.
Steps to reproduce:
- activate exposay
- try to rotate the surface with mod + right mouse button
- crash
Closes: https://bugs.freedesktop.org/show_bug.cgi?id=72885
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 4cc23d5..00c7b01 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -3747,10 +3747,15 @@
static void
move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data)
{
- struct weston_surface *focus = seat->pointer->focus->surface;
+ struct weston_surface *focus;
struct weston_surface *surface;
struct shell_surface *shsurf;
+ if (seat->pointer->focus == NULL)
+ return;
+
+ focus = seat->pointer->focus->surface;
+
surface = weston_surface_get_main_surface(focus);
if (surface == NULL)
return;
@@ -3833,12 +3838,17 @@
static void
resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data)
{
- struct weston_surface *focus = seat->pointer->focus->surface;
+ struct weston_surface *focus;
struct weston_surface *surface;
uint32_t edges = 0;
int32_t x, y;
struct shell_surface *shsurf;
+ if (seat->pointer->focus == NULL)
+ return;
+
+ focus = seat->pointer->focus->surface;
+
surface = weston_surface_get_main_surface(focus);
if (surface == NULL)
return;
@@ -4107,10 +4117,15 @@
rotate_binding(struct weston_seat *seat, uint32_t time, uint32_t button,
void *data)
{
- struct weston_surface *focus = seat->pointer->focus->surface;
+ struct weston_surface *focus;
struct weston_surface *base_surface;
struct shell_surface *surface;
+ if (seat->pointer->focus == NULL)
+ return;
+
+ focus = seat->pointer->focus->surface;
+
base_surface = weston_surface_get_main_surface(focus);
if (base_surface == NULL)
return;