~xnox/metacity/ubuntu

« back to all changes in this revision

Viewing changes to debian/patches/06_Add_UXD_shadows_and_borders.patch

  • Committer: Dimitri John Ledkov
  • Date: 2014-07-09 13:01:45 UTC
  • Revision ID: dimitri.ledkov@canonical.com-20140709130145-tn3p21qunh43mg9l
* debian/patches/01_focus_new_window.patch
  debian/patches/03_gtop_error.patch
  debian/patches/04_support_drag_drop_with_alt_tab.patch
  debian/patches/06_Add_UXD_shadows_and_borders.patch
  debian/patches/100_fade_on_long_title.patch
  debian/patches/10_no-ws-switcher.patch
  debian/patches/13_better_support_for_button_layout.patch
  debian/patches/14_wrong_colormap.patch
  debian/patches/21_fix_compositing_startup.patch
  debian/patches/git_support_new_schemas.patch:
  - Remove, applied upstream
* debian/patches/12_dont-show-as-user.patch:
  - Refresh

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From a5442fe19432509eda44901093b45e97f72e04c0 Mon Sep 17 00:00:00 2001
2
 
From: Sam Spilsbury <smspillaz@gmail.com>
3
 
Date: Thu, 13 Jan 2011 11:59:40 +0800
4
 
Subject: [PATCH] Add UXD shadows and borders
5
 
 
6
 
---
7
 
 src/ui/theme-parser.c                  |  520 ++++++++++++++++++++------------
8
 
 src/ui/theme.c                         |   63 ++++
9
 
 src/ui/theme.h                         |  112 ++++++--
10
 
 3 files changed, 482 insertions(+), 215 deletions(-)
11
 
 
12
 
Index: metacity-2.34.1/src/ui/theme-parser.c
13
 
===================================================================
14
 
--- metacity-2.34.1.orig/src/ui/theme-parser.c  2011-04-23 12:10:04.000000000 -0400
15
 
+++ metacity-2.34.1/src/ui/theme-parser.c       2011-08-18 00:02:30.689002059 -0400
16
 
@@ -67,6 +67,8 @@
17
 
   STATE_FRAME_STYLE,
18
 
   STATE_PIECE,
19
 
   STATE_BUTTON,
20
 
+  STATE_SHADOW,
21
 
+  STATE_PADDING,
22
 
   /* style set */
23
 
   STATE_FRAME_STYLE_SET,
24
 
   STATE_FRAME,
25
 
@@ -173,6 +175,20 @@
26
 
                                      ParseInfo            *info,
27
 
                                      GError              **error);
28
 
 
29
 
+static void parse_shadow_element    (GMarkupParseContext  *context,
30
 
+                                     const gchar          *element_name,
31
 
+                                     const gchar         **attribute_names,
32
 
+                                     const gchar         **attribute_values,
33
 
+                                     ParseInfo            *info,
34
 
+                                     GError              **error);
35
 
+
36
 
+static void parse_padding_element    (GMarkupParseContext  *context,
37
 
+                                      const gchar          *element_name,
38
 
+                                      const gchar         **attribute_names,
39
 
+                                      const gchar         **attribute_values,
40
 
+                                      ParseInfo            *info,
41
 
+                                      GError              **error);
42
 
+
43
 
 static void parse_menu_icon_element (GMarkupParseContext  *context,
44
 
                                      const gchar          *element_name,
45
 
                                      const gchar         **attribute_names,
46
 
@@ -2935,9 +2951,76 @@
47
 
           meta_draw_op_list_ref (op_list);
48
 
           info->op_list = op_list;
49
 
         }
50
 
-      
51
 
+
52
 
       push_state (info, STATE_BUTTON);
53
 
     }
54
 
+  else if (ELEMENT_IS ("shadow"))
55
 
+    {
56
 
+      const char *shadow_radius = NULL;
57
 
+      const char *shadow_opacity = NULL;
58
 
+      const char *shadow_color = NULL;
59
 
+      const char *shadow_x_offset = NULL;
60
 
+      const char *shadow_y_offset = NULL;
61
 
+      double shadow_radius_v, shadow_opacity_v;
62
 
+      int    shadow_x_offset_v, shadow_y_offset_v;
63
 
+      MetaColorSpec *shadow_color_v;
64
 
+
65
 
+      if (!locate_attributes (context, element_name, attribute_names, attribute_values,
66
 
+                              error,
67
 
+                              "radius", &shadow_radius,
68
 
+                              "opacity", &shadow_opacity,
69
 
+                              "color", &shadow_color,
70
 
+                              "x_offset", &shadow_x_offset,
71
 
+                              "y_offset", &shadow_y_offset,
72
 
+                              NULL))
73
 
+        return;
74
 
+
75
 
+      parse_double (shadow_radius, &shadow_radius_v, context, error);
76
 
+      parse_double (shadow_opacity, &shadow_opacity_v, context, error);
77
 
+      parse_positive_integer (shadow_x_offset, &shadow_x_offset_v, context, info->theme, error);
78
 
+      parse_positive_integer (shadow_y_offset, &shadow_y_offset_v, context, info->theme, error);
79
 
+      shadow_color_v = parse_color (info->theme, shadow_color, error);
80
 
+
81
 
+      if (!info->style->shadow_properties)
82
 
+        info->style->shadow_properties = meta_shadow_properties_new ();
83
 
+
84
 
+      info->style->shadow_properties->unity_shadow_radius = shadow_radius_v;
85
 
+      info->style->shadow_properties->unity_shadow_opacity = shadow_opacity_v;
86
 
+      info->style->shadow_properties->unity_shadow_x_offset = shadow_x_offset_v;
87
 
+      info->style->shadow_properties->unity_shadow_y_offset = shadow_y_offset_v;
88
 
+      info->style->shadow_properties->unity_shadow_color = shadow_color_v;
89
 
+
90
 
+      push_state (info, STATE_SHADOW);
91
 
+
92
 
+    }
93
 
+  else if (ELEMENT_IS ("padding"))
94
 
+    {
95
 
+      const char *left = NULL;
96
 
+      const char *bottom = NULL;
97
 
+      const char *right = NULL;
98
 
+      int        left_v, right_v, bottom_v;
99
 
+
100
 
+      if (!locate_attributes (context, element_name, attribute_names, attribute_values,
101
 
+                              error,
102
 
+                              "left", &left,
103
 
+                              "right", &right,
104
 
+                              "bottom", &bottom,
105
 
+                              NULL))
106
 
+        return;
107
 
+
108
 
+      parse_positive_integer (left, &left_v, context, info->theme, error);
109
 
+      parse_positive_integer (right, &right_v, context, info->theme, error);
110
 
+      parse_positive_integer (bottom, &bottom_v, context, info->theme, error);
111
 
+
112
 
+      if (!info->style->invisible_grab_area_properties)
113
 
+        info->style->invisible_grab_area_properties = meta_invisible_grab_area_properties_new ();
114
 
+
115
 
+      info->style->invisible_grab_area_properties->left = left_v;
116
 
+      info->style->invisible_grab_area_properties->right = right_v;
117
 
+      info->style->invisible_grab_area_properties->bottom = bottom_v;
118
 
+
119
 
+      push_state (info, STATE_PADDING);
120
 
+    }
121
 
   else
122
 
     {
123
 
       set_error (error, context,
124
 
@@ -3216,6 +3299,38 @@
125
 
 }
126
 
 
127
 
 static void
128
 
+parse_shadow_element (GMarkupParseContext  *context,
129
 
+                      const gchar          *element_name,
130
 
+                      const gchar         **attribute_names,
131
 
+                      const gchar         **attribute_values,
132
 
+                      ParseInfo            *info,
133
 
+                      GError              **error)
134
 
+{
135
 
+  g_return_if_fail (peek_state (info) == STATE_SHADOW);
136
 
+
137
 
+  set_error (error, context,
138
 
+             G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
139
 
+             _("Element <%s> is not allowed below <%s>"),
140
 
+             element_name, "shadow");
141
 
+}
142
 
+
143
 
+static void
144
 
+parse_padding_element (GMarkupParseContext  *context,
145
 
+                      const gchar          *element_name,
146
 
+                      const gchar         **attribute_names,
147
 
+                      const gchar         **attribute_values,
148
 
+                      ParseInfo            *info,
149
 
+                      GError              **error)
150
 
+{
151
 
+  g_return_if_fail (peek_state (info) == STATE_PADDING);
152
 
+
153
 
+  set_error (error, context,
154
 
+             G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
155
 
+             _("Element <%s> is not allowed below <%s>"),
156
 
+             element_name, "padding");
157
 
+}
158
 
+
159
 
+static void
160
 
 parse_menu_icon_element (GMarkupParseContext  *context,
161
 
                          const gchar          *element_name,
162
 
                          const gchar         **attribute_names,
163
 
@@ -3366,6 +3481,16 @@
164
 
                             attribute_names, attribute_values,
165
 
                             info, error);
166
 
       break;
167
 
+    case STATE_SHADOW:
168
 
+       parse_shadow_element (context, element_name,
169
 
+                             attribute_names, attribute_values,
170
 
+                             info, error);
171
 
+       break;
172
 
+    case STATE_PADDING:
173
 
+       parse_padding_element (context, element_name,
174
 
+                              attribute_names, attribute_values,
175
 
+                              info, error);
176
 
+       break;
177
 
     case STATE_MENU_ICON:
178
 
       parse_menu_icon_element (context, element_name,
179
 
                                attribute_names, attribute_values,
180
 
@@ -3635,6 +3760,14 @@
181
 
         }
182
 
       pop_state (info);
183
 
       break;
184
 
+    case STATE_SHADOW:
185
 
+      g_assert (info->style);
186
 
+      pop_state (info);
187
 
+      break;
188
 
+    case STATE_PADDING:
189
 
+      g_assert (info->style);
190
 
+      pop_state (info);
191
 
+      break;
192
 
     case STATE_MENU_ICON:
193
 
       g_assert (info->theme);
194
 
       if (info->op_list != NULL)
195
 
@@ -3859,6 +3992,12 @@
196
 
     case STATE_BUTTON:
197
 
       NO_TEXT ("button");
198
 
       break;
199
 
+    case STATE_SHADOW:
200
 
+      NO_TEXT ("shadow");
201
 
+      break;
202
 
+    case STATE_PADDING:
203
 
+      NO_TEXT ("padding");
204
 
+      break;
205
 
     case STATE_MENU_ICON:
206
 
       NO_TEXT ("menu_icon");
207
 
       break;
208
 
Index: metacity-2.34.1/src/ui/theme.c
209
 
===================================================================
210
 
--- metacity-2.34.1.orig/src/ui/theme.c 2011-03-08 04:31:53.000000000 -0500
211
 
+++ metacity-2.34.1/src/ui/theme.c      2011-08-18 00:02:30.699002293 -0400
212
 
@@ -1088,6 +1088,51 @@
213
 
   g_free (spec);
214
 
 }
215
 
 
216
 
+MetaShadowProperties*
217
 
+meta_shadow_properties_new (void)
218
 
+{
219
 
+  MetaShadowProperties *properties;
220
 
+  
221
 
+  properties = g_new0 (MetaShadowProperties, 1);
222
 
+
223
 
+  if (properties)
224
 
+  {
225
 
+    properties->unity_shadow_radius = 0.0f;
226
 
+    properties->unity_shadow_x_offset = 0;
227
 
+    properties->unity_shadow_y_offset = 0;
228
 
+    properties->unity_shadow_color = NULL;
229
 
+  }
230
 
+
231
 
+  return properties;
232
 
+}
233
 
+
234
 
+void
235
 
+meta_shadow_properties_free (MetaShadowProperties *properties)
236
 
+{
237
 
+  g_return_if_fail (properties != NULL);
238
 
+
239
 
+  meta_color_spec_free (properties->unity_shadow_color);
240
 
+  g_free (properties);
241
 
+}
242
 
+
243
 
+MetaInvisibleGrabAreaProperties*
244
 
+meta_invisible_grab_area_properties_new (void)
245
 
+{
246
 
+  MetaInvisibleGrabAreaProperties *properties;
247
 
+  
248
 
+  properties = g_new0 (MetaInvisibleGrabAreaProperties, 1);
249
 
+
250
 
+  return properties;
251
 
+}
252
 
+
253
 
+void
254
 
+meta_invisible_grab_area_properties_free (MetaInvisibleGrabAreaProperties *properties)
255
 
+{
256
 
+  g_return_if_fail (properties != NULL);
257
 
+
258
 
+  g_free (properties);
259
 
+}
260
 
+
261
 
 MetaColorSpec*
262
 
 meta_color_spec_new (MetaColorSpecType type)
263
 
 {
264
 
@@ -4186,6 +4231,12 @@
265
 
       if (style->parent)
266
 
         meta_frame_style_unref (style->parent);
267
 
 
268
 
+      if (style->shadow_properties)
269
 
+        meta_shadow_properties_free (style->shadow_properties);
270
 
+
271
 
+      if (style->invisible_grab_area_properties)
272
 
+        meta_invisible_grab_area_properties_free (style->invisible_grab_area_properties);
273
 
+
274
 
       DEBUG_FILL_STRUCT (style);
275
 
       g_free (style);
276
 
     }
277
 
@@ -4680,6 +4731,18 @@
278
 
                                     button_states, mini_icon, icon);
279
 
 }
280
 
 
281
 
+MetaShadowProperties *
282
 
+meta_frame_style_get_shadow_properties (MetaFrameStyle *style)
283
 
+{
284
 
+    return style->shadow_properties;
285
 
+}
286
 
+
287
 
+
288
 
+MetaInvisibleGrabAreaProperties * meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style)
289
 
+{
290
 
+    return style->invisible_grab_area_properties;
291
 
+}
292
 
+
293
 
 MetaFrameStyleSet*
294
 
 meta_frame_style_set_new (MetaFrameStyleSet *parent)
295
 
 {
296
 
Index: metacity-2.34.1/src/ui/theme.h
297
 
===================================================================
298
 
--- metacity-2.34.1.orig/src/ui/theme.h 2011-03-08 04:31:53.000000000 -0500
299
 
+++ metacity-2.34.1/src/ui/theme.h      2011-08-18 00:02:30.699002293 -0400
300
 
@@ -34,7 +34,7 @@
301
 
 typedef struct _MetaDrawOp MetaDrawOp;
302
 
 typedef struct _MetaDrawOpList MetaDrawOpList;
303
 
 typedef struct _MetaGradientSpec MetaGradientSpec;
304
 
-typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec; 
305
 
+typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
306
 
 typedef struct _MetaColorSpec MetaColorSpec;
307
 
 typedef struct _MetaFrameLayout MetaFrameLayout;
308
 
 typedef struct _MetaButtonSpace MetaButtonSpace;
309
 
@@ -42,6 +42,54 @@
310
 
 typedef struct _MetaTheme MetaTheme;
311
 
 typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
312
 
 typedef struct _MetaDrawInfo MetaDrawInfo;
313
 
+typedef struct _MetaShadowProperties MetaShadowProperties;
314
 
+typedef struct _MetaInvisibleGrabAreaProperties MetaInvisibleGrabAreaProperties;
315
 
+
316
 
+struct _MetaShadowProperties
317
 
+{
318
 
+  /**
319
 
+   * Radius of the shadow
320
 
+   */
321
 
+  double unity_shadow_radius;
322
 
+
323
 
+  /**
324
 
+   * Opacity of the shadow
325
 
+   */
326
 
+  double unity_shadow_opacity;
327
 
+
328
 
+  /**
329
 
+   * Color of the shadow
330
 
+   */
331
 
+  MetaColorSpec *unity_shadow_color;
332
 
+  /**
333
 
+   * Shadow X Offset
334
 
+   */
335
 
+  guint8 unity_shadow_x_offset;
336
 
+  /**
337
 
+   * Shadow Y Offset
338
 
+   */
339
 
+  guint8 unity_shadow_y_offset;
340
 
+};
341
 
+
342
 
+struct _MetaInvisibleGrabAreaProperties
343
 
+{
344
 
+  /**
345
 
+   * Left padding
346
 
+   */
347
 
+  guint8 left;
348
 
+  /**
349
 
+   * Right padding
350
 
+   */
351
 
+  guint8 right;
352
 
+  /**
353
 
+   * Bottom padding
354
 
+   */
355
 
+  guint8 bottom;
356
 
+  /**
357
 
+   * Top padding
358
 
+   */
359
 
+  guint8 top;
360
 
+};
361
 
 
362
 
 #define META_THEME_ERROR (g_quark_from_static_string ("meta-theme-error"))
363
 
 
364
 
@@ -698,6 +746,15 @@
365
 
    * Transparency of the window background. 0=transparent; 255=opaque.
366
 
    */
367
 
   guint8 window_background_alpha;
368
 
+  /**
369
 
+   * Shadow
370
 
+   */
371
 
+  MetaShadowProperties *shadow_properties;
372
 
+  /**
373
 
+   * Padding (eg invisible grab area)
374
 
+   */
375
 
+  MetaInvisibleGrabAreaProperties *invisible_grab_area_properties;
376
 
+
377
 
 };
378
 
 
379
 
 /* Kinds of frame...
380
 
@@ -951,6 +1008,11 @@
381
 
                                                       int                    n_alphas);
382
 
 void                   meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec);
383
 
 
384
 
+MetaShadowProperties* meta_shadow_properties_new (void);
385
 
+void                  meta_shadow_properties_free (MetaShadowProperties *);
386
 
+
387
 
+MetaInvisibleGrabAreaProperties* meta_invisible_grab_area_properties_new (void);
388
 
+void                             meta_invisible_grab_area_properties_free (MetaInvisibleGrabAreaProperties *);
389
 
 
390
 
 MetaFrameStyle* meta_frame_style_new   (MetaFrameStyle *parent);
391
 
 void            meta_frame_style_ref   (MetaFrameStyle *style);
392
 
@@ -988,6 +1050,8 @@
393
 
                                        GdkPixbuf               *mini_icon,
394
 
                                        GdkPixbuf               *icon);
395
 
 
396
 
+MetaShadowProperties * meta_frame_style_get_shadow_properties (MetaFrameStyle *style);
397
 
+MetaInvisibleGrabAreaProperties * meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style);
398
 
 
399
 
 gboolean       meta_frame_style_validate (MetaFrameStyle    *style,
400
 
                                           guint              current_theme_version,