2007-12-14 21:51:54 +01:00
|
|
|
/*
|
|
|
|
* focus.c - focus management
|
|
|
|
*
|
2008-01-02 16:59:43 +01:00
|
|
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
2007-12-14 21:51:54 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-02-13 06:53:08 +01:00
|
|
|
#include "focus.h"
|
2008-05-25 18:08:49 +02:00
|
|
|
#include "cnode.h"
|
2008-06-09 16:30:46 +02:00
|
|
|
#include "workspace.h"
|
2007-12-14 21:51:54 +01:00
|
|
|
|
2008-05-24 08:59:27 +02:00
|
|
|
extern awesome_t globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2008-05-23 22:40:17 +02:00
|
|
|
/** Push the client at the beginning of the client focus history stack.
|
|
|
|
* \param c The client to push.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
focus_client_push(client_t *c)
|
|
|
|
{
|
2008-05-25 18:08:49 +02:00
|
|
|
client_node_t *node = client_node_client_add(&globalconf.focus, c);
|
2008-01-12 23:10:59 +01:00
|
|
|
client_node_list_push(&globalconf.focus, node);
|
2007-12-14 21:51:54 +01:00
|
|
|
}
|
|
|
|
|
2008-05-23 22:40:17 +02:00
|
|
|
/** Append the client at the end of the client focus history stack.
|
|
|
|
* \param c The client to append.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
focus_client_append(client_t *c)
|
|
|
|
{
|
2008-05-25 18:08:49 +02:00
|
|
|
client_node_t *node = client_node_client_add(&globalconf.focus, c);
|
2008-05-23 22:40:17 +02:00
|
|
|
client_node_list_append(&globalconf.focus, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove a client from focus history.
|
|
|
|
* \param c The client.
|
|
|
|
*/
|
2007-12-14 21:51:54 +01:00
|
|
|
void
|
2008-05-23 22:40:17 +02:00
|
|
|
focus_client_delete(client_t *c)
|
2007-12-14 21:51:54 +01:00
|
|
|
{
|
2008-05-25 18:08:49 +02:00
|
|
|
client_node_t *node = client_node_client_getby(globalconf.focus, c);
|
2007-12-28 12:39:40 +01:00
|
|
|
|
2008-01-12 23:10:59 +01:00
|
|
|
if(node)
|
2007-12-15 08:06:20 +01:00
|
|
|
{
|
2008-01-12 23:10:59 +01:00
|
|
|
client_node_list_detach(&globalconf.focus, node);
|
|
|
|
p_delete(&node);
|
2007-12-15 08:06:20 +01:00
|
|
|
}
|
2007-12-14 21:51:54 +01:00
|
|
|
}
|
|
|
|
|
2008-04-11 11:35:11 +02:00
|
|
|
static client_t *
|
2008-06-09 16:30:46 +02:00
|
|
|
focus_get_latest_client_for_workspace(workspace_t *ws, int nindex)
|
2007-12-14 21:51:54 +01:00
|
|
|
{
|
2008-01-12 23:10:59 +01:00
|
|
|
client_node_t *node;
|
2007-12-28 14:27:15 +01:00
|
|
|
int i = 0;
|
2007-12-14 21:51:54 +01:00
|
|
|
|
2008-01-12 23:10:59 +01:00
|
|
|
for(node = globalconf.focus; node; node = node->next)
|
2008-06-09 18:24:12 +02:00
|
|
|
if(node->client && !node->client->skip && !node->client->ishidden)
|
2008-06-09 16:30:46 +02:00
|
|
|
if(workspace_client_get(node->client) == ws)
|
|
|
|
if(i-- == nindex)
|
|
|
|
return node->client;
|
2007-12-14 21:51:54 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-06-09 16:30:46 +02:00
|
|
|
/** Get the latest focused client on a workspace.
|
|
|
|
* \param ws The workspace.
|
2008-05-23 22:40:17 +02:00
|
|
|
* \return A pointer to an existing client.
|
|
|
|
*/
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *
|
2008-06-09 16:30:46 +02:00
|
|
|
focus_client_getcurrent(workspace_t *ws)
|
2007-12-27 19:57:46 +01:00
|
|
|
{
|
2008-06-09 16:30:46 +02:00
|
|
|
return focus_get_latest_client_for_workspace(ws, 0);
|
2007-12-27 19:57:46 +01:00
|
|
|
}
|
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|