summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2012-11-14 19:14:39 +0100
committerThorsten Wißmann <re06huxa@stud.informatik.uni-erlangen.de>2012-11-18 03:08:41 +0100
commit72c0d4962dd01f63adc59b966ea206ebdd4c3f9b (patch)
tree979acaab2c44e0fa697b8c94aa6077a05833ba4a /src
parentcde90ecad8ad55bf5093738358b6678571d3e8cf (diff)
Print error when frame neighbours are missing
Diffstat (limited to 'src')
-rw-r--r--src/layout.c17
-rw-r--r--src/layout.h4
-rw-r--r--src/main.c4
3 files changed, 17 insertions, 8 deletions
diff --git a/src/layout.c b/src/layout.c
index 0ef9d19d..259d8889 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -1207,8 +1207,9 @@ int frame_change_fraction_command(int argc, char** argv, GString* output) {
}
neighbour = frame_neighbour(g_cur_frame, direction);
if (!neighbour) {
- // nothing to do
- return 0;
+ g_string_append_printf(output,
+ "%s: No neighbour found!", argv[0]);
+ return HERBST_FORBIDDEN;
}
}
HSFrame* parent = neighbour->parent;
@@ -1326,7 +1327,7 @@ int frame_inner_neighbour_index(HSFrame* frame, char direction) {
return index;
}
-int frame_focus_command(int argc, char** argv) {
+int frame_focus_command(int argc, char** argv, GString* output) {
// usage: focus [-e|-i] left|right|up|down
if (argc < 2) return HERBST_NEED_MORE_ARGS;
if (!g_cur_frame) {
@@ -1361,12 +1362,16 @@ int frame_focus_command(int argc, char** argv) {
// change focus if possible
frame_focus_recursive(parent);
monitor_apply_layout(get_current_monitor());
+ } else {
+ g_string_append_printf(output,
+ "%s: No neighbour found!", argv[0]);
+ return HERBST_FORBIDDEN;
}
}
return 0;
}
-int frame_move_window_command(int argc, char** argv) {
+int frame_move_window_command(int argc, char** argv, GString* output) {
// usage: move left|right|up|down
if (argc < 2) return HERBST_NEED_MORE_ARGS;
if (!g_cur_frame) {
@@ -1429,6 +1434,10 @@ int frame_move_window_command(int argc, char** argv) {
}
// layout was changed, so update it
monitor_apply_layout(get_current_monitor());
+ } else {
+ g_string_append_printf(output,
+ "%s: No neighbour found!", argv[0]);
+ return HERBST_FORBIDDEN;
}
}
return 0;
diff --git a/src/layout.h b/src/layout.h
index ebb2882d..f09a07f0 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -138,7 +138,7 @@ void frame_unfocus(); // unfocus currently focused window
// returns the neighbour or NULL if there is no one
HSFrame* frame_neighbour(HSFrame* frame, char direction);
int frame_inner_neighbour_index(HSFrame* frame, char direction);
-int frame_focus_command(int argc, char** argv);
+int frame_focus_command(int argc, char** argv, GString* output);
// follow selection to leave and focus this frame
int frame_focus_recursive(HSFrame* frame);
@@ -163,7 +163,7 @@ Window frame_focused_window(HSFrame* frame);
bool frame_focus_window(HSFrame* frame, Window win);
bool focus_window(Window win, bool switch_tag, bool switch_monitor);
// moves a window to an other frame
-int frame_move_window_command(int argc, char** argv);
+int frame_move_window_command(int argc, char** argv, GString* output);
/// removes the current frame
int frame_remove_command(int argc, char** argv);
int close_or_remove_command(int argc, char** argv);
diff --git a/src/main.c b/src/main.c
index b6ccb082..6bc4260d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -109,8 +109,8 @@ CommandBinding g_commands[] = {
CMD_BIND_NO_OUTPUT( "close_or_remove",close_or_remove_command),
CMD_BIND( "split", frame_split_command),
CMD_BIND( "resize", frame_change_fraction_command),
- CMD_BIND_NO_OUTPUT( "focus", frame_focus_command),
- CMD_BIND_NO_OUTPUT( "shift", frame_move_window_command),
+ CMD_BIND( "focus", frame_focus_command),
+ CMD_BIND( "shift", frame_move_window_command),
CMD_BIND_NO_OUTPUT( "remove", frame_remove_command),
CMD_BIND( "set", settings_set_command),
CMD_BIND( "toggle", settings_toggle),