[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Shift_to_monitor follows shift
- To: herbstluftwm _minus_ devel _at_ lists _dot_ sourceforge _dot_ net
- Subject: [PATCH] Shift_to_monitor follows shift
- From: Tyler Thomas Hart <htyler _at_ pdx _dot_ edu>
- Date: Thu, 24 Jan 2013 15:17:01 -0800
Hi,
eto on irc brought my attention (again) to the fact that
shift_to_monitor does not follow shift. Since
focus_follows_shift was removed, I think that the behavior
of all shift commands should be similar.
The following patch focuses the monitor/frame/window of the
target. Note that the old behavior can be easily scripted if
using a relative index by calling
$ hc chain shift_to_monitor +$X , focus_monitor -$X
which requires less scripting than the current way to
produce the 'correct' behavior.
Sorry for neglecting this during the focus_follows_shift
discussion.
Tylo
>From aef743fa8d49e661b1f317b668d9d505f04bda38 Mon Sep 17 00:00:00 2001
From: Tyler Thomas Hart <htyler _at_ pdx _dot_ edu>
Date: Thu, 24 Jan 2013 15:04:55 -0800
Subject: [PATCH] Shift_to_monitor follows shift
Shift_to_monitor previously did not follow shift, which is not
the behavior of shift and shift_edge.
---
src/monitor.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/monitor.c b/src/monitor.c
index 042b6ba..5c13921 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -1183,13 +1183,21 @@ int shift_to_monitor(int argc, char** argv, GString* output) {
return HERBST_NEED_MORE_ARGS;
}
char* monitor_str = argv[1];
- HSMonitor* monitor = string_to_monitor(monitor_str);
- if (!monitor) {
+ int monitor = string_to_monitor_index(monitor_str);
+ if (monitor == -1) {
g_string_append_printf(output,
"%s: Invalid monitor\n", monitor_str);
return HERBST_INVALID_ARGUMENT;
}
- tag_move_focused_client(monitor->tag);
+ Window cur_window = frame_focused_window(g_cur_frame);
+ if (!cur_window) {
+ g_string_append_printf(output, "%s: No window focused\n", argv[0]);
+ return HERBST_FORBIDDEN;
+ }
+ monitors_lock();
+ tag_move_focused_client((monitor_with_index(monitor))->tag);
+ monitor_focus_by_index(monitor);
+ monitors_unlock();
return 0;
}
--
1.8.1.1