aboutsummaryrefslogtreecommitdiff
path: root/x11/gnomepanel/files/patch-temp
blob: a863cbbc8bd99e7092ad95bead7647271b3eed7e (plain) (blame)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
This patch reverts fully rev.1.50 of xstuff.c and rev.1.22 of xstuff.h, as
well as partially rev.1.302 of session.c and rev.1.176 of basep-widget.c.
The goal is to make Nautilus recognizing presence of the panel on screen,
so that it doesn't put its icons under the panel(s). For some reason,
advertized in ChangeLog _NET_WM_WORKAREA isn't recognised by Nautilus-2.0.0
available at this time.

--- gnome-panel/xstuff.c.orig	Sun Aug  4 18:30:21 2002
+++ gnome-panel/xstuff.c	Thu Aug  8 22:19:15 2002
@@ -8,46 +8,97 @@
  *          Mark McLoughlin <mark@skynet.ie>
  */
 #include <config.h>
-#include <string.h>
-
-#include <gdk/gdk.h>
 #include <gdk/gdkx.h>
+#include <string.h>
 
+#include <X11/Xmd.h>
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
-#include "xstuff.h"
+/* Yes, yes I know, now bugger off ... */
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
 
+#include "xstuff.h"
+#include "multiscreen-stuff.h"
+#include "basep-widget.h"
+#include "foobar-widget.h"
 #include "global-keys.h"
 
-static Atom
-panel_atom_get (Display    *display,
-		const char *atom_name)
+/*list of all panel widgets created*/
+extern GSList *panel_list;
+
+static void xstuff_setup_global_desktop_area (int left, int right,
+					int top, int bottom);
+
+#define ATOM(name) xstuff_atom_intern(GDK_DISPLAY(),name)
+/* Once we have multiple display support we need to only use
+ * the below ones */
+
+#define ATOMD(display,name) xstuff_atom_intern(display,name)
+#define ATOMEV(event,name) xstuff_atom_intern(((XAnyEvent *)event)->display,name)
+#define ATOMGDK(win,name) xstuff_atom_intern(GDK_WINDOW_XDISPLAY(win),name)
+
+Atom
+xstuff_atom_intern (Display *display, const char *name)
 {
-	static GHashTable *atom_hash;
-	Atom               retval;
+	static GHashTable *cache = NULL;
+	char *key;
+	Atom atom;
 
 	g_return_val_if_fail (display != NULL, None);
-	g_return_val_if_fail (atom_name != NULL, None);
+	g_return_val_if_fail (name != NULL, None);
+
+	if (cache == 0)
+	    cache = g_hash_table_new (g_str_hash, g_str_equal);
 
-	if (!atom_hash)
-		atom_hash = g_hash_table_new_full (
-				g_str_hash, g_str_equal, g_free, NULL);
-
-	retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
-	if (!retval) {
-		retval = XInternAtom (display, atom_name, FALSE);
-
-		if (retval != None)
-			g_hash_table_insert (atom_hash, g_strdup (atom_name),
-					     GUINT_TO_POINTER (retval));
+	key = g_strdup_printf ("%p %s", display, name);
+
+	atom = (Atom)g_hash_table_lookup (cache, key);
+	if (atom == 0) {
+	    	atom = XInternAtom (display, name, False);
+		g_hash_table_insert (cache, key, (gpointer)atom);
+	} else {
+	   	g_free (key);
 	}
 
-	return retval;
+    	return atom;
+}
+
+void
+xstuff_init (void)
+{
+       /* setup the keys filter */
+       gdk_window_add_filter (gdk_get_default_root_window (),
+                              panel_global_keys_filter,
+                              NULL);
+
+       gdk_error_trap_push ();
+
+       xstuff_setup_global_desktop_area (0, 0, 0, 0);
+
+       gdk_error_trap_pop ();
+}
+
+void
+xstuff_set_simple_hint (GdkWindow *w, const char *name, long val)
+{
+       Atom atom = ATOMGDK (w, name);
+
+       gdk_error_trap_push ();
+
+       XChangeProperty (GDK_DISPLAY (),
+                        GDK_WINDOW_XWINDOW (w),
+                        atom, atom,
+                        32, PropModeReplace,
+                        (unsigned char*)&val, 1);
+
+       gdk_flush ();
+       gdk_error_trap_pop ();
 }
 
 /* Stolen from deskguide */
-static gpointer
+gpointer
 get_typed_property_data (Display *xdisplay,
 			 Window   xwindow,
 			 Atom     property,
@@ -156,7 +207,7 @@
         
 	data = get_typed_property_data (GDK_DISPLAY (),
 					GDK_ROOT_WINDOW (),
-					panel_atom_get (GDK_DISPLAY (), "_NET_SUPPORTED"),
+					ATOM ("_NET_SUPPORTED"),
 					XA_ATOM,
 					&size, 32);
 	if (data != NULL) {
@@ -176,11 +227,9 @@
 
 	XDeleteProperty (GDK_WINDOW_XDISPLAY (win),
 			 GDK_WINDOW_XWINDOW (win),
-			 panel_atom_get (GDK_WINDOW_XDISPLAY (win),
-					 "WM_CLIENT_LEADER"));
+			 ATOMGDK (win, "WM_CLIENT_LEADER"));
 
-	old_wmhints = XGetWMHints (GDK_WINDOW_XDISPLAY (win),
-				   GDK_WINDOW_XWINDOW (win));
+	old_wmhints = XGetWMHints (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (win));
 	/* General paranoia */
 	if (old_wmhints != NULL) {
 		memcpy (&wmhints, old_wmhints, sizeof (XWMHints));
@@ -197,16 +246,124 @@
 		wmhints.input = False;
 		wmhints.initial_state = NormalState;
 	}
-
-	XSetWMHints (GDK_WINDOW_XDISPLAY (win),
+	XSetWMHints (GDK_DISPLAY (),
 		     GDK_WINDOW_XWINDOW (win),
 		     &wmhints);
 }
 
+
+static void
+xstuff_setup_global_desktop_area (int left, int right, int top, int bottom)
+{
+       long vals[4];
+       static int old_left = -1, old_right = -1, old_top = -1, old_bottom = -1;+
+       left = left >= 0 ? left : old_left;
+       right = right >= 0 ? right : old_right;
+       top = top >= 0 ? top : old_top;
+       bottom = bottom >= 0 ? bottom : old_bottom;
+
+      if (old_left == left &&
+           old_right == right &&
+           old_top == top &&
+           old_bottom == bottom)
+               return;
+
+       vals[0] = left;
+       vals[1] = right;
+       vals[2] = top;
+       vals[3] = bottom;
+
+       XChangeProperty (GDK_DISPLAY (),
+                        GDK_ROOT_WINDOW (),
+                        ATOM ("GNOME_PANEL_DESKTOP_AREA"),
+                        XA_CARDINAL,
+                        32, PropModeReplace,
+                        (unsigned char *)vals, 4);
+
+       old_left = left;
+       old_right = right;
+       old_top = top;
+       old_bottom = bottom;
+}
+
+void
+xstuff_setup_desktop_area (int screen, int left, int right, int top, int bottom)
+{
+       char *screen_atom;
+       long vals[4];
+       static int screen_width = -1, screen_height = -1;
+
+       if (screen_width < 0)
+               screen_width = gdk_screen_width ();
+       if (screen_height < 0)
+               screen_height = gdk_screen_height ();
+
+       vals[0] = left;
+       vals[1] = right;
+       vals[2] = top;
+       vals[3] = bottom;
+
+       gdk_error_trap_push ();
+
+       /* Note, when we do standard multihead and we have per screen
+        * root window, this should just set the GNOME_PANEL_DESKTOP_AREA */
+       screen_atom = g_strdup_printf ("GNOME_PANEL_DESKTOP_AREA_%d",
+                                      screen);
+       XChangeProperty (GDK_DISPLAY (),
+                        GDK_ROOT_WINDOW (),
+                        ATOM (screen_atom),
+                        XA_CARDINAL,
+                        32, PropModeReplace,
+                        (unsigned char *)vals, 4);
+
+       g_free (screen_atom);
+
+       xstuff_setup_global_desktop_area
+               ((multiscreen_x (screen)      == 0)             ? left   : -1,
+                (multiscreen_x (screen) +
+                 multiscreen_width (screen)  == screen_width)  ? right  : -1,
+                (multiscreen_y (screen)      == 0)             ? top    : -1,
+                (multiscreen_y (screen) +
+                 multiscreen_height (screen) == screen_height) ? bottom : -1);
+
+       gdk_flush ();
+       gdk_error_trap_pop ();
+}
+
+void
+xstuff_unsetup_desktop_area (void)
+{
+       int i;
+       char *screen_atom;
+
+       gdk_error_trap_push ();
+
+       XDeleteProperty (GDK_DISPLAY (),
+                        GDK_ROOT_WINDOW (),
+                        ATOM ("GNOME_PANEL_DESKTOP_AREA"));
+
+       for (i = 0; i < multiscreen_screens (); i++) {
+               screen_atom =
+                       g_strdup_printf ("GNOME_PANEL_DESKTOP_AREA_%d", i);
+
+               XDeleteProperty (GDK_DISPLAY (),
+                                GDK_ROOT_WINDOW (),
+                                ATOM (screen_atom));
+
+               g_free (screen_atom);
+       }
+
+       gdk_flush ();
+       gdk_error_trap_pop ();
+}
+
+
+
 /* This is such a broken stupid function. */   
 void
 xstuff_set_pos_size (GdkWindow *window, int x, int y, int w, int h)
 {
+	Window win = GDK_WINDOW_XWINDOW (window);
 	XSizeHints size_hints;
 	int old_x, old_y, old_w, old_h;
 
@@ -231,9 +388,7 @@
   
 	gdk_error_trap_push ();
 
-	XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
-			   GDK_WINDOW_XWINDOW (window),
-			   &size_hints);
+	XSetWMNormalHints (GDK_DISPLAY (), win, &size_hints);
 
 	gdk_window_move_resize (window, x, y, w, h);
 
@@ -250,33 +405,29 @@
 xstuff_set_wmspec_dock_hints (GdkWindow *window,
 			      gboolean autohide)
 {
-        Atom atoms [2] = { None, None };
+	Atom atoms[2] = { None, None };
         
-	if (!autohide)
-		atoms [0] = panel_atom_get (GDK_WINDOW_XDISPLAY (window),
-					    "_NET_WM_WINDOW_TYPE_DOCK");
-	else {
-		atoms [0] = panel_atom_get (GDK_WINDOW_XDISPLAY (window),
-					    "_GNOME_WINDOW_TYPE_AUTOHIDE_PANEL");
-		atoms [1] = panel_atom_get (GDK_WINDOW_XDISPLAY (window),
-					    "_NET_WM_WINDOW_TYPE_DOCK");
+	if (autohide) {
+		atoms[0] = ATOMGDK (window, "_GNOME_WINDOW_TYPE_AUTOHIDE_PANEL");
+		atoms[1] = ATOMGDK (window, "_NET_WM_WINDOW_TYPE_DOCK");
+	} else {
+		atoms[0] = ATOMGDK (window, "_NET_WM_WINDOW_TYPE_DOCK");
 	}
 
         XChangeProperty (GDK_WINDOW_XDISPLAY (window),
                          GDK_WINDOW_XWINDOW (window),
-			 panel_atom_get (GDK_WINDOW_XDISPLAY (window),
-					 "_NET_WM_WINDOW_TYPE"),
+			 ATOMGDK (window, "_NET_WM_WINDOW_TYPE"),
                          XA_ATOM, 32, PropModeReplace,
-                         (unsigned char *) atoms, 
+			 (guchar *)atoms,
 			 autohide ? 2 : 1);
 }
 
 void
 xstuff_set_wmspec_strut (GdkWindow *window,
-			 int        left,
-			 int        right,
-			 int        top,
-			 int        bottom)
+			int left,
+			int right,
+			int top,
+			int bottom)
 {
 	long vals [4];
         
@@ -287,25 +438,15 @@
 
         XChangeProperty (GDK_WINDOW_XDISPLAY (window),
                          GDK_WINDOW_XWINDOW (window),
-			 panel_atom_get (GDK_WINDOW_XDISPLAY (window),
-					 "_NET_WM_STRUT"),
+			 ATOMGDK (window, "_NET_WM_STRUT"),
                          XA_CARDINAL, 32, PropModeReplace,
-                         (unsigned char *) vals, 4);
+			 (guchar *)vals, 4);
 }
 
 void
 xstuff_delete_property (GdkWindow *window, const char *name)
 {
-	Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
-	Window   xwindow  = GDK_WINDOW_XWINDOW (window);
-
-        XDeleteProperty (xdisplay, xwindow,
-			 panel_atom_get (xdisplay, name));
-}
-
-void
-xstuff_init (void)
-{
-	gdk_window_add_filter (gdk_get_default_root_window (),
-			       panel_global_keys_filter, NULL);
+	XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
+			GDK_WINDOW_XWINDOW (window),
+			ATOMGDK (window, name));
 }
--- gnome-panel/xstuff.h.orig	Fri Jun 21 02:07:59 2002
+++ gnome-panel/xstuff.h	Thu Aug  8 22:11:31 2002
@@ -1,15 +1,36 @@
-#ifndef __XSTUFF_H__
-#define __XSTUFF_H__
+#ifndef XSTUFF_H
 
-#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#include <X11/Xmd.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
 
 void xstuff_init			(void);
+Atom xstuff_atom_intern                        (Display *display,
+					const char *name);
+void xstuff_set_simple_hint            (GdkWindow *w,
+					const char *name,
+					long val);
 void xstuff_delete_property		(GdkWindow *window,
 					 const char *name);
 gboolean xstuff_is_compliant_wm		(void);
 
+gpointer get_typed_property_data       (Display *xdisplay,
+					Window   xwindow,
+					Atom     property,
+					Atom     requested_type,
+					gint    *size_p,
+					guint    expected_format);
+
 void xstuff_set_no_group_and_no_input	(GdkWindow *win);
 
+void xstuff_setup_desktop_area         (int screen,
+					int left,
+					int right,
+					int top,
+					int bottom);
+
 void xstuff_unsetup_desktop_area	(void);
 void xstuff_set_pos_size		(GdkWindow *window,
 					 int x, int y,
@@ -22,4 +43,4 @@
 					 int top,
 					 int bottom);
 
-#endif /* __XSTUFF_H__ */
+#endif
--- gnome-panel/basep-widget.c.orig	Sun Aug  4 18:29:17 2002
+++ gnome-panel/basep-widget.c	Thu Aug  8 22:11:37 2002
@@ -2508,6 +2508,11 @@
 		    BASEP_WIDGET (panel)->screen == screen)
 			gtk_widget_queue_resize (panel);
 	}
+	xstuff_setup_desktop_area (screen,
+				   sb->left,
+				   sb->right,
+				   sb->top,
+				   sb->bottom);
 }
 
 static guint  queue_recalc_id = 0;
--- gnome-panel/session.c.orig	Wed Jul 31 20:02:15 2002
+++ gnome-panel/session.c	Thu Aug  8 22:11:41 2002
@@ -242,6 +242,8 @@
 
 	gnome_config_sync ();
 
+	xstuff_unsetup_desktop_area ();
+
 	panel_shell_unregister ();
 	
 	gtk_main_quit();