action.c for the Openbox window manager
Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003 Ben Jansens
+ Copyright (c) 2003-2007 Dana Jansens
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
#include "config.h"
#include "mainloop.h"
#include "startupnotify.h"
+#include "gettext.h"
#include <glib.h>
{
if (config_focus_follow)
if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
- grab_pointer(TRUE, OB_CURSOR_NONE);
+ grab_pointer(TRUE, FALSE, OB_CURSOR_NONE);
}
inline void client_action_end(union ActionData *data)
if (config_focus_follow)
if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
if (!data->any.button) {
- grab_pointer(FALSE, OB_CURSOR_NONE);
+ grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
} else {
ObClient *c;
}
}
+void setup_action_focus(ObAction **a, ObUserAction uact)
+{
+ (*a)->data.any.client_action = OB_CLIENT_ACTION_OPTIONAL;
+}
+
void setup_client_action(ObAction **a, ObUserAction uact)
{
(*a)->data.any.client_action = OB_CLIENT_ACTION_ALWAYS;
{
"focus",
action_focus,
- setup_client_action
+ setup_action_focus
},
{
"unfocus",
break;
}
if (!exist)
- g_warning("Invalid action '%s' requested. No such action exists.",
+ g_message(_("Invalid action '%s' requested. No such action exists."),
name);
if (!a)
- g_warning("Invalid use of action '%s'. Action will be ignored.", name);
+ g_message(_("Invalid use of action '%s'. Action will be ignored."),
+ name);
return a;
}
it won't work right unless we XUngrabKeyboard first,
even though we grabbed the key/button Asychronously.
e.g. "gnome-panel-control --main-menu" */
- XUngrabKeyboard(ob_display, event_curtime);
+ grab_keyboard(FALSE);
}
for (it = acts; it; it = g_slist_next(it)) {
cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
if (cmd) {
if (!g_shell_parse_argv (cmd, NULL, &argv, &e)) {
- g_warning("failed to execute '%s': %s",
+ g_message(_("Failed to execute '%s': %s"),
cmd, e->message);
g_error_free(e);
} else if (data->execute.startupnotify) {
- gchar **env, *program;
+ gchar *program;
program = g_path_get_basename(argv[0]);
- env = sn_get_spawn_environment(program,
- data->execute.name,
- data->execute.icon_name,
- /* launch it on the current
- desktop */
- screen_desktop,
- data->execute.any.time);
- if (!g_spawn_async(NULL, argv, env, G_SPAWN_SEARCH_PATH |
+ /* sets up the environment */
+ sn_setup_spawn_environment(program,
+ data->execute.name,
+ data->execute.icon_name,
+ /* launch it on the current
+ desktop */
+ screen_desktop,
+ data->execute.any.time);
+ if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, NULL, &e)) {
- g_warning("failed to execute '%s': %s",
+ g_message(_("Failed to execute '%s': %s"),
cmd, e->message);
g_error_free(e);
sn_spawn_cancel();
}
- g_strfreev(env);
+ unsetenv("DESKTOP_STARTUP_ID");
g_free(program);
g_strfreev(argv);
} else {
G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, NULL, &e))
{
- g_warning("failed to execute '%s': %s",
+ g_message(_("Failed to execute '%s': %s"),
cmd, e->message);
g_error_free(e);
}
}
g_free(cmd);
} else {
- g_warning("failed to convert '%s' from utf8", data->execute.path);
+ g_message(_("Failed to convert the path '%s' from utf8"),
+ data->execute.path);
}
}
}
void action_focus(union ActionData *data)
{
- /* similar to the openbox dock for dockapps, don't let user actions give
- focus to 3rd-party docks (panels) either (unless they ask for it
- themselves). */
- if (data->client.any.c->type != OB_CLIENT_TYPE_DOCK) {
- /* if using focus_delay, stop the timer now so that focus doesn't go
- moving on us */
- event_halt_focus_delay();
+ if (data->client.any.c) {
+ /* similar to the openbox dock for dockapps, don't let user actions
+ give focus to 3rd-party docks (panels) either (unless they ask for
+ it themselves). */
+ if (data->client.any.c->type != OB_CLIENT_TYPE_DOCK) {
+ /* if using focus_delay, stop the timer now so that focus doesn't
+ go moving on us */
+ event_halt_focus_delay();
- if (client_validate(data->client.any.c))
client_focus(data->client.any.c);
+ }
+ } else {
+ /* focus action on something other than a client, make keybindings
+ work for this openbox instance, but don't focus any specific client
+ */
+ focus_nothing();
}
}