summaryrefslogtreecommitdiff
path: root/src/event.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.cpp')
-rw-r--r--src/event.cpp60
1 files changed, 53 insertions, 7 deletions
diff --git a/src/event.cpp b/src/event.cpp
index 034ea6a..2cf55b4 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -950,6 +950,34 @@ PrivateScreen::handleActionEvent (XEvent *event)
}
void
+PrivateScreen::setDefaultWindowAttributes (XWindowAttributes *wa)
+{
+ wa->x = 0;
+ wa->y = 0;
+ wa->width = 1;
+ wa->height = 1;
+ wa->border_width = 0;
+ wa->depth = 0;
+ wa->visual = NULL;
+ wa->root = None;
+ wa->c_class = InputOnly;
+ wa->bit_gravity = NorthWestGravity;
+ wa->win_gravity = NorthWestGravity;
+ wa->backing_store = NotUseful;
+ wa->backing_planes = 0;
+ wa->backing_pixel = 0;
+ wa->save_under = false;
+ wa->colormap = None;
+ wa->map_installed = false;
+ wa->map_state = IsUnviewable;
+ wa->all_event_masks = 0;
+ wa->your_event_mask = 0;
+ wa->do_not_propagate_mask = 0;
+ wa->override_redirect = true;
+ wa->screen = NULL;
+}
+
+void
CompScreen::handleCompizEvent (const char *plugin,
const char *event,
CompOption::Vector &options)
@@ -1021,10 +1049,19 @@ CompScreen::handleEvent (XEvent *event)
}
break;
case CreateNotify:
- XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa);
+ {
+ bool failure = false;
+
+ /* Failure means that window has been destroyed. We still have to add
+ * the window to the window list as we might get configure requests
+ * which require us to stack other windows relative to it. Setting
+ * some default values if this is the case. */
+ if (failure = !XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa))
+ priv->setDefaultWindowAttributes (&wa);
+
w = findTopLevelWindow (event->xcreatewindow.window, true);
- if (event->xcreatewindow.parent == wa.root &&
+ if ((event->xcreatewindow.parent == wa.root || failure) &&
(!w || w->frame () != event->xcreatewindow.window))
{
/* Track the window if it was created on this
@@ -1032,15 +1069,16 @@ CompScreen::handleEvent (XEvent *event)
* for FocusChangeMask. Also, we don't want to
* manage it straight away - in reality we want
* that to wait until the map request */
- if (wa.root == priv->root)
+ if (failure || (wa.root == priv->root))
{
- /* Our SubstructurRedirectMask doesn't work on OverrideRedirect
+ /* Our SubstructureRedirectMask doesn't work on OverrideRedirect
* windows so we need to track them directly here */
if (!event->xcreatewindow.override_redirect)
- new CoreWindow (event->xcreatewindow.window);
+ new CoreWindow (event->xcreatewindow.window, wa);
else
{
- CoreWindow *cw = new CoreWindow (event->xcreatewindow.window);
+ CoreWindow *cw =
+ new CoreWindow (event->xcreatewindow.window, wa);
if (cw)
{
@@ -1054,6 +1092,7 @@ CompScreen::handleEvent (XEvent *event)
FocusChangeMask);
}
break;
+ }
case DestroyNotify:
w = findWindow (event->xdestroywindow.window);
if (w)
@@ -1160,7 +1199,14 @@ CompScreen::handleEvent (XEvent *event)
w = findWindow (event->xreparent.window);
if (!w && event->xreparent.parent == priv->root)
{
- CoreWindow *cw = new CoreWindow (event->xreparent.window);
+ /* Failure means that window has been destroyed. We still have to add
+ * the window to the window list as we might get configure requests
+ * which require us to stack other windows relative to it. Setting
+ * some default values if this is the case. */
+ if (!XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa))
+ priv->setDefaultWindowAttributes (&wa);
+
+ CoreWindow *cw = new CoreWindow (event->xreparent.window, wa);
if (cw)
{