[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: UPDATE: command: shift_edge
- To: Tyler Thomas Hart <tylerthomashart _at_ gmail _dot_ com>
- Subject: Re: UPDATE: command: shift_edge
- From: Thorsten Wißmann <edu _at_ thorsten _minus_ wissmann _dot_ de>
- Date: Sat, 8 Dec 2012 23:24:31 +0100
Hi Tyler,
Sorry for the spam. I accidentally wrote the answer to shift_edge as a
reply to shift_cycle_monitor. So here's the correct answer:
On Wed, Nov 28, 2012 at 04:30:54PM -0800, Tyler Thomas Hart wrote:
> shift_edge DIRECTION
> Shifts the focused window to the the edge of a tag in the
> specified DIRECTION. The DIRECTIONS behave as specified at
> the focus command.
I had to modify your patch heavily â I actually changed everything
except the function signature:
- There was no parameter completion
- There was a useless variable called "check"
- The command produced flickering, if the loop was executed twice, so
I added monitor locking/unlocking.
- I added your full name in the author field of the commit.
But I have a bad feeling about this patch anyway, because it assumes
that frame_move_window() doesn't behave in a cyclic way. (Which may
change in the future...).
If you still need this feature, then please acknowledge the attached
patch.
Regards,
Thorsten
>From 8dc315c90342091c3178f7ffded01ddb42d934d5 Mon Sep 17 00:00:00 2001
From: Tyler Thomas Hart <htyler _at_ pdx _dot_ edu>
Date: Wed, 28 Nov 2012 15:43:56 -0800
Subject: [PATCH] Add command shift_edge
---
NEWS | 1 +
doc/herbstluftwm.txt | 4 ++++
src/command.c | 2 ++
src/layout.c | 11 +++++++++++
src/layout.h | 2 ++
src/main.c | 1 +
6 files changed, 21 insertions(+)
diff --git a/NEWS b/NEWS
index 2559bcd..a9ba125 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Changes:
* floating, fullscreen, pseudotile: default to toggle if no argument is
given
* add error messages for herbstclient
+ * new command: shift_edge
Release: 0.4.1 on 2012-08-30
----------------------------
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index c617114..80852e9 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -361,6 +361,10 @@ resize 'DIRECTION' 'FRACTIONDELTA'::
* resize right +0.05
* resize down -0.1
+shift_edge 'DIRECTION'::
+ Shifts the focused window to the the edge of a tag in the specified
+ 'DIRECTION'. The 'DIRECTIONS' behave as specified at the 'focus' command.
+
shift ['-i'|'-e'] 'DIRECTION'::
Shifts the focused window to the next frame in the specified 'DIRECTION'.
The 'DIRECTIONS' and '-i'|'-e' behave as specified at the 'focus' command.
diff --git a/src/command.c b/src/command.c
index d2e5073..bbbea45 100644
--- a/src/command.c
+++ b/src/command.c
@@ -77,6 +77,7 @@ struct {
{ "jumpto", 2, no_completion },
{ "bring", 2, no_completion },
{ "resize", 3, no_completion },
+ { "shift_edge", 2, no_completion },
{ "shift", 3, no_completion },
{ "shift", 2, first_parameter_is_flag },
{ "remove", 1, no_completion },
@@ -177,6 +178,7 @@ struct {
{ "jumpto", EQ, 1, .list = completion_special_winids },
{ "jumpto", EQ, 1, .function = complete_against_winids },
{ "resize", EQ, 1, .list = completion_directions },
+ { "shift_edge", EQ, 1, .list = completion_directions },
{ "shift", EQ, 1, .list = completion_directions },
{ "shift", EQ, 1, .list = completion_focus_args },
{ "shift", EQ, 2, .list = completion_directions },
diff --git a/src/layout.c b/src/layout.c
index 2ba3cf4..aadd4e9 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -12,6 +12,7 @@
#include "settings.h"
#include "layout.h"
#include "stack.h"
+#include "monitor.h"
#include <glib.h>
#include <stdlib.h>
@@ -1767,3 +1768,13 @@ void frame_update_border(Window window, unsigned long color) {
}
}
+int frame_move_window_edge(int argc, char** argv, GString* output) {
+ // Moves a window to an edge in the specified direction
+ char* args[] = { "" };
+ monitors_lock_command(LENGTH(args), args);
+ while (0 == frame_move_window_command(argc,argv,output))
+ ;
+ monitors_unlock_command(LENGTH(args), args);
+ return 0;
+}
+
diff --git a/src/layout.h b/src/layout.h
index 57a3018..0882849 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -169,5 +169,7 @@ int close_or_remove_command(int argc, char** argv);
void frame_set_visible(HSFrame* frame, bool visible);
void frame_update_border(Window window, unsigned long color);
+int frame_move_window_edge(int argc, char** argv, GString* output);
+
#endif
diff --git a/src/main.c b/src/main.c
index 1dfea90..d668c2d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -110,6 +110,7 @@ CommandBinding g_commands[] = {
CMD_BIND( "split", frame_split_command),
CMD_BIND( "resize", frame_change_fraction_command),
CMD_BIND( "focus", frame_focus_command),
+ CMD_BIND( "shift_edge", frame_move_window_edge),
CMD_BIND( "shift", frame_move_window_command),
CMD_BIND_NO_OUTPUT( "remove", frame_remove_command),
CMD_BIND( "set", settings_set_command),
--
1.8.0