2007-10-12 17:10:36 +02:00
|
|
|
/*
|
|
|
|
* uicb.c - user interface callbacks management
|
|
|
|
*
|
|
|
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-15 14:41:03 +01:00
|
|
|
#include "awesome.h"
|
2007-12-14 16:15:40 +01:00
|
|
|
#include "util.h"
|
2007-11-17 20:53:31 +01:00
|
|
|
#include "xutil.h"
|
2007-11-15 14:41:03 +01:00
|
|
|
#include "tag.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "statusbar.h"
|
2007-12-16 10:25:13 +01:00
|
|
|
#include "widget.h"
|
2007-12-15 20:32:49 +01:00
|
|
|
#include "focus.h"
|
2008-01-01 17:25:48 +01:00
|
|
|
#include "client.h"
|
2008-01-01 18:02:36 +01:00
|
|
|
#include "screen.h"
|
2007-11-15 14:41:03 +01:00
|
|
|
#include "layouts/tile.h"
|
2007-10-12 17:10:36 +02:00
|
|
|
|
2007-12-19 04:46:44 +01:00
|
|
|
extern AwesomeConf globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2007-12-15 16:34:22 +01:00
|
|
|
const NameFuncLink UicbList[] =
|
|
|
|
{
|
2007-11-21 15:06:30 +01:00
|
|
|
/* xutil.c */
|
2007-11-15 14:41:03 +01:00
|
|
|
{"spawn", uicb_spawn},
|
|
|
|
{"exec", uicb_exec},
|
|
|
|
/* client.c */
|
|
|
|
{"client_kill", uicb_client_kill},
|
|
|
|
{"client_moveresize", uicb_client_moveresize},
|
|
|
|
{"client_settrans", uicb_client_settrans},
|
|
|
|
{"client_swapnext", uicb_client_swapnext},
|
|
|
|
{"client_swapprev", uicb_client_swapprev},
|
|
|
|
/* tag.c */
|
|
|
|
{"client_tag", uicb_client_tag},
|
|
|
|
{"client_togglefloating", uicb_client_togglefloating},
|
|
|
|
{"tag_toggleview", uicb_tag_toggleview},
|
|
|
|
{"client_toggletag", uicb_client_toggletag},
|
|
|
|
{"tag_view", uicb_tag_view},
|
|
|
|
{"tag_viewprev_selected", uicb_tag_prev_selected},
|
|
|
|
{"tag_viewprev", uicb_tag_viewprev},
|
|
|
|
{"tag_viewnext", uicb_tag_viewnext},
|
2008-01-02 17:10:32 +01:00
|
|
|
{"tag_create", uicb_tag_create},
|
2007-11-15 14:41:03 +01:00
|
|
|
/* layout.c */
|
|
|
|
{"tag_setlayout", uicb_tag_setlayout},
|
|
|
|
{"client_focusnext", uicb_client_focusnext},
|
|
|
|
{"client_focusprev", uicb_client_focusprev},
|
|
|
|
{"client_togglemax", uicb_client_togglemax},
|
|
|
|
{"client_toggleverticalmax", uicb_client_toggleverticalmax},
|
|
|
|
{"client_togglehorizontalmax", uicb_client_togglehorizontalmax},
|
|
|
|
{"client_zoom", uicb_client_zoom},
|
|
|
|
/* layouts/tile.c */
|
|
|
|
{"tag_setmwfact", uicb_tag_setmwfact},
|
|
|
|
{"tag_setnmaster", uicb_tag_setnmaster},
|
|
|
|
{"tag_setncol", uicb_tag_setncol},
|
|
|
|
/* screen.c */
|
2007-12-13 13:59:46 +01:00
|
|
|
{"screen_focus", uicb_screen_focus},
|
2007-11-15 14:41:03 +01:00
|
|
|
{"client_movetoscreen", uicb_client_movetoscreen},
|
|
|
|
/* awesome.c */
|
|
|
|
{"quit", uicb_quit},
|
|
|
|
/* statusbar.c */
|
2007-12-14 15:52:52 +01:00
|
|
|
{"statusbar_toggle", uicb_statusbar_toggle},
|
2007-11-15 14:41:03 +01:00
|
|
|
/* mouse.c */
|
|
|
|
{"client_movemouse", uicb_client_movemouse},
|
|
|
|
{"client_resizemouse", uicb_client_resizemouse},
|
2007-12-15 20:32:49 +01:00
|
|
|
/* focus.c */
|
|
|
|
{"focus_history", uicb_focus_history},
|
2007-12-23 16:16:02 +01:00
|
|
|
{"focus_client_byname", uicb_focus_client_byname},
|
2007-12-16 10:25:13 +01:00
|
|
|
/* widgets.c */
|
|
|
|
{"widget_tell", uicb_widget_tell},
|
2007-11-15 14:41:03 +01:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2007-10-12 17:10:36 +02:00
|
|
|
|
2007-12-14 16:07:34 +01:00
|
|
|
static int
|
2007-12-19 04:46:44 +01:00
|
|
|
run_uicb(char *cmd, AwesomeConf *awesomeconf __attribute ((unused)))
|
2007-10-12 17:10:36 +02:00
|
|
|
{
|
2007-12-13 02:32:16 +01:00
|
|
|
char *p;
|
2007-10-15 19:11:19 +02:00
|
|
|
const char *arg;
|
2007-12-16 10:25:13 +01:00
|
|
|
char *argcpy;
|
2007-12-13 02:32:16 +01:00
|
|
|
int screen, len;
|
2007-12-16 02:45:38 +01:00
|
|
|
void (*uicb) (int, const char *);
|
2007-10-12 17:10:36 +02:00
|
|
|
|
2007-12-13 02:32:16 +01:00
|
|
|
len = strlen(cmd);
|
|
|
|
p = strtok(cmd, " ");
|
2007-12-13 02:37:30 +01:00
|
|
|
if (!p){
|
|
|
|
warn("Ignoring malformed command\n");
|
2007-10-12 17:10:36 +02:00
|
|
|
return -1;
|
2007-12-13 02:37:30 +01:00
|
|
|
}
|
2007-12-12 08:41:57 +01:00
|
|
|
screen = atoi(cmd);
|
2007-12-18 09:02:08 +01:00
|
|
|
if(screen >= get_screen_count() || screen < 0){
|
2007-12-13 02:37:30 +01:00
|
|
|
warn("Invalid screen specified: %i\n", screen);
|
2007-10-12 17:10:36 +02:00
|
|
|
return -1;
|
2007-12-13 02:37:30 +01:00
|
|
|
}
|
2007-10-12 17:10:36 +02:00
|
|
|
|
2007-12-13 02:32:16 +01:00
|
|
|
p = strtok(NULL, " ");
|
2007-12-13 02:37:30 +01:00
|
|
|
if (!p){
|
|
|
|
warn("Ignoring malformed command.\n");
|
2007-12-13 02:32:16 +01:00
|
|
|
return -1;
|
2007-12-13 02:37:30 +01:00
|
|
|
}
|
2007-12-13 02:32:16 +01:00
|
|
|
uicb = name_func_lookup(p, UicbList);
|
2007-12-13 02:37:30 +01:00
|
|
|
if (!uicb){
|
|
|
|
warn("Unknown UICB function: %s.\n", p);
|
2007-12-13 02:32:16 +01:00
|
|
|
return -1;
|
2007-12-13 02:37:30 +01:00
|
|
|
}
|
2007-10-12 17:10:36 +02:00
|
|
|
|
2007-12-13 02:32:16 +01:00
|
|
|
if (p+strlen(p) < cmd+len)
|
2007-12-16 10:25:13 +01:00
|
|
|
{
|
2007-12-13 02:32:16 +01:00
|
|
|
arg = p + strlen(p) + 1;
|
2007-12-16 10:25:13 +01:00
|
|
|
/* Allow our callees to modify this string. */
|
|
|
|
argcpy = p_new(char, strlen(arg)+1);
|
|
|
|
strncpy(argcpy, arg, strlen(arg));
|
|
|
|
uicb(screen, argcpy);
|
|
|
|
p_delete(&argcpy);
|
|
|
|
}
|
2007-10-12 17:10:36 +02:00
|
|
|
else
|
2007-12-16 10:25:13 +01:00
|
|
|
uicb(screen, NULL);
|
2007-10-12 17:10:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2007-12-13 02:32:16 +01:00
|
|
|
|
2007-12-14 16:07:34 +01:00
|
|
|
int
|
2007-12-16 02:45:38 +01:00
|
|
|
parse_control(char *cmd)
|
2007-12-14 16:07:34 +01:00
|
|
|
{
|
|
|
|
char *p, *curcmd = cmd;
|
|
|
|
|
|
|
|
if(!a_strlen(cmd))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
while((p = strchr(curcmd, '\n')))
|
|
|
|
{
|
|
|
|
*p = '\0';
|
2007-12-16 02:45:38 +01:00
|
|
|
run_uicb(curcmd, &globalconf);
|
2007-12-14 16:07:34 +01:00
|
|
|
curcmd = p + 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-13 02:32:16 +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
|