/**
* Stores a rectangle, for example the size of a window, the child window etc.
+ * It needs to be packed so that the compiler will not add any padding bytes.
+ * (it is used in src/ewmh.c for example)
*
*/
struct Rect {
- uint32_t x, y;
- uint32_t width, height;
-};
+ uint32_t x;
+ uint32_t y;
+ uint32_t width;
+ uint32_t height;
+} __attribute__((packed));
/**
* Defines a position in the table
*/
void ewmh_update_active_window(xcb_window_t window);
+/**
+ * Updates the workarea for each desktop.
+ *
+ * EWMH: Contains a geometry for each desktop. These geometries specify an area
+ * that is completely contained within the viewport. Work area SHOULD be used by
+ * desktop applications to place desktop icons appropriately.
+ *
+ */
+void ewmh_update_workarea();
+
#endif
#ifndef _I3_H
#define _I3_H
-#define NUM_ATOMS 20
+#define NUM_ATOMS 21
extern xcb_connection_t *global_conn;
extern xcb_key_symbols_t *keysyms;
WM_STATE,
WM_CLIENT_LEADER,
_NET_CURRENT_DESKTOP,
- _NET_ACTIVE_WINDOW
+ _NET_ACTIVE_WINDOW,
+ _NET_WORKAREA
};
extern unsigned int xcb_numlock_mask;
*
*/
#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
#include "data.h"
#include "table.h"
#include "i3.h"
#include "xcb.h"
+#include "util.h"
+#include "log.h"
/*
* Updates _NET_CURRENT_DESKTOP with the current desktop number.
xcb_change_property(global_conn, XCB_PROP_MODE_REPLACE, root,
atoms[_NET_ACTIVE_WINDOW], WINDOW, 32, 1, &window);
}
+
+/*
+ * Updates the workarea for each desktop.
+ *
+ * EWMH: Contains a geometry for each desktop. These geometries specify an area
+ * that is completely contained within the viewport. Work area SHOULD be used by
+ * desktop applications to place desktop icons appropriately.
+ *
+ */
+void ewmh_update_workarea() {
+ Workspace *ws;
+ int num_workspaces = 0, count = 0;
+ /* Get the number of workspaces */
+ TAILQ_FOREACH(ws, workspaces, workspaces)
+ num_workspaces++;
+ DLOG("Got %d workspaces\n", num_workspaces);
+ uint8_t *workarea = smalloc(sizeof(Rect) * num_workspaces);
+ TAILQ_FOREACH(ws, workspaces, workspaces) {
+ DLOG("storing %d: %dx%d with %d x %d\n", count, ws->rect.x, ws->rect.y, ws->rect.width, ws->rect.height);
+ memcpy(workarea + (sizeof(Rect) * count++), &(ws->rect), sizeof(Rect));
+ }
+ xcb_change_property(global_conn, XCB_PROP_MODE_REPLACE, root,
+ atoms[_NET_WORKAREA], CARDINAL, 32,
+ num_workspaces * (sizeof(Rect) / sizeof(uint32_t)),
+ workarea);
+ free(workarea);
+ xcb_flush(global_conn);
+}
REQUEST_ATOM(WM_CLIENT_LEADER);
REQUEST_ATOM(_NET_CURRENT_DESKTOP);
REQUEST_ATOM(_NET_ACTIVE_WINDOW);
+ REQUEST_ATOM(_NET_WORKAREA);
/* TODO: this has to be more beautiful somewhen */
int major, minor, error;
GET_ATOM(WM_CLIENT_LEADER);
GET_ATOM(_NET_CURRENT_DESKTOP);
GET_ATOM(_NET_ACTIVE_WINDOW);
+ GET_ATOM(_NET_WORKAREA);
xcb_property_set_handler(&prophs, atoms[_NET_WM_WINDOW_TYPE], UINT_MAX, handle_window_type, NULL);
/* TODO: In order to comply with EWMH, we have to watch _NET_WM_STRUT_PARTIAL */
#include "workspace.h"
#include "client.h"
#include "log.h"
+#include "ewmh.h"
/*
* Returns a pointer to the workspace with the given number (starting at 0),
}
DLOG("done\n");
+ ewmh_update_workarea();
+
return ws;
}
/* Copy the dimensions from the virtual screen */
memcpy(&(ws->rect), &(ws->screen->rect), sizeof(Rect));
+ ewmh_update_workarea();
+
/* Force reconfiguration for each client on that workspace */
FOR_TABLE(ws)
CIRCLEQ_FOREACH(client, &(ws->table[cols][rows]->clients), clients) {