diff options
author | MC <mc@hack.org> | 2010-06-23 15:00:36 +0200 |
---|---|---|
committer | MC <mc@hack.org> | 2010-06-23 15:00:36 +0200 |
commit | 34be9f9e245480a2d35c88c4f26c048c6e53b0ab (patch) | |
tree | ea93fbb544bf0f7c7a613e9178b9692f9122b2cc /mcwm.c | |
parent | df9f53bf97c20d0643ac65143d401d54f42be205 (diff) | |
download | mcwm-34be9f9e245480a2d35c88c4f26c048c6e53b0ab.zip |
Ignore windows with override redirect set when initializing at start.
Don't bother setting focus when entering a window if the event notify
says we're not in a normal state, e.g. the pointer is grabbed by some
client (including us).
Diffstat (limited to 'mcwm.c')
-rw-r--r-- | mcwm.c | 82 |
1 files changed, 67 insertions, 15 deletions
@@ -307,7 +307,8 @@ int setupscreen(void) int i; int len; xcb_window_t *children; - + xcb_get_window_attributes_reply_t *attr; + /* Get all children. */ reply = xcb_query_tree_reply(conn, xcb_query_tree(conn, screen->root), 0); @@ -319,10 +320,40 @@ int setupscreen(void) len = xcb_query_tree_children_length(reply); children = xcb_query_tree_children(reply); - /* Set up all windows. */ + /* Set up all windows on this root. */ for (i = 0; i < len; i ++) { - setupwin(children[i]); + attr = xcb_get_window_attributes_reply( + conn, xcb_get_window_attributes(conn, children[i]), NULL); + + if (!attr) + { + PDEBUG("Couldn't get attributes."); + } + else + { + /* + * Don't set up windows in override redirect mode. + * + * This mode means they wouldn't have been reported to us + * with a MapRequest if we had been running, so in the + * normal case we wouldn't have seen them. + * + * Usually, this mode is used for menu windows and the + * like. + */ + if (!attr->override_redirect) + { + setupwin(children[i]); + } +#if #DEBUG + else + { + PDEBUG("win %d has override_redirect.\n", children[i]); + } +#endif + free(attr); + } } /* @@ -1265,25 +1296,46 @@ void events(void) break; case XCB_ENTER_NOTIFY: - PDEBUG("event: Enter notify.\n"); - if (0 == mode) + { + xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *)ev; + + PDEBUG("event: Enter notify eventwin %d child %d.\n", + e->event, + e->child); + + /* + * If this isn't a normal enter notify, don't bother. + * + * The other cases means the pointer is grabbed and that + * either means someone is using it for menu selections or + * that we're moving or resizing. We don't want to change + * focus in these cases. + * + */ + if (e->mode != XCB_NOTIFY_MODE_NORMAL) + { + PDEBUG("Not a normal EnterNotify. Ignoring.\n"); + break; + } + + /* + * If we're entering the same window we focus now, + * then don't bother focusing. + */ + if (e->event != focuswin) { - xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *)ev; - /* - * If we're entering the same window we focus now, - * then don't bother focusing. + * Otherwise, set focus to the window we just entered. */ - if (e->event != focuswin) - { - setfocus(e->event); - } + setfocus(e->event); } - break; + } + break; case XCB_CONFIGURE_NOTIFY: { - xcb_configure_notify_event_t *e = (xcb_configure_notify_event_t *)ev; + xcb_configure_notify_event_t *e + = (xcb_configure_notify_event_t *)ev; if (e->window == screen->root) { |