2 * focus.c - focus management
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "common/util.h"
27 extern AwesomeConf globalconf
;
29 static client_node_t
*
30 focus_get_node_by_client(Client
*c
)
34 for(node
= globalconf
.focus
; node
; node
= node
->next
)
42 focus_add_client(Client
*c
)
46 /* if we don't find this node, create a new one */
47 if(!(node
= focus_get_node_by_client(c
)))
49 node
= p_new(client_node_t
, 1);
52 else /* if we've got a node, detach it */
53 client_node_list_detach(&globalconf
.focus
, node
);
55 client_node_list_push(&globalconf
.focus
, node
);
59 focus_delete_client(Client
*c
)
61 client_node_t
*node
= focus_get_node_by_client(c
);
65 client_node_list_detach(&globalconf
.focus
, node
);
71 focus_get_latest_client_for_tags(Tag
**t
, int nindex
)
77 for(node
= globalconf
.focus
; node
; node
= node
->next
)
78 if(node
->client
&& !node
->client
->skip
)
79 for(tags
= t
; *tags
; tags
++)
80 if(is_client_tagged(node
->client
, *tags
))
92 focus_get_current_client(int screen
)
94 Tag
**curtags
= get_current_tags(screen
);
95 Client
*sel
= focus_get_latest_client_for_tags(curtags
, 0);
101 /** Jump in focus history stack
102 * \param screen Screen ID
103 * \param arg Integer argument
104 * \ingroup ui_callback
107 uicb_focus_history(int screen
, char *arg
)
119 curtags
= get_current_tags(screen
);
120 c
= focus_get_latest_client_for_tags(curtags
, i
);
123 client_focus(c
, screen
, False
);
129 uicb_focus_client_byname(int screen
, char *arg
)
132 Tag
**curtags
, **tag
;
136 curtags
= get_current_tags(screen
);
137 if((c
= get_client_byname(globalconf
.clients
, arg
)))
138 for(tag
= curtags
; *tag
; tag
++)
139 if(is_client_tagged(c
, *tag
))
140 client_focus(c
, screen
, False
);
145 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80