comparison src/aosd/ghosd.c @ 614:354389b85dce trunk

[svn] - aosd, further work on ghosd source: do not use a override_redirect=true window and give the WM information about initial pos/size of osd (prevents flickering with normal windows); now the osd won't be displayed in multiple workspaces, only in the one where it's initially triggered
author giacomo
date Wed, 07 Feb 2007 03:52:25 -0800
parents 6584e697e6da
children 30f74d6b75cf
comparison
equal deleted inserted replaced
613:85a70ace8c02 614:354389b85dce
12 #include <cairo/cairo-xlib-xrender.h> 12 #include <cairo/cairo-xlib-xrender.h>
13 #include <X11/Xatom.h> 13 #include <X11/Xatom.h>
14 14
15 #include "ghosd.h" 15 #include "ghosd.h"
16 #include "ghosd-internal.h" 16 #include "ghosd-internal.h"
17
18 static unsigned long
19 get_current_workspace(Ghosd *ghosd) {
20 Atom cur_workspace_atom;
21 Atom type;
22 int format;
23 unsigned long nitems, bytes_after;
24 unsigned char *data;
25
26 cur_workspace_atom = XInternAtom(ghosd->dpy, "_NET_CURRENT_DESKTOP", False);
27 XGetWindowProperty(ghosd->dpy, DefaultRootWindow(ghosd->dpy), cur_workspace_atom,
28 0, ULONG_MAX, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &data);
29
30 if ( type == XA_CARDINAL )
31 {
32 unsigned long cur_workspace = (unsigned long)*data;
33 g_print("debug: %i\n", cur_workspace);
34 XFree( data );
35 return cur_workspace;
36 }
37
38 /* fall back to desktop number 0 */
39 return 0;
40 }
17 41
18 static Pixmap 42 static Pixmap
19 take_snapshot(Ghosd *ghosd) { 43 take_snapshot(Ghosd *ghosd) {
20 Pixmap pixmap; 44 Pixmap pixmap;
21 GC gc; 45 GC gc;
94 * behavior we want. */ 118 * behavior we want. */
95 119
96 /* turn off window decorations. 120 /* turn off window decorations.
97 * we could pull this in from a motif header, but it's easier to 121 * we could pull this in from a motif header, but it's easier to
98 * use this snippet i found on a mailing list. */ 122 * use this snippet i found on a mailing list. */
123 XSizeHints *sizehints;
99 Atom mwm_hints = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); 124 Atom mwm_hints = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
100 #define MWM_HINTS_DECORATIONS (1<<1) 125 #define MWM_HINTS_DECORATIONS (1<<1)
101 struct { 126 struct {
102 long flags, functions, decorations, input_mode; 127 long flags, functions, decorations, input_mode;
103 } mwm_hints_setting = { 128 } mwm_hints_setting = {
114 XInternAtom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", False), 139 XInternAtom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", False),
115 XInternAtom(dpy, "_NET_WM_STATE_SKIP_PAGER", False) 140 XInternAtom(dpy, "_NET_WM_STATE_SKIP_PAGER", False)
116 }; 141 };
117 XChangeProperty(dpy, win, win_state, XA_ATOM, 32, 142 XChangeProperty(dpy, win, win_state, XA_ATOM, 32,
118 PropModeReplace, (unsigned char*)&win_state_setting, 3); 143 PropModeReplace, (unsigned char*)&win_state_setting, 3);
144
145 /* give initial pos/size information to window manager
146 about the window, this prevents flickering */
147 sizehints = XAllocSizeHints();
148 sizehints->flags = USPosition | USSize;
149 sizehints->x = -1;
150 sizehints->y = -1;
151 sizehints->width = 1;
152 sizehints->height = 1;
153 XSetWMNormalHints(dpy, win, sizehints);
154 XFree( sizehints );
119 } 155 }
120 156
121 static Window 157 static Window
122 make_window(Display *dpy) { 158 make_window(Display *dpy) {
123 Window win; 159 Window win;
129 att.background_pixel = None; 165 att.background_pixel = None;
130 att.border_pixel = 0; 166 att.border_pixel = 0;
131 att.background_pixmap = None; 167 att.background_pixmap = None;
132 att.save_under = True; 168 att.save_under = True;
133 att.event_mask = ExposureMask | StructureNotifyMask | ButtonPressMask; 169 att.event_mask = ExposureMask | StructureNotifyMask | ButtonPressMask;
134 att.override_redirect = True; 170 att.override_redirect = False;
135 171
136 win = XCreateWindow(dpy, DefaultRootWindow(dpy), 172 win = XCreateWindow(dpy, DefaultRootWindow(dpy),
137 -1, -1, 1, 1, 0, 173 -1, -1, 1, 1, 0,
138 CopyFromParent, InputOutput, CopyFromParent, 174 CopyFromParent, InputOutput, CopyFromParent,
139 CWBackingStore | CWBackPixel | CWBackPixmap | 175 CWBackingStore | CWBackPixel | CWBackPixmap |