int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window,
xcb_atom_t name, xcb_get_property_reply_t *reply);
+/**
+ * Handles the transient for hints set by a window, signalizing that this window is a popup window
+ * for some other window.
+ *
+ * See ICCCM 4.1.2.6 for more details
+ *
+ */
+int handle_transient_for(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window,
+ xcb_atom_t name, xcb_get_property_reply_t *reply);
+
#endif
#ifndef _I3_H
#define _I3_H
-#define NUM_ATOMS 13
+#define NUM_ATOMS 14
extern char **start_argv;
extern Display *xkbdpy;
_NET_WM_STATE,
_NET_WM_WINDOW_TYPE,
_NET_WM_WINDOW_TYPE_DOCK,
+ _NET_WM_WINDOW_TYPE_DIALOG,
_NET_WM_DESKTOP,
_NET_WM_STRUT_PARTIAL,
WM_PROTOCOLS,
return 1;
}
- if (strcmp(new_class, "tools") == 0) {
- LOG("tool window, should we put it floating?\n");
+ if (strcmp(new_class, "tools") == 0 || strcmp(new_class, "Dialog") == 0) {
+ LOG("tool/dialog window, should we put it floating?\n");
if (client->floating == FLOATING_AUTO_OFF)
toggle_floating_mode(conn, client, true);
}
else
xcb_get_wm_normal_hints_reply(conn, xcb_get_wm_normal_hints_unchecked(conn, client->child), &size_hints, NULL);
+ if ((size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)) {
+ LOG("min size set\n");
+ LOG("gots min_width = %d, min_height = %d\n", size_hints.min_width, size_hints.min_height);
+ }
+
/* If no aspect ratio was set or if it was invalid, we ignore the hints */
if (!(size_hints.flags & XCB_SIZE_HINT_P_ASPECT) ||
(size_hints.min_aspect_num <= 0) ||
return 1;
}
+
+/*
+ * Handles the transient for hints set by a window, signalizing that this window is a popup window
+ * for some other window.
+ *
+ * See ICCCM 4.1.2.6 for more details
+ *
+ */
+int handle_transient_for(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window,
+ xcb_atom_t name, xcb_get_property_reply_t *reply) {
+ LOG("Transient hint!\n");
+ Client *client = table_get(&by_child, window);
+ if (client == NULL) {
+ LOG("No such client\n");
+ return 1;
+ }
+
+ xcb_window_t transient_for;
+
+ if (reply != NULL) {
+ if (!xcb_get_wm_transient_for_from_reply(&transient_for, reply)) {
+ LOG("Not transient for any window\n");
+ return 1;
+ }
+ } else {
+ if (!xcb_get_wm_transient_for_reply(conn, xcb_get_wm_transient_for_unchecked(conn, window),
+ &transient_for, NULL)) {
+ LOG("Not transient for any window\n");
+ return 1;
+ }
+ }
+
+ if (client->floating == FLOATING_AUTO_OFF) {
+ LOG("This is a popup window, putting into floating\n");
+ toggle_floating_mode(conn, client, true);
+ }
+
+ return 1;
+}
/* Watch _NET_WM_NAME (= title of the window in UTF-8) property */
xcb_property_set_handler(&prophs, atoms[_NET_WM_NAME], 128, handle_windowname_change, NULL);
+ /* Watch WM_TRANSIENT_FOR property (to which client this popup window belongs) */
+ xcb_property_set_handler(&prophs, WM_TRANSIENT_FOR, UINT_MAX, handle_transient_for, NULL);
+
/* Watch WM_NAME (= title of the window in compound text) property for legacy applications */
xcb_watch_wm_name(&prophs, 128, handle_windowname_change_legacy, NULL);
xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_CLASS);
xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_NAME);
xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_NORMAL_HINTS);
+ xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_TRANSIENT_FOR);
xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, atoms[_NET_WM_NAME]);
free(geom);
new->container = CUR_CELL;
new->workspace = new->container->workspace;
+ /* Minimum useful size for managed windows is 75x50 (primarily affects floating) */
+ width = max(width, 75);
+ height = max(height, 50);
+
new->frame = xcb_generate_id(conn);
new->child = child;
new->rect.width = width;
xcb_atom_t *atom;
xcb_get_property_reply_t *preply = xcb_get_property_reply(conn, wm_type_cookie, NULL);
if (preply != NULL && preply->value_len > 0 && (atom = xcb_get_property_value(preply))) {
- for (int i = 0; i < xcb_get_property_value_length(preply); i++) {
- if (atom[i] != atoms[_NET_WM_WINDOW_TYPE_DOCK])
- continue;
- LOG("Window is a dock.\n");
- new->dock = true;
- new->titlebar_position = TITLEBAR_OFF;
- new->force_reconfigure = true;
- new->container = NULL;
- SLIST_INSERT_HEAD(&(c_ws->screen->dock_clients), new, dock_clients);
- }
+ for (int i = 0; i < xcb_get_property_value_length(preply); i++)
+ if (atom[i] == atoms[_NET_WM_WINDOW_TYPE_DOCK]) {
+ LOG("Window is a dock.\n");
+ new->dock = true;
+ new->titlebar_position = TITLEBAR_OFF;
+ new->force_reconfigure = true;
+ new->container = NULL;
+ SLIST_INSERT_HEAD(&(c_ws->screen->dock_clients), new, dock_clients);
+ } else if (atom[i] == atoms[_NET_WM_WINDOW_TYPE_DIALOG]) {
+ /* Set the dialog window to automatically floating, will be used below */
+ new->floating = FLOATING_AUTO_ON;
+ LOG("dialog window, automatically floating\n");
+ }
}
if (new->dock) {
}
/* Insert into the currently active container, if it’s not a dock window */
- if (!new->dock) {
+ if (!new->dock && new->floating <= FLOATING_USER_OFF) {
/* Insert after the old active client, if existing. If it does not exist, the
container is empty and it does not matter, where we insert it */
if (old_focused != NULL && !old_focused->dock)
}
}
+ if (new->floating >= FLOATING_AUTO_ON) {
+ new->floating_rect.x = new->rect.x;
+ new->floating_rect.y = new->rect.y;
+ LOG("copying size from tiling (%d, %d) size (%d, %d)\n",
+ new->floating_rect.x, new->floating_rect.y,
+ new->floating_rect.width, new->floating_rect.height);
+
+ /* Make sure it is on top of the other windows */
+ xcb_raise_window(conn, new->frame);
+ }
+
new->initialized = true;
/* Check if the window already got the fullscreen hint set */