#include <xcb/xcb.h>
#include <xcb/xcb_event.h>
#include <xcb/xcb_ewmh.h>
+#include <xcb/xinerama.h>
#include "types.h"
#include "settings.h"
#include "messages.h"
err("another WM is already running\n");
}
- xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, BUTTON_MODIFIER);
- xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_2, BUTTON_MODIFIER);
- xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_3, BUTTON_MODIFIER);
+}
+
+void grab_buttons(void)
+{
+ xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, button_modifier);
+ xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_2, button_modifier);
+ xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_3, button_modifier);
}
void setup(void)
ewmh->_NET_WM_STATE,
ewmh->_NET_WM_STATE_FULLSCREEN,
ewmh->_NET_WM_WINDOW_TYPE,
+ ewmh->_NET_WM_WINDOW_TYPE_DOCK,
+ ewmh->_NET_WM_WINDOW_TYPE_NOTIFICATION,
ewmh->_NET_WM_WINDOW_TYPE_DIALOG,
ewmh->_NET_WM_WINDOW_TYPE_UTILITY,
ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR};
xcb_ewmh_set_supported(ewmh, default_screen, LENGTH(net_atoms), net_atoms);
- desk = make_desktop(DEFAULT_DESK_NAME);
- last_desk = NULL;
- desk_head = desk;
- desk_tail = desk;
- num_desktops++;
+ monitor_uid = desktop_uid = client_uid = 0;
+ mon = last_mon = mon_head = mon_tail = NULL;
+
+ bool xinerama_is_active = false;
+
+ if (xcb_get_extension_data(dpy, &xcb_xinerama_id)->present) {
+ xcb_xinerama_is_active_reply_t *xia = xcb_xinerama_is_active_reply(dpy, xcb_xinerama_is_active(dpy), NULL);
+ if (xia != NULL) {
+ xinerama_is_active = xia->state;
+ free(xia);
+ }
+ }
+
+ if (xinerama_is_active) {
+ xcb_xinerama_query_screens_reply_t *xsq = xcb_xinerama_query_screens_reply(dpy, xcb_xinerama_query_screens(dpy), NULL);
+ xcb_xinerama_screen_info_t *xsi = xcb_xinerama_query_screens_screen_info(xsq);
+ int n = xcb_xinerama_query_screens_screen_info_length(xsq);
+ PRINTF("number of monitors: %d\n", n);
+ for (int i = 0; i < n; i++) {
+ xcb_xinerama_screen_info_t info = xsi[i];
+ xcb_rectangle_t rect = (xcb_rectangle_t) {info.x_org, info.y_org, info.width, info.height};
+ add_monitor(&rect);
+ }
+ free(xsq);
+ } else {
+ warn("Xinerama is inactive");
+ xcb_rectangle_t rect = (xcb_rectangle_t) {0, 0, screen_width, screen_height};
+ add_monitor(&rect);
+ }
+
+ for (monitor_t *m = mon_head; m != NULL; m = m->next)
+ add_desktop(m, NULL);
ewmh_update_number_of_desktops();
ewmh_update_desktop_names();
load_settings();
run_autostart();
ewmh_update_wm_name();
- update_root_dimensions();
+ grab_buttons();
while (running) {