Exemple #1
0
void window_manage(Window win)
{
	XWindowAttributes attrib;
	gboolean no_manage = FALSE;
	Window icon_win = None;
	grab_server(TRUE);
	if(xqueue_exists_local(check_unmap, &win)) {
		wm_debug("Trying to manage unmapped window. Aborting that.");
		no_manage = TRUE;
	} else if(!XGetWindowAttributes(t_display, win, &attrib))
		no_manage = TRUE;
	else {
		XWMHints *wmhints;
		if((wmhints = XGetWMHints(t_display, win))) {
			if((wmhints->flags & StateHint) && wmhints->initial_state == WithdrawnState) {
				if(wmhints->flags & IconWindowHint)
					icon_win = wmhints->icon_window;
			}
			XFree(wmhints);
		}
	}
	if(!no_manage) {
		if(attrib.override_redirect) {
			wm_debug("not managing override redirect window 0x%x", win);
			grab_server(FALSE);
		} else
			client_manage(win);
	} else {
		grab_server(FALSE);
		wm_debug("FAILED to manage window 0x%x", win);
	}
}
Exemple #2
0
void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal)
{
    gint i;

    if (self->mapped) {
        /* activate the prompt */
        OBT_PROP_MSG(ob_screen, self->super.window, NET_ACTIVE_WINDOW,
                     1, /* from an application.. */
                     event_time(),
                     0,
                     0, 0);
        return;
    }

    /* set the focused button (if not found then the first button is used) */
    self->focus = &self->button[0];
    for (i = 0; i < self->n_buttons; ++i)
        if (self->button[i].result == self->default_result) {
            self->focus = &self->button[i];
            break;
        }

    if (parent) {
        Atom states[1];
        gint nstates;
        Window p;
        XWMHints h;

        if (parent->group) {
            /* make it transient for the window's group */
            h.flags = WindowGroupHint;
            h.window_group = parent->group->leader;
            p = obt_root(ob_screen);
        }
        else {
            /* make it transient for the window directly */
            h.flags = 0;
            p = parent->window;
        }

        XSetWMHints(obt_display, self->super.window, &h);
        OBT_PROP_SET32(self->super.window, WM_TRANSIENT_FOR, WINDOW, p);

        states[0] = OBT_PROP_ATOM(NET_WM_STATE_MODAL);
        nstates = (modal ? 1 : 0);
        OBT_PROP_SETA32(self->super.window, NET_WM_STATE, ATOM,
                        states, nstates);
    }
    else
        OBT_PROP_ERASE(self->super.window, WM_TRANSIENT_FOR);

    /* set up the dialog and render it */
    prompt_layout(self);
    render_all(self);

    client_manage(self->super.window, self);

    self->mapped = TRUE;
}
Exemple #3
0
void event_maprequest( xcb_generic_event_t* e ) {
    printf( "yawn: maprequest\n" );

    xcb_map_request_event_t* ev = (xcb_map_request_event_t*)e;
    stack_add( ev->window );
    client_manage( ev->window );
    stack_tile();
    window_current_update();
}
Exemple #4
0
/** The map request event handler.
 * \param ev The event.
 */
static void
event_handle_maprequest(xcb_map_request_event_t *ev)
{
    client_t *c;
    xcb_get_window_attributes_cookie_t wa_c;
    xcb_get_window_attributes_reply_t *wa_r;
    xcb_get_geometry_cookie_t geom_c;
    xcb_get_geometry_reply_t *geom_r;

    wa_c = xcb_get_window_attributes_unchecked(globalconf.connection, ev->window);

    if(!(wa_r = xcb_get_window_attributes_reply(globalconf.connection, wa_c, NULL)))
        return;

    if(wa_r->override_redirect)
        goto bailout;

    if(xembed_getbywin(&globalconf.embedded, ev->window))
    {
        xcb_map_window(globalconf.connection, ev->window);
        xembed_window_activate(globalconf.connection, ev->window);
    }
    else if((c = client_getbywin(ev->window)))
    {
        /* Check that it may be visible, but not asked to be hidden */
        if(client_on_selected_tags(c) && !c->hidden)
        {
            lua_State *L = globalconf_get_lua_State();
            luaA_object_push(L, c);
            client_set_minimized(L, -1, false);
            lua_pop(L, 1);
            /* it will be raised, so just update ourself */
            client_raise(c);
        }
    }
    else
    {
        geom_c = xcb_get_geometry_unchecked(globalconf.connection, ev->window);

        if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL)))
        {
            goto bailout;
        }

        client_manage(ev->window, geom_r, wa_r);

        p_delete(&geom_r);
    }

bailout:
    p_delete(&wa_r);
}
Exemple #5
0
void window_manage(Window win)
{
    XWindowAttributes attrib;
    gboolean no_manage = FALSE;
    gboolean is_dockapp = FALSE;
    Window icon_win = None;

    grab_server(TRUE);

    /* check if it has already been unmapped by the time we started
       mapping. the grab does a sync so we don't have to here */
    if (xqueue_exists_local(check_unmap, &win)) {
        ob_debug("Trying to manage unmapped window. Aborting that.");
        no_manage = TRUE;
    }
    else if (!XGetWindowAttributes(obt_display, win, &attrib))
        no_manage = TRUE;
    else {
        XWMHints *wmhints;

        /* is the window a docking app */
        is_dockapp = FALSE;
        if ((wmhints = XGetWMHints(obt_display, win))) {
            if ((wmhints->flags & StateHint) &&
                wmhints->initial_state == WithdrawnState)
            {
                if (wmhints->flags & IconWindowHint)
                    icon_win = wmhints->icon_window;
                is_dockapp = TRUE;
            }
            XFree(wmhints);
        }
    }

    if (!no_manage) {
        if (attrib.override_redirect) {
            ob_debug("not managing override redirect window 0x%x", win);
            grab_server(FALSE);
        }
        else if (is_dockapp) {
            if (!icon_win)
                icon_win = win;
            dock_manage(icon_win, win);
        }
        else
            client_manage(win, NULL);
    }
    else {
        grab_server(FALSE);
        ob_debug("FAILED to manage window 0x%x", win);
    }
}
Exemple #6
0
/** MapRequest handle event
 * \param ev XMapRequestEvent pointer
*/
static void
maprequest(XMapRequestEvent *ev)
{
     XWindowAttributes at;
     Systray *s;

     CHECK(XGetWindowAttributes(dpy, ev->window, &at));
     CHECK(!at.override_redirect);

     if((s = systray_find(ev->window)))
     {
          ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
          systray_update();
     }
     else if(!client_gb_win(ev->window))
          client_manage(ev->window, &at, True);

     return;
}
/** Scan X to find windows to manage.
 */
static void
scan(xcb_query_tree_cookie_t tree_c[])
{
    int i, x_screen, tree_c_len;
    const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
    xcb_query_tree_reply_t *tree_r;
    xcb_window_t *wins = NULL;
    xcb_get_window_attributes_reply_t *attr_r;
    xcb_get_geometry_reply_t *geom_r;
    long state;

    for(x_screen = 0; x_screen < screen_max; x_screen++)
    {
        tree_r = xcb_query_tree_reply(globalconf.connection,
                                      tree_c[x_screen],
                                      NULL);

        if(!tree_r)
            continue;

        /* Get the tree of the children windows of the current root window */
        if(!(wins = xcb_query_tree_children(tree_r)))
            fatal("cannot get tree children");

        tree_c_len = xcb_query_tree_children_length(tree_r);
        xcb_get_window_attributes_cookie_t attr_wins[tree_c_len];
        xcb_get_property_cookie_t state_wins[tree_c_len];

        for(i = 0; i < tree_c_len; i++)
        {
            attr_wins[i] = xcb_get_window_attributes_unchecked(globalconf.connection,
                                                               wins[i]);

            state_wins[i] = window_state_get_unchecked(wins[i]);
        }

        xcb_get_geometry_cookie_t *geom_wins[tree_c_len];

        for(i = 0; i < tree_c_len; i++)
        {
            attr_r = xcb_get_window_attributes_reply(globalconf.connection,
                                                     attr_wins[i],
                                                     NULL);

            state = window_state_get_reply(state_wins[i]);

            if(!attr_r || attr_r->override_redirect
               || attr_r->map_state == XCB_MAP_STATE_UNMAPPED
               || state == XCB_ICCCM_WM_STATE_WITHDRAWN)
            {
                geom_wins[i] = NULL;
                p_delete(&attr_r);
                continue;
            }

            p_delete(&attr_r);

            /* Get the geometry of the current window */
            geom_wins[i] = p_alloca(xcb_get_geometry_cookie_t, 1);
            *(geom_wins[i]) = xcb_get_geometry_unchecked(globalconf.connection, wins[i]);
        }

        for(i = 0; i < tree_c_len; i++)
        {
            if(!geom_wins[i] || !(geom_r = xcb_get_geometry_reply(globalconf.connection,
                                                                  *(geom_wins[i]), NULL)))
                continue;

            /* The window can be mapped, so force it to be undrawn for startup */
            xcb_unmap_window(globalconf.connection, wins[i]);

            client_manage(wins[i], geom_r,
                          phys_screen_getbycoord(geom_r->x, geom_r->y, geom_r->root),
                          x_screen, true);

            p_delete(&geom_r);
        }

        p_delete(&tree_r);
    }
}
Exemple #8
0
/** Scan X to find windows to manage.
 */
static void
scan(xcb_query_tree_cookie_t tree_c)
{
    int i, tree_c_len;
    xcb_query_tree_reply_t *tree_r;
    xcb_window_t *wins = NULL;
    xcb_get_window_attributes_reply_t *attr_r;
    xcb_get_geometry_reply_t *geom_r;
    long state;

    tree_r = xcb_query_tree_reply(globalconf.connection,
                                  tree_c,
                                  NULL);

    if(!tree_r)
        return;

    /* Get the tree of the children windows of the current root window */
    if(!(wins = xcb_query_tree_children(tree_r)))
        fatal("cannot get tree children");

    tree_c_len = xcb_query_tree_children_length(tree_r);
    xcb_get_window_attributes_cookie_t attr_wins[tree_c_len];
    xcb_get_property_cookie_t state_wins[tree_c_len];

    for(i = 0; i < tree_c_len; i++)
    {
        attr_wins[i] = xcb_get_window_attributes_unchecked(globalconf.connection,
                       wins[i]);

        state_wins[i] = xwindow_get_state_unchecked(wins[i]);
    }

    xcb_get_geometry_cookie_t *geom_wins[tree_c_len];

    for(i = 0; i < tree_c_len; i++)
    {
        attr_r = xcb_get_window_attributes_reply(globalconf.connection,
                 attr_wins[i],
                 NULL);

        state = xwindow_get_state_reply(state_wins[i]);

        if(!attr_r || attr_r->override_redirect
                || attr_r->map_state == XCB_MAP_STATE_UNMAPPED
                || state == XCB_ICCCM_WM_STATE_WITHDRAWN)
        {
            geom_wins[i] = NULL;
            p_delete(&attr_r);
            continue;
        }

        p_delete(&attr_r);

        /* Get the geometry of the current window */
        geom_wins[i] = p_alloca(xcb_get_geometry_cookie_t, 1);
        *(geom_wins[i]) = xcb_get_geometry_unchecked(globalconf.connection, wins[i]);
    }

    for(i = 0; i < tree_c_len; i++)
    {
        if(!geom_wins[i] || !(geom_r = xcb_get_geometry_reply(globalconf.connection,
                                       *(geom_wins[i]), NULL)))
            continue;

        client_manage(wins[i], geom_r, true);

        p_delete(&geom_r);
    }

    p_delete(&tree_r);
}
Exemple #9
0
/** Scan if there are windows on X
 *  for manage it
*/
static void
scan(void)
{
     uint n;
     XWindowAttributes wa;
     Window usl, usl2, *w = NULL;
     Atom rt;
     int s, rf, tag = -1, screen = -1, free = -1, i;
     ulong ir, il;
     uchar *ret;
     Client *c;

     s = screen_count();

     if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n))
          for(i = n - 1; i != -1; --i)
          {
               XGetWindowAttributes(dpy, w[i], &wa);

               if(!wa.override_redirect && wa.map_state == IsViewable)
               {
                    if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_TAG"), 0, 32,
                                   False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
                    {
                         tag = *ret;
                         XFree(ret);
                    }

                    if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_SCREEN"), 0, 32,
                                   False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
                    {
                         screen = *ret;
                         XFree(ret);
                    }

                    if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_ISFREE"), 0, 32,
                                   False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
                    {
                         free = *ret;
                         XFree(ret);
                    }

                    c = client_manage(w[i], &wa, False);

                    if(tag != -1 && tag != MAXTAG + 1)
                         c->tag = tag;
                    if(screen != -1 && screen <= s - 1)
                         c->screen = screen;
                    if(free != -1)
                         c->flags |= (free) ? FreeFlag : 0;

                    client_update_attributes(c);
               }
          }

     /* Set update layout request */
     for(c = clients; c; c = c->next)
     {
          if(c->tag > (uint)conf.ntag[c->screen])
               c->tag = conf.ntag[c->screen];
          tags[c->screen][c->tag].request_update = True;
     }

     for(i = 0; i < s; ++i)
          arrange(i, True);

     XFree(w);

     return;
}