[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Squashed commit of the following:
- Subject: [PATCH] Squashed commit of the following:
- From: "Martin \"eto\" Misuth" <et _dot_ git _at_ ethome _dot_ sk>
- Date: Mon, 18 Aug 2014 11:15:42 +0200
commit 6ce911ae5e145eefef23d3e17dbf5727d35d0ca1
Author: Martin "eto" Misuth <et _dot_ git _at_ ethome _dot_ sk>
Date: Mon Aug 18 11:11:39 2014 +0200
final composed commit: add close_and_remove command and documentation
commit 830489b0331a3e33a024365d1c465a23ac2aecad
Author: Martin "eto" Misuth <et _dot_ git _at_ ethome _dot_ sk>
Date: Mon Aug 18 10:23:39 2014 +0200
add newline for readability
commit 9fd3510434fcba1bf468c62ee9ec5170f16d3c61
Author: Martin "eto" Misuth <et _dot_ git _at_ ethome _dot_ sk>
Date: Mon Aug 18 10:12:51 2014 +0200
fixed semantic error in comment and added command to manual
commit c60d2b6a6191420f4e6a3aa0209dd7d084cf3ae0
Merge: 0e905b8 b1fe138
Author: Martin "eto" Misuth <et _dot_ git _at_ ethome _dot_ sk>
Date: Mon Aug 18 10:07:52 2014 +0200
Merge branch 'master' of git://git.cs.fau.de/hlwm into eto-close_and_remove
commit 0e905b8652b3393256eceef900c5e46aa580d79f
Author: Martin "eto" Misuth <et _dot_ git _at_ ethome _dot_ sk>
Date: Mon Aug 11 19:43:10 2014 +0200
initial attempt
---
doc/herbstluftwm.txt | 4 ++++
src/command.cpp | 1 +
src/layout.cpp | 22 ++++++++++++++++++++++
src/layout.h | 1 +
src/main.cpp | 1 +
5 files changed, 29 insertions(+)
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index 409a43b..bde839a 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -353,6 +353,10 @@ close_or_remove::
Closes the focused window or removes the current frame if no window is
focused.
+close_and_remove::
+ Closes the focused window and removes the current frame if no other window
+ is present in that frame.
+
split 'ALIGN' ['FRACTION']::
Splits the focused frame into two subframes with a specified 'FRACTION'
between 0 and 1 which defaults to 0.5. 'ALIGN' is one of
diff --git a/src/command.cpp b/src/command.cpp
index 59cc9a8..1adf8a8 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -97,6 +97,7 @@ struct {
{ "set_layout", 2, no_completion },
{ "close", 1, no_completion },
{ "close_or_remove",1, no_completion },
+ { "close_and_remove",1, no_completion },
{ "split", 3, no_completion },
{ "focus", 3, no_completion },
{ "focus", 2, first_parameter_is_flag },
diff --git a/src/layout.cpp b/src/layout.cpp
index abbe479..19ffb85 100644
--- a/src/layout.cpp
+++ b/src/layout.cpp
@@ -1917,6 +1917,28 @@ int close_or_remove_command(int argc, char** argv) {
}
}
+// ET: same as close or remove but remove after last client
+int close_and_remove_command(int argc, char** argv) {
+ bool remove_after_close = false;
+ HSClient* client = frame_focused_client(g_cur_frame);
+ if (client) {
+ if (g_cur_frame->content.clients.count == 1 ) {
+ remove_after_close = true;
+ }
+
+ window_close(client->window);
+
+ if (remove_after_close) {
+ frame_remove_command(argc, argv);
+ }
+
+ return 0;
+
+ } else {
+ return frame_remove_command(argc, argv);
+ }
+}
+
void frame_set_visible(HSFrame* frame, bool visible) {
if (!frame) {
return;
diff --git a/src/layout.h b/src/layout.h
index 18343bd..71be87d 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -180,6 +180,7 @@ 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);
+int close_and_remove_command(int argc, char** argv);
void frame_set_visible(HSFrame* frame, bool visible);
void frame_update_border(Window window, unsigned long color);
diff --git a/src/main.cpp b/src/main.cpp
index 5b34ded..aa5dfd3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -129,6 +129,7 @@ CommandBinding g_commands[] = {
CMD_BIND_NO_OUTPUT( "cycle_frame", cycle_frame_command),
CMD_BIND( "close", close_command),
CMD_BIND_NO_OUTPUT( "close_or_remove",close_or_remove_command),
+ CMD_BIND_NO_OUTPUT( "close_and_remove",close_and_remove_command),
CMD_BIND( "split", frame_split_command),
CMD_BIND( "resize", frame_change_fraction_command),
CMD_BIND( "focus_edge", frame_focus_edge),
--
2.0.4
--=_zucker.schokokeks.org-30212-1408357934-0001-2--