#include "all.h"
#include <time.h>
+#include <float.h>
#include <sys/time.h>
#include <xcb/randr.h>
#include <X11/XKBlib.h>
static void handle_screen_change(xcb_generic_event_t *e) {
DLOG("RandR screen change\n");
+ /* The geometry of the root window is used for “fullscreen global” and
+ * changes when new outputs are added. */
+ xcb_get_geometry_cookie_t cookie = xcb_get_geometry(conn, root);
+ xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(conn, cookie, NULL);
+ if (reply == NULL) {
+ ELOG("Could not get geometry of the root window, exiting\n");
+ exit(1);
+ }
+ DLOG("root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
+
+ croot->rect.width = reply->width;
+ croot->rect.height = reply->height;
+
randr_query_outputs();
scratchpad_fix_resolution();
handle_unmap_notify_event(&unmap);
}
+static bool window_name_changed(i3Window *window, char *old_name) {
+ if ((old_name == NULL) && (window->name == NULL))
+ return false;
+
+ /* Either the old or the new one is NULL, but not both. */
+ if ((old_name == NULL) ^ (window->name == NULL))
+ return true;
+
+ return (strcmp(old_name, i3string_as_utf8(window->name)) != 0);
+}
+
/*
* Called when a window changes its title
*
if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
return false;
+ char *old_name = (con->window->name != NULL ? sstrdup(i3string_as_utf8(con->window->name)) : NULL);
+
window_update_name(con->window, prop, false);
x_push_changes(croot);
+ if (window_name_changed(con->window, old_name))
+ ipc_send_window_event("title", con);
+
+ FREE(old_name);
+
return true;
}
if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
return false;
+ char *old_name = (con->window->name != NULL ? sstrdup(i3string_as_utf8(con->window->name)) : NULL);
+
window_update_name_legacy(con->window, prop, false);
x_push_changes(croot);
+ if (window_name_changed(con->window, old_name))
+ ipc_send_window_event("title", con);
+
+ FREE(old_name);
+
return true;
}
return;
}
+ if (con_is_internal(ws)) {
+ DLOG("Workspace is internal, ignoring _NET_ACTIVE_WINDOW\n");
+ return;
+ }
+
if (ws != con_get_workspace(focused))
workspace_show(ws);
xcb_flush(conn);
free(reply);
} else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
- // A client can request an estimate for the frame size which the window
- // manager will put around it before actually mapping its window. Java
- // does this (as of openjdk-7).
- //
- // Note that the calculation below is not entirely accurate — once you
- // set a different border type, it’s off. We _could_ request all the
- // window properties (which have to be set up at this point according
- // to EWMH), but that seems rather elaborate. The standard explicitly
- // says the application must cope with an estimate that is not entirely
- // accurate.
+ /*
+ * A client can request an estimate for the frame size which the window
+ * manager will put around it before actually mapping its window. Java
+ * does this (as of openjdk-7).
+ *
+ * Note that the calculation below is not entirely accurate — once you
+ * set a different border type, it’s off. We _could_ request all the
+ * window properties (which have to be set up at this point according
+ * to EWMH), but that seems rather elaborate. The standard explicitly
+ * says the application must cope with an estimate that is not entirely
+ * accurate.
+ */
DLOG("_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
- xcb_get_geometry_reply_t *geometry;
- xcb_get_geometry_cookie_t cookie = xcb_get_geometry(conn, event->window);
-
- if (!(geometry = xcb_get_geometry_reply(conn, cookie, NULL))) {
- ELOG("Could not get geometry of X11 window 0x%08x while handling "
- "the _NET_REQUEST_FRAME_EXTENTS ClientMessage\n",
- event->window);
- return;
- }
-
- DLOG("Current geometry = x=%d, y=%d, width=%d, height=%d\n",
- geometry->x, geometry->y, geometry->width, geometry->height);
+ /* The reply data: approximate frame size */
Rect r = {
- 0, // left
- geometry->width + 4, // right
- 0, // top
- geometry->height + config.font.height + 5, // bottom
+ config.default_border_width, /* left */
+ config.default_border_width, /* right */
+ config.font.height + 5, /* top */
+ config.default_border_width /* bottom */
};
xcb_change_property(
conn,
return false;
}
- xcb_icccm_wm_hints_t hints;
-
+ bool urgency_hint;
if (reply == NULL)
- if (!(reply = xcb_get_property_reply(conn, xcb_icccm_get_wm_hints(conn, window), NULL)))
- return false;
-
- if (!xcb_icccm_get_wm_hints_from_reply(&hints, reply))
- return false;
-
- /* Update the flag on the client directly */
- bool hint_urgent = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
- con_set_urgency(con, hint_urgent);
-
+ reply = xcb_get_property_reply(conn, xcb_icccm_get_wm_hints(conn, window), NULL);
+ window_update_hints(con->window, reply, &urgency_hint);
+ con_set_urgency(con, urgency_hint);
tree_render();
- if (con->window)
- window_update_hints(con->window, reply);
- else free(reply);
return true;
}
struct property_handler_t *handler = NULL;
xcb_get_property_reply_t *propr = NULL;
- for (int c = 0; c < sizeof(property_handlers) / sizeof(struct property_handler_t); c++) {
+ for (size_t c = 0; c < sizeof(property_handlers) / sizeof(struct property_handler_t); c++) {
if (property_handlers[c].atom != atom)
continue;