client: implement maybevisible(), and use it for maprequest
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4b2293d43d
commit
8d1f20c5ad
30
client.c
30
client.c
|
@ -123,9 +123,9 @@ window_isprotodel(xcb_window_t win)
|
|||
* \return true if the client is visible, false otherwise.
|
||||
*/
|
||||
bool
|
||||
client_isvisible(client_t *c, int screen)
|
||||
client_maybevisible(client_t *c, int screen)
|
||||
{
|
||||
if(c && !c->ishidden && c->screen == screen)
|
||||
if(c->screen == screen)
|
||||
{
|
||||
tag_array_t *tags = &globalconf.screens[screen].tags;
|
||||
for(int i = 0; i < tags->len; i++)
|
||||
|
@ -135,6 +135,18 @@ client_isvisible(client_t *c, int screen)
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if a client is tagged
|
||||
* with one of the tags of the specified screen and is not hidden.
|
||||
* \param c The client to check.
|
||||
* \param screen Virtual screen number.
|
||||
* \return true if the client is visible, false otherwise.
|
||||
*/
|
||||
bool
|
||||
client_isvisible(client_t *c, int screen)
|
||||
{
|
||||
return (!c->ishidden && client_maybevisible(c, screen));
|
||||
}
|
||||
|
||||
/** Get a client by its window.
|
||||
* \param w The client window to find.
|
||||
* \return A client pointer if found, NULL otherwise.
|
||||
|
@ -217,19 +229,7 @@ client_ban(client_t *c)
|
|||
static void
|
||||
client_focus(client_t *c)
|
||||
{
|
||||
bool istagged = false;
|
||||
tag_array_t *tags = &globalconf.screens[c->screen].tags;
|
||||
|
||||
/* Just check if the client is tagged with at least one visible tag.
|
||||
* If so, we can give it the focus. */
|
||||
for(int i = 0; i < tags->len; i++)
|
||||
if(tags->tab[i]->selected && is_client_tagged(c, tags->tab[i]))
|
||||
{
|
||||
istagged = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!istagged)
|
||||
if(!client_maybevisible(c, c->screen))
|
||||
return;
|
||||
|
||||
/* unfocus current selected client */
|
||||
|
|
1
client.h
1
client.h
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "structs.h"
|
||||
|
||||
bool client_maybevisible(client_t *, int);
|
||||
bool client_isvisible(client_t *, int);
|
||||
client_t * client_getbywin(xcb_window_t);
|
||||
void client_setlayer(client_t *, layer_t);
|
||||
|
|
3
event.c
3
event.c
|
@ -458,8 +458,9 @@ event_handle_maprequest(void *data __attribute__ ((unused)),
|
|||
}
|
||||
else if((c = client_getbywin(ev->window)))
|
||||
{
|
||||
if(client_isvisible(c, c->screen))
|
||||
if(client_maybevisible(c, c->screen))
|
||||
{
|
||||
c->ishidden = false;
|
||||
xcb_map_window(globalconf.connection, ev->window);
|
||||
/* it will be raised, so just update ourself */
|
||||
client_raise(c);
|
||||
|
|
Loading…
Reference in New Issue