コード例 #1
0
ファイル: xcb_help.c プロジェクト: nathan-hoad/howm
/**
* @brief Create the EWMH connection, request all of the atoms and set some
* sensible defaults for them.
*/
void setup_ewmh(void)
{
	xcb_ewmh_coordinates_t viewport[] = { {0, 0} };
	xcb_ewmh_geometry_t workarea[] = { {0, conf.bar_bottom ? 0 : wss[cw].bar_height,
	screen_width, screen_height - wss[cw].bar_height} };
	ewmh = calloc(1, sizeof(xcb_ewmh_connection_t));
	if (!ewmh) {
		log_err("Unable to create ewmh connection\n");
		exit(EXIT_FAILURE);
	}
	if (xcb_ewmh_init_atoms_replies(ewmh, xcb_ewmh_init_atoms(dpy, ewmh), NULL) == 0)
		log_err("Couldn't initialise ewmh atoms");
	xcb_atom_t ewmh_net_atoms[] = { ewmh->_NET_SUPPORTED,
					ewmh->_NET_SUPPORTING_WM_CHECK,
					ewmh->_NET_DESKTOP_VIEWPORT,
					ewmh->_NET_WM_NAME,
					ewmh->_NET_WM_STATE,
					ewmh->_NET_CLOSE_WINDOW,
					ewmh->_NET_WM_STATE_FULLSCREEN,
					ewmh->_NET_CURRENT_DESKTOP,
					ewmh->_NET_NUMBER_OF_DESKTOPS,
					ewmh->_NET_DESKTOP_GEOMETRY,
					ewmh->_NET_WORKAREA,
					ewmh->_NET_ACTIVE_WINDOW };
	xcb_ewmh_set_supported(ewmh, 0, LENGTH(ewmh_net_atoms), ewmh_net_atoms);
	xcb_ewmh_set_supporting_wm_check(ewmh, 0, screen->root);
	xcb_ewmh_set_desktop_viewport(ewmh, 0, LENGTH(viewport), viewport);
	xcb_ewmh_set_wm_name(ewmh, 0, strlen("howm"), "howm");
	xcb_ewmh_set_current_desktop(ewmh, 0, cw);
	xcb_ewmh_set_number_of_desktops(ewmh, 0, WORKSPACES);
	xcb_ewmh_set_workarea(ewmh, 0, LENGTH(workarea), workarea);
	xcb_ewmh_set_desktop_geometry(ewmh, 0, screen_width, screen_height);
}
コード例 #2
0
ファイル: ewmh.c プロジェクト: c00kiemon5ter/wm
void ewmh_set_supported_atoms(void)
{
    xcb_atom_t ewmh_atoms[] = {
        cfg.ewmh->_NET_SUPPORTED,
        cfg.ewmh->_NET_WM_STATE,
        cfg.ewmh->_NET_WM_STATE_FULLSCREEN,
        cfg.ewmh->_NET_WM_WINDOW_TYPE,
        cfg.ewmh->_NET_WM_WINDOW_TYPE_DIALOG,
        cfg.ewmh->_NET_WM_WINDOW_TYPE_UTILITY,
        cfg.ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR,
        cfg.ewmh->_NET_DESKTOP_NAMES,
        cfg.ewmh->_NET_NUMBER_OF_DESKTOPS,
        cfg.ewmh->_NET_CURRENT_DESKTOP,
        cfg.ewmh->_NET_CLIENT_LIST,
        cfg.ewmh->_NET_ACTIVE_WINDOW,
    };
    xcb_ewmh_set_supported(cfg.ewmh, cfg.def_screen, LENGTH(ewmh_atoms), ewmh_atoms);
}
コード例 #3
0
ファイル: bspwm.c プロジェクト: c00kiemon5ter/bspwm
void setup(void)
{
    ewmh_init();
    screen = xcb_setup_roots_iterator(xcb_get_setup(dpy)).data;
    if (!screen)
        die("error: cannot aquire screen\n");

    screen_width = screen->width_in_pixels;
    screen_height = screen->height_in_pixels;
    root_depth = screen->root_depth;

    xcb_atom_t net_atoms[] = {ewmh->_NET_SUPPORTED,
                              ewmh->_NET_DESKTOP_NAMES,
                              ewmh->_NET_NUMBER_OF_DESKTOPS,
                              ewmh->_NET_CURRENT_DESKTOP,
                              ewmh->_NET_CLIENT_LIST,
                              ewmh->_NET_ACTIVE_WINDOW,
                              ewmh->_NET_WM_STATE,
                              ewmh->_NET_WM_STATE_FULLSCREEN,
                              ewmh->_NET_WM_WINDOW_TYPE,
                              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++;

    ewmh_update_number_of_desktops();
    ewmh_update_desktop_names();
    rule_head = make_rule();
    frozen_pointer = make_pointer_state();
    split_mode = MODE_AUTOMATIC;
}
コード例 #4
0
ファイル: atoms.c プロジェクト: jon-turney/libxcwm
int
_xcwm_atoms_init(xcwm_context_t *context)
{
    xcb_intern_atom_cookie_t *atom_cookies;
    xcb_generic_error_t *error;

    /* Initialization for the xcb_ewmh connection and EWMH atoms */
    atom_cookies = xcb_ewmh_init_atoms(context->conn,
                                       &context->atoms.ewmh_conn);
    if (!xcb_ewmh_init_atoms_replies(&context->atoms.ewmh_conn,
                                     atom_cookies, &error)) {
        return error->major_code;;
    }

    /* Set the _NET_SUPPORTED atom for this context
     * Most of these are defined as MUSTs in the
     * EWMH standards for window managers.
     * NOTE: Starting with only a limited set of _NET_WM_STATE. This
     * may be expanded. */
    xcb_atom_t supported[] =
        {
            context->atoms.ewmh_conn.WM_PROTOCOLS,
            context->atoms.ewmh_conn._NET_SUPPORTED,
            context->atoms.ewmh_conn._NET_SUPPORTING_WM_CHECK,
            context->atoms.ewmh_conn._NET_CLOSE_WINDOW,
            context->atoms.ewmh_conn._NET_WM_NAME,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_TOOLBAR,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_MENU,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_UTILITY,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_SPLASH,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_DIALOG,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_POPUP_MENU,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_TOOLTIP,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_NOTIFICATION,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_COMBO,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_DND,
            context->atoms.ewmh_conn._NET_WM_WINDOW_TYPE_NORMAL,
            context->atoms.ewmh_conn._NET_WM_STATE,
            context->atoms.ewmh_conn._NET_WM_STATE_MODAL,
            context->atoms.ewmh_conn._NET_WM_STATE_HIDDEN
        };

    xcb_ewmh_set_supported(&context->atoms.ewmh_conn,
                           context->conn_screen,
                           21,  /* Length of supported[] */
                           supported);

    /* Used erroneously instead of _NET_WM_WINDOW_TYPE_SPLASH by some applications */
    context->atoms.net_wm_window_type_splashscreen = _xcwm_atom_get(context, "_NET_WM_WINDOW_TYPE_SPLASHSCREEN");

    /* Get the ICCCM atoms we need that are not included in the
     * xcb_ewmh_connection_t. */
    _xcwm_atom_register(context, "_NET_WM_NAME",           set_window_name,       XCWM_EVENT_WINDOW_NAME);
    _xcwm_atom_register(context, "WM_NAME",                set_window_name,       XCWM_EVENT_WINDOW_NAME);
    _xcwm_atom_register(context, "_NET_WM_WINDOW_TYPE",    setup_window_type,     XCWM_EVENT_WINDOW_APPEARANCE);
    _xcwm_atom_register(context, "WM_NORMAL_HINTS",        set_window_size_hints, 0);
    _xcwm_atom_register(context, "_NET_WM_WINDOW_OPACITY", set_window_opacity,    XCWM_EVENT_WINDOW_APPEARANCE);

    /* WM_DELETE_WINDOW atom */
    context->atoms.wm_delete_window_atom = _xcwm_atom_get(context, "WM_DELETE_WINDOW");

    if (!check_wm_cm_owner(context)) {
        return XCB_WINDOW;
    }
    create_wm_cm_window(context);

    /* WM_STATE atom */
    context->atoms.wm_state_atom = _xcwm_atom_get(context, "WM_STATE");

    return 0;
}
コード例 #5
0
ファイル: bspwm.c プロジェクト: sunaku/bspwm
void setup(void)
{
    ewmh_init();
    screen = xcb_setup_roots_iterator(xcb_get_setup(dpy)).data;
    if (!screen)
        err("error: cannot aquire screen\n");

    screen_width = screen->width_in_pixels;
    screen_height = screen->height_in_pixels;
    root_depth = screen->root_depth;

    xcb_atom_t net_atoms[] = {ewmh->_NET_SUPPORTED,
                              ewmh->_NET_DESKTOP_NAMES,
                              ewmh->_NET_NUMBER_OF_DESKTOPS,
                              ewmh->_NET_CURRENT_DESKTOP,
                              ewmh->_NET_CLIENT_LIST,
                              ewmh->_NET_ACTIVE_WINDOW,
                              ewmh->_NET_WM_DESKTOP,
                              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);

    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();
    rule_head = make_rule();
    frozen_pointer = make_pointer_state();
    get_pointer_position(&pointer_position);
    split_mode = MODE_AUTOMATIC;
}