summaryrefslogtreecommitdiff
blob: 0999ebd582a0abba7e8161c68e62b2eb048f14ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
From 351f444f9d16a90636feb217b15f0f376bf96d85 Mon Sep 17 00:00:00 2001
From: "Jasper St. Pierre" <jstpierre@mecheye.net>
Date: Tue, 23 Jun 2015 16:23:45 -0700
Subject: surface-actor-x11: Make sure to set a size when unredirected

When we're unredirected, we don't have a pixmap, and thus our allocation
becomes 0x0. So when events come in, they pass right through our actor,
going to the one underneath in the stack.

Fix this by having a fallback size on the shaped texture actor when
we're unredirected, causing it to always have a valid allocation.

This fixes clicking on stuff in sloppy / mouse mode focus.

diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index 4ee8027..21c6335 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -32,6 +32,9 @@
 ClutterActor *meta_shaped_texture_new (void);
 void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
                                       CoglTexture       *texture);
+void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
+                                            guint              fallback_width,
+                                            guint              fallback_height);
 gboolean meta_shaped_texture_is_obscured (MetaShapedTexture *self);
 
 #endif
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 163c5e6..8701d1b 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -86,6 +86,7 @@ struct _MetaShapedTexturePrivate
   cairo_region_t *unobscured_region;
 
   guint tex_width, tex_height;
+  guint fallback_width, fallback_height;
 
   guint create_mipmaps : 1;
 };
@@ -136,7 +137,20 @@ set_unobscured_region (MetaShapedTexture *self,
   g_clear_pointer (&priv->unobscured_region, (GDestroyNotify) cairo_region_destroy);
   if (unobscured_region)
     {
-      cairo_rectangle_int_t bounds = { 0, 0, priv->tex_width, priv->tex_height };
+      guint width, height;
+
+      if (priv->texture)
+        {
+          width = priv->tex_width;
+          height = priv->tex_height;
+        }
+      else
+        {
+          width = priv->fallback_width;
+          height = priv->fallback_height;
+        }
+
+      cairo_rectangle_int_t bounds = { 0, 0, width, height };
       priv->unobscured_region = cairo_region_copy (unobscured_region);
       cairo_region_intersect_rectangle (priv->unobscured_region, &bounds);
     }
@@ -499,16 +513,21 @@ meta_shaped_texture_get_preferred_width (ClutterActor *self,
                                          gfloat       *natural_width_p)
 {
   MetaShapedTexturePrivate *priv;
+  guint width;
 
   g_return_if_fail (META_IS_SHAPED_TEXTURE (self));
 
   priv = META_SHAPED_TEXTURE (self)->priv;
 
-  if (min_width_p)
-    *min_width_p = priv->tex_width;
+  if (priv->texture)
+    width = priv->tex_width;
+  else
+    width = priv->fallback_width;
 
+  if (min_width_p)
+    *min_width_p = width;
   if (natural_width_p)
-    *natural_width_p = priv->tex_width;
+    *natural_width_p = width;
 }
 
 static void
@@ -518,16 +537,21 @@ meta_shaped_texture_get_preferred_height (ClutterActor *self,
                                           gfloat       *natural_height_p)
 {
   MetaShapedTexturePrivate *priv;
+  guint height;
 
   g_return_if_fail (META_IS_SHAPED_TEXTURE (self));
 
   priv = META_SHAPED_TEXTURE (self)->priv;
 
-  if (min_height_p)
-    *min_height_p = priv->tex_height;
+  if (priv->texture)
+    height = priv->tex_height;
+  else
+    height = priv->fallback_height;
 
+  if (min_height_p)
+    *min_height_p = height;
   if (natural_height_p)
-    *natural_height_p = priv->tex_height;
+    *natural_height_p = height;
 }
 
 static cairo_region_t *
@@ -860,6 +884,17 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
   return surface;
 }
 
+void
+meta_shaped_texture_set_fallback_size (MetaShapedTexture *self,
+                                       guint              fallback_width,
+                                       guint              fallback_height)
+{
+  MetaShapedTexturePrivate *priv = self->priv;
+
+  priv->fallback_width = fallback_width;
+  priv->fallback_height = fallback_height;
+}
+
 static void
 meta_shaped_texture_cull_out (MetaCullable   *cullable,
                               cairo_region_t *unobscured_region,
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
index 4aa7ecd..b50b8f2 100644
--- a/src/compositor/meta-surface-actor-x11.c
+++ b/src/compositor/meta-surface-actor-x11.c
@@ -416,6 +416,7 @@ meta_surface_actor_x11_set_size (MetaSurfaceActorX11 *self,
                                  int width, int height)
 {
   MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self);
+  MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self));
 
   if (priv->last_width == width &&
       priv->last_height == height)
@@ -424,4 +425,5 @@ meta_surface_actor_x11_set_size (MetaSurfaceActorX11 *self,
   priv->size_changed = TRUE;
   priv->last_width = width;
   priv->last_height = height;
+  meta_shaped_texture_set_fallback_size (stex, width, height);
 }
-- 
cgit v0.10.2