wintype windowType;
unsigned long damage_sequence; /* sequence when damage was created */
+ Bool need_configure;
+ XConfigureEvent queue_configure;
+
/* for drawing translucent windows */
XserverRegion borderClip;
struct _win *prev_trans;
/* opacity property name; sometime soon I'll write up an EWMH spec for it */
#define OPACITY_PROP "_NET_WM_WINDOW_OPACITY"
+#define REGISTER_PROP "_NET_WM_CM_S"
#define TRANSLUCENT 0xe0000000
#define OPAQUE 0xffffffff
get_opacity_prop (Display *dpy, win *w, unsigned int def);
static void
+configure_win (Display *dpy, XConfigureEvent *ce);
+
+static void
map_win (Display *dpy, Window id, unsigned long sequence, Bool fade)
{
win *w = find_win (dpy, id);
return;
w->a.map_state = IsViewable;
-
- /* This needs to be here or else we lose transparency messages */
- XSelectInput (dpy, id, PropertyChangeMask);
-
- /* This needs to be here since we don't get PropertyNotify when unmapped */
- w->opacity = get_opacity_prop (dpy, w, OPAQUE);
- determine_mode (dpy, w);
w->windowType = determine_wintype (dpy, w->id, w->id);
#if 0
printf("window 0x%x type %s\n", w->id, wintype_name(w->windowType));
#endif
+ /* select before reading the property so that no property changes are lost */
+ XSelectInput (dpy, id, PropertyChangeMask);
+ w->opacity = get_opacity_prop (dpy, w, OPAQUE);
+
+ determine_mode (dpy, w);
+
#if CAN_DO_USABLE
w->damage_bounds.x = w->damage_bounds.y = 0;
w->damage_bounds.width = w->damage_bounds.height = 0;
#endif
w->damaged = 0;
-#if HAS_NAME_WINDOW_PIXMAP
- /* If the window was previously mapped and its pixmap still exists, it
- is out of date now, so force us to reacquire it. (If the window
- re-maps before the unmap fade-out finished) */
- if (w->pixmap)
- {
- XFreePixmap (dpy, w->pixmap);
- w->pixmap = None;
- }
-#endif
-
if (fade && winTypeFade[w->windowType])
set_fade (dpy, w, 0, get_opacity_percent (dpy, w), fade_in_step, 0, True, True);
+
+ /* if any configure events happened while the window was unmapped, then
+ configure the window to its correct place */
+ if (w->need_configure)
+ configure_win (dpy, &w->queue_configure);
}
static void
w->picture = None;
}
- /* don't care about properties anymore */
- set_ignore (dpy, NextRequest (dpy));
- XSelectInput(dpy, w->id, 0);
-
if (w->borderSize)
{
set_ignore (dpy, NextRequest (dpy));
if (!w)
return;
w->a.map_state = IsUnmapped;
+
+ /* don't care about properties anymore */
+ set_ignore (dpy, NextRequest (dpy));
+ XSelectInput(dpy, w->id, 0);
+
#if HAS_NAME_WINDOW_PIXMAP
if (w->pixmap && fade && winTypeFade[w->windowType])
set_fade (dpy, w, w->opacity*1.0/OPAQUE, 0.0, fade_out_step, unmap_callback, False, True);
new->shadow_width = 0;
new->shadow_height = 0;
new->opacity = OPAQUE;
+ new->need_configure = False;
new->borderClip = None;
new->prev_trans = 0;
}
return;
}
+
+ if (w->a.map_state == IsUnmapped) {
+ /* save the configure event for when the window maps */
+ w->need_configure = True;
+ w->queue_configure = *ce;
+ }
+ else {
+ w->need_configure = False;
+
#if CAN_DO_USABLE
- if (w->usable)
+ if (w->usable)
#endif
- {
- damage = XFixesCreateRegion (dpy, 0, 0);
- if (w->extents != None)
- XFixesCopyRegion (dpy, damage, w->extents);
- }
- w->a.x = ce->x;
- w->a.y = ce->y;
- /* Only destroy the pixmap if the window is mapped */
- if (w->a.map_state != IsUnmapped &&
- (w->a.width != ce->width || w->a.height != ce->height))
- {
+ {
+ damage = XFixesCreateRegion (dpy, 0, 0);
+ if (w->extents != None)
+ XFixesCopyRegion (dpy, damage, w->extents);
+ }
+
+ w->a.x = ce->x;
+ w->a.y = ce->y;
+ if (w->a.width != ce->width || w->a.height != ce->height)
+ {
#if HAS_NAME_WINDOW_PIXMAP
- if (w->pixmap)
- {
- XFreePixmap (dpy, w->pixmap);
- w->pixmap = None;
- if (w->picture)
- {
- XRenderFreePicture (dpy, w->picture);
- w->picture = None;
- }
- }
+ if (w->pixmap)
+ {
+ XFreePixmap (dpy, w->pixmap);
+ w->pixmap = None;
+ if (w->picture)
+ {
+ XRenderFreePicture (dpy, w->picture);
+ w->picture = None;
+ }
+ }
#endif
- if (w->shadow)
- {
- XRenderFreePicture (dpy, w->shadow);
- w->shadow = None;
- }
+ if (w->shadow)
+ {
+ XRenderFreePicture (dpy, w->shadow);
+ w->shadow = None;
+ }
+ }
+ w->a.width = ce->width;
+ w->a.height = ce->height;
+ w->a.border_width = ce->border_width;
+ if (w->a.map_state != IsUnmapped && damage)
+ {
+ XserverRegion extents = win_extents (dpy, w);
+ XFixesUnionRegion (dpy, damage, damage, extents);
+ XFixesDestroyRegion (dpy, extents);
+ add_damage (dpy, damage);
+ }
}
- w->a.width = ce->width;
- w->a.height = ce->height;
- w->a.border_width = ce->border_width;
w->a.override_redirect = ce->override_redirect;
restack_win (dpy, w, ce->above);
- if (w->a.map_state != IsUnmapped && damage)
- {
- XserverRegion extents = win_extents (dpy, w);
- XFixesUnionRegion (dpy, damage, damage, extents);
- XFixesDestroyRegion (dpy, extents);
- add_damage (dpy, damage);
- }
clipChanged = True;
}
XDamageDestroy (dpy, w->damage);
w->damage = None;
}
+
cleanup_fade (dpy, w);
free (w);
break;
destroy_win (Display *dpy, Window id, Bool fade)
{
win *w = find_win (dpy, id);
+
#if HAS_NAME_WINDOW_PIXMAP
if (w && w->pixmap && fade && winTypeFade[w->windowType])
set_fade (dpy, w, w->opacity*1.0/OPAQUE, 0.0, fade_out_step,
}
static void
-register_cm (void)
+register_cm (int scr)
{
Window w;
Atom a;
+ char *buf;
+ int len, s;
+
+ if (scr < 0) return;
w = XCreateSimpleWindow (dpy, RootWindow (dpy, 0), 0, 0, 1, 1, 0, None,
None);
Xutf8SetWMProperties (dpy, w, "xcompmgr", "xcompmgr", NULL, 0, NULL, NULL,
NULL);
- /* FIXME: Don't hard code the screen number */
- a = XInternAtom (dpy, "_NET_WM_CM_S0", False);
+ len = strlen(REGISTER_PROP) + 2;
+ s = scr;
+ while (s >= 10) {
+ ++len;
+ s /= 10;
+ }
+ buf = malloc(len);
+ snprintf(buf, len, REGISTER_PROP"%d", scr);
+
+ a = XInternAtom (dpy, buf, False);
+ free(buf);
XSetSelectionOwner (dpy, a, w, 0);
}
exit (1);
}
- register_cm();
+ register_cm(scr);
/* get atoms */
opacityAtom = XInternAtom (dpy, OPACITY_PROP, False);