aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--data/init.in2
-rw-r--r--data/keys3
-rw-r--r--doc/asciidoc/fluxbox.txt11
-rw-r--r--src/CurrentWindowCmd.cc20
-rw-r--r--src/CurrentWindowCmd.hh21
-rw-r--r--src/FbCommandFactory.cc45
-rw-r--r--src/FbCommands.cc9
-rw-r--r--src/FbCommands.hh8
-rw-r--r--src/Screen.cc1
-rw-r--r--src/Screen.hh11
-rw-r--r--src/ScreenResources.cc27
-rw-r--r--src/Window.cc77
-rw-r--r--src/Window.hh18
-rw-r--r--src/fluxbox.cc22
-rw-r--r--src/fluxbox.hh4
-rw-r--r--util/fluxbox-update_configs.cc32
17 files changed, 169 insertions, 151 deletions
diff --git a/ChangeLog b/ChangeLog
index 646720b..0644aad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0.1: 2Changes for 1.0.1:
3*07/10/22:
4 * Replaced modKey with new commands StartMoving and StartResizing (Mark)
5 - your keys file should be updated automatically
6 - they must be used with a mouse button, or they won't work
7 - StartResizing takes one or none of the following arguments:
8 NearestCorner, Center, TopLeft, TopRight, BottomLeft, BottomRight
9 Window.cc/hh CurrentWindowCmd.cc/hh FbCommandFactory.cc Screen.cc/hh
10 fluxbox.cc/hh ScreenResources.cc FbCommands.cc/hh
11 util/fluxbox-update_configs.cc
3*07/10/21: 12*07/10/21:
4 * Allow decorations bitmask to be specified using '0x' (Mark) 13 * Allow decorations bitmask to be specified using '0x' (Mark)
5 Window.cc 14 Window.cc
diff --git a/data/init.in b/data/init.in
index 5ad9aa3..10727c3 100644
--- a/data/init.in
+++ b/data/init.in
@@ -31,4 +31,4 @@ session.colorsPerChannel: 4
31session.doubleClickInterval: 250 31session.doubleClickInterval: 250
32session.cacheMax: 200 32session.cacheMax: 200
33session.imageDither: True 33session.imageDither: True
34session.configVersion: 3 34session.configVersion: 4
diff --git a/data/keys b/data/keys
index 603e15c..85d1f71 100644
--- a/data/keys
+++ b/data/keys
@@ -7,6 +7,9 @@ OnDesktop Mouse5 :PrevWorkspace
7OnToolbar Mouse4 :NextWorkspace 7OnToolbar Mouse4 :NextWorkspace
8OnToolbar Mouse5 :PrevWorkspace 8OnToolbar Mouse5 :PrevWorkspace
9 9
10OnWindow Mod1 Mouse1 :StartMoving
11OnWindow Mod1 Mouse3 :StartResizing
12
10Mod1 Tab :NextWindow 13Mod1 Tab :NextWindow
11Mod1 Shift Tab :PrevWindow 14Mod1 Shift Tab :PrevWindow
12Mod1 F1 :Workspace 1 15Mod1 F1 :Workspace 1
diff --git a/doc/asciidoc/fluxbox.txt b/doc/asciidoc/fluxbox.txt
index 0b11dad..5e4cf07 100644
--- a/doc/asciidoc/fluxbox.txt
+++ b/doc/asciidoc/fluxbox.txt
@@ -848,11 +848,6 @@ session.screen0.followModel: <model>
848 be focused. `Ignore' does nothing, and `Follow' uses the setting in 848 be focused. `Ignore' does nothing, and `Follow' uses the setting in
849 session.screen0.userFollowModel. Default: Ignore 849 session.screen0.userFollowModel. Default: Ignore
850 850
851session.screen0.resizeMode: Bottom|Quadrant|Center
852 Setting this resource to `Quadrant' makes resizing by using the modkey
853 grab the corner closest to the mouse pointer instead of the bottom right
854 corner. `Center' resizes all corners at the same time. Default: Bottom
855
856session.screen0.focusModel: ClickToFocus|MouseFocus 851session.screen0.focusModel: ClickToFocus|MouseFocus
857 This controls how windows gain focus via the mouse. With `ClickToFocus', 852 This controls how windows gain focus via the mouse. With `ClickToFocus',
858 the user must click on the window. With `MouseFocus', windows gain focus 853 the user must click on the window. With `MouseFocus', windows gain focus
@@ -1018,11 +1013,6 @@ session.titlebar.right: Minimize Maximize Close
1018 The icons to place in the titlebar of decorated windows. The available 1013 The icons to place in the titlebar of decorated windows. The available
1019 options are Close, Maximize, MenuIcon, Minimize, Shade, and Stick. 1014 options are Close, Maximize, MenuIcon, Minimize, Shade, and Stick.
1020 1015
1021session.modKey: <modifier>
1022 This specifies a modifier to use to drag and resize windows without
1023 clicking on the border or titlebar. For example, Alt + Left click will
1024 move windows, and Alt + Right click will resize. Default: Mod1
1025
1026................................................................................ 1016................................................................................
1027 1017
1028 1018
@@ -1163,7 +1153,6 @@ Special Commands
1163- SetResourceValue <resourcename> <resource> value 1153- SetResourceValue <resourcename> <resource> value
1164- BindKey <key><value>: <action> 1154- BindKey <key><value>: <action>
1165- KeyMode <keymode name> <return key sequence> 1155- KeyMode <keymode name> <return key sequence>
1166- SetModKey <modifier>
1167 1156
1168Couple of things 1157Couple of things
1169~~~~~~~~~~~~~~~~ 1158~~~~~~~~~~~~~~~~
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index 01b8de7..885f4b0 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -115,6 +115,26 @@ void GoToTabCmd::real_execute() {
115 (*it)->focus(); 115 (*it)->focus();
116} 116}
117 117
118void StartMovingCmd::real_execute() {
119 const XEvent &last = Fluxbox::instance()->lastEvent();
120 if (last.type == ButtonPress) {
121 const XButtonEvent &be = last.xbutton;
122 fbwindow().startMoving(be.x_root, be.y_root);
123 }
124}
125
126void StartResizingCmd::real_execute() {
127 const XEvent &last = Fluxbox::instance()->lastEvent();
128 if (last.type == ButtonPress) {
129 const XButtonEvent &be = last.xbutton;
130 int x = be.x_root - fbwindow().x()
131 - fbwindow().frame().window().borderWidth();
132 int y = be.y_root - fbwindow().y()
133 - fbwindow().frame().window().borderWidth();
134 fbwindow().startResizing(x, y, fbwindow().getResizeDirection(x, y, m_mode));
135 }
136}
137
118MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) : 138MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) :
119 m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } 139 m_step_size_x(step_size_x), m_step_size_y(step_size_y) { }
120 140
diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh
index da929d5..53dc7b8 100644
--- a/src/CurrentWindowCmd.hh
+++ b/src/CurrentWindowCmd.hh
@@ -26,8 +26,7 @@
26#define CURRENTWINDOWCMD_HH 26#define CURRENTWINDOWCMD_HH
27 27
28#include "Command.hh" 28#include "Command.hh"
29 29#include "Window.hh"
30class FluxboxWindow;
31 30
32/// helper class for window commands 31/// helper class for window commands
33/// calls real_execute if there's a focused window or a window in button press/release window 32/// calls real_execute if there's a focused window or a window in button press/release window
@@ -131,6 +130,24 @@ private:
131 const int m_tab_num; 130 const int m_tab_num;
132}; 131};
133 132
133// begin moving with mouse
134class StartMovingCmd: public WindowHelperCmd {
135public:
136 StartMovingCmd() { }
137protected:
138 void real_execute();
139};
140
141// begin resizing with mouse
142class StartResizingCmd: public WindowHelperCmd {
143public:
144 explicit StartResizingCmd(FluxboxWindow::ResizeModel mode):m_mode(mode) { }
145protected:
146 void real_execute();
147private:
148 const FluxboxWindow::ResizeModel m_mode;
149};
150
134// move cmd, relative position 151// move cmd, relative position
135class MoveCmd: public WindowHelperCmd { 152class MoveCmd: public WindowHelperCmd {
136public: 153public:
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
index bf008ad..be37403 100644
--- a/src/FbCommandFactory.cc
+++ b/src/FbCommandFactory.cc
@@ -158,7 +158,6 @@ FbCommandFactory::FbCommandFactory() {
158 "setalpha", 158 "setalpha",
159 "setenv", 159 "setenv",
160 "sethead", 160 "sethead",
161 "setmodkey",
162 "setstyle", 161 "setstyle",
163 "setworkspacename", 162 "setworkspacename",
164 "setworkspacenamedialog", 163 "setworkspacenamedialog",
@@ -167,6 +166,8 @@ FbCommandFactory::FbCommandFactory() {
167 "shade", 166 "shade",
168 "shadewindow", 167 "shadewindow",
169 "showdesktop", 168 "showdesktop",
169 "startmoving",
170 "startresizing",
170 "stick", 171 "stick",
171 "stickwindow", 172 "stickwindow",
172 "tab", 173 "tab",
@@ -235,15 +236,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
235 string value = name.substr(pos + 1); 236 string value = name.substr(pos + 1);
236 name = name.substr(0, pos); 237 name = name.substr(0, pos);
237 return new ExportCmd(name, value); 238 return new ExportCmd(name, value);
238 } 239 } else if (command == "commanddialog") // run specified fluxbox command
239 else if (command == "setmodkey") {
240 string modkey(arguments);
241 FbTk::StringUtil::removeFirstWhitespace(modkey);
242 FbTk::StringUtil::removeTrailingWhitespace(modkey);
243
244 return new SetModKeyCmd(modkey);
245 }
246 else if (command == "commanddialog") // run specified fluxbox command
247 return new CommandDialogCmd(); 240 return new CommandDialogCmd();
248 else if (command == "bindkey" && trusted) 241 else if (command == "bindkey" && trusted)
249 return new BindKeyCmd(arguments); 242 return new BindKeyCmd(arguments);
@@ -307,6 +300,38 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
307 pat = arguments.c_str() + pos; 300 pat = arguments.c_str() + pos;
308 301
309 return new WindowListCmd(FbTk::RefCount<WindowHelperCmd>(new SetAlphaCmd(focused, relative, unfocused, un_rel)), pat); 302 return new WindowListCmd(FbTk::RefCount<WindowHelperCmd>(new SetAlphaCmd(focused, relative, unfocused, un_rel)), pat);
303 } else if (command == "startmoving")
304 return new StartMovingCmd();
305 else if (command == "startresizing") {
306 FluxboxWindow::ResizeModel mode = FluxboxWindow::DEFAULTRESIZE;
307 vector<string> tokens;
308 FbTk::StringUtil::stringtok<vector<string> >(tokens, arguments);
309 if (!tokens.empty()) {
310 string arg = FbTk::StringUtil::toLower(tokens[0]);
311 if (arg == "nearestcorner")
312 mode = FluxboxWindow::QUADRANTRESIZE;
313 else if (arg == "nearestedge")
314 mode = FluxboxWindow::NEARESTEDGERESIZE;
315 else if (arg == "center")
316 mode = FluxboxWindow::CENTERRESIZE;
317 else if (arg == "topleft")
318 mode = FluxboxWindow::TOPLEFTRESIZE;
319 else if (arg == "top")
320 mode = FluxboxWindow::TOPRESIZE;
321 else if (arg == "topright")
322 mode = FluxboxWindow::TOPRIGHTRESIZE;
323 else if (arg == "left")
324 mode = FluxboxWindow::LEFTRESIZE;
325 else if (arg == "right")
326 mode = FluxboxWindow::RIGHTRESIZE;
327 else if (arg == "bottomleft")
328 mode = FluxboxWindow::BOTTOMLEFTRESIZE;
329 else if (arg == "bottom")
330 mode = FluxboxWindow::BOTTOMRESIZE;
331 else if (arg == "bottomright")
332 mode = FluxboxWindow::BOTTOMRIGHTRESIZE;
333 }
334 return new StartResizingCmd(mode);
310 } else if (command == "resize" || command == "resizeto" || 335 } else if (command == "resize" || command == "resizeto" ||
311 command == "resizehorizontal" || command == "resizevertical") { 336 command == "resizehorizontal" || command == "resizevertical") {
312 FbTk_istringstream is(arguments.c_str()); 337 FbTk_istringstream is(arguments.c_str());
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index f536fd8..1d063e7 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -169,15 +169,6 @@ int ExecuteCmd::run() {
169 return pid; // compiler happy -> we are happy ;) 169 return pid; // compiler happy -> we are happy ;)
170} 170}
171 171
172SetModKeyCmd::SetModKeyCmd(const string& modkey) : m_modkey(modkey) { }
173
174void SetModKeyCmd::execute() {
175 Fluxbox::instance()->setModKey(m_modkey.c_str());
176 Fluxbox::instance()->save_rc();
177 // TODO: we need a better way to do this ...
178 Fluxbox::instance()->reconfigure();
179}
180
181ExportCmd::ExportCmd(const string& name, const string& value) : 172ExportCmd::ExportCmd(const string& name, const string& value) :
182 m_name(name), m_value(value) { 173 m_name(name), m_value(value) {
183} 174}
diff --git a/src/FbCommands.hh b/src/FbCommands.hh
index a049a7c..c563899 100644
--- a/src/FbCommands.hh
+++ b/src/FbCommands.hh
@@ -101,14 +101,6 @@ private:
101 std::string m_filename; 101 std::string m_filename;
102}; 102};
103 103
104class SetModKeyCmd: public FbTk::Command {
105public:
106 explicit SetModKeyCmd(const std::string& modkey);
107 void execute();
108private:
109 std::string m_modkey;
110};
111
112class KeyModeCmd: public FbTk::Command { 104class KeyModeCmd: public FbTk::Command {
113public: 105public:
114 explicit KeyModeCmd(const std::string &arguments); 106 explicit KeyModeCmd(const std::string &arguments);
diff --git a/src/Screen.cc b/src/Screen.cc
index 5549ca5..e6681e6 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -297,7 +297,6 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
297 decorate_transient(rm, true, scrname+".decorateTransient", altscrname+".DecorateTransient"), 297 decorate_transient(rm, true, scrname+".decorateTransient", altscrname+".DecorateTransient"),
298 default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"), 298 default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"),
299 rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), 299 rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
300 resize_model(rm, BOTTOMRESIZE, scrname+".resizeMode", altscrname+".ResizeMode"),
301 tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"), 300 tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"),
302 windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"), 301 windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"),
303 typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"), 302 typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"),
diff --git a/src/Screen.hh b/src/Screen.hh
index a094bac..09865e6 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -92,14 +92,6 @@ public:
92 FETCH_ACTIVE_WINDOW ///< put that window to the current workspace 92 FETCH_ACTIVE_WINDOW ///< put that window to the current workspace
93 }; 93 };
94 94
95 /// Different resize modes when resizing a window
96 enum ResizeModel {
97 BOTTOMRESIZE = 0, ///< resizes from the bottom right corner
98 QUADRANTRESIZE, ///< resizes from one quadrant
99 CENTERRESIZE, ///< resizes from center
100 DEFAULTRESIZE = BOTTOMRESIZE ///< default resize mode is bottom
101 };
102
103 95
104 typedef std::list<FluxboxWindow *> Icons; 96 typedef std::list<FluxboxWindow *> Icons;
105 97
@@ -142,8 +134,6 @@ public:
142 134
143 FbWinFrame::TabPlacement getTabPlacement() const { return *resource.tab_placement; } 135 FbWinFrame::TabPlacement getTabPlacement() const { return *resource.tab_placement; }
144 136
145 ResizeModel getResizeModel() const { return *resource.resize_model; }
146
147 inline unsigned int noFocusWhileTypingDelay() const { return *resource.typing_delay; } 137 inline unsigned int noFocusWhileTypingDelay() const { return *resource.typing_delay; }
148 inline FollowModel getFollowModel() const { return *resource.follow_model; } 138 inline FollowModel getFollowModel() const { return *resource.follow_model; }
149 inline FollowModel getUserFollowModel() const { return *resource.user_follow_model; } 139 inline FollowModel getUserFollowModel() const { return *resource.user_follow_model; }
@@ -561,7 +551,6 @@ private:
561 decorate_transient; 551 decorate_transient;
562 FbTk::Resource<std::string> default_deco; 552 FbTk::Resource<std::string> default_deco;
563 FbTk::Resource<std::string> rootcommand; 553 FbTk::Resource<std::string> rootcommand;
564 FbTk::Resource<ResizeModel> resize_model;
565 FbTk::Resource<FbWinFrame::TabPlacement> tab_placement; 554 FbTk::Resource<FbWinFrame::TabPlacement> tab_placement;
566 FbTk::Resource<std::string> windowmenufile; 555 FbTk::Resource<std::string> windowmenufile;
567 FbTk::Resource<unsigned int> typing_delay; 556 FbTk::Resource<unsigned int> typing_delay;
diff --git a/src/ScreenResources.cc b/src/ScreenResources.cc
index e4d712a..c346c12 100644
--- a/src/ScreenResources.cc
+++ b/src/ScreenResources.cc
@@ -58,33 +58,6 @@ void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setFromString(const char *str) {
58 setDefaultValue(); 58 setDefaultValue();
59} 59}
60 60
61template <>
62string FbTk::Resource<BScreen::ResizeModel>::getString() const {
63 switch (m_value) {
64 case BScreen::QUADRANTRESIZE:
65 return string("Quadrant");
66 case BScreen::BOTTOMRESIZE:
67 return string("Bottom");
68 case BScreen::CENTERRESIZE:
69 return string("Center");
70 }
71
72 return string("Default");
73}
74
75template<>
76void FbTk::Resource<BScreen::ResizeModel>::
77setFromString(char const *strval) {
78 if (strcasecmp(strval, "Bottom") == 0) {
79 m_value = BScreen::BOTTOMRESIZE;
80 } else if (strcasecmp(strval, "Quadrant") == 0) {
81 m_value = BScreen::QUADRANTRESIZE;
82 } else if (strcasecmp(strval, "Center") == 0) {
83 m_value = BScreen::CENTERRESIZE;
84 } else
85 m_value = BScreen::DEFAULTRESIZE;
86}
87
88template<> 61template<>
89string FbTk::Resource<BScreen::FollowModel>::getString() const { 62string FbTk::Resource<BScreen::FollowModel>::getString() const {
90 switch (m_value) { 63 switch (m_value) {
diff --git a/src/Window.cc b/src/Window.cc
index 9a3d367..dbd945f 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1039,20 +1039,6 @@ void FluxboxWindow::grabButtons() {
1039 XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, 1039 XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask,
1040 frame().window().window()); 1040 frame().window().window());
1041 1041
1042 unsigned int modkey = Fluxbox::instance()->getModKey();
1043
1044 if (modkey) {
1045 //----grab with "all" modifiers
1046 FbTk::KeyUtil::grabButton(Button1, modkey, frame().window().window(),
1047 ButtonReleaseMask | ButtonMotionMask, frame().theme().moveCursor());
1048
1049 XGrabButton(display, Button2, modkey, frame().window().window(), True,
1050 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
1051
1052 //---grab with "all" modifiers
1053 FbTk::KeyUtil::grabButton(Button3, modkey, frame().window().window(),
1054 ButtonReleaseMask | ButtonMotionMask);
1055 }
1056} 1042}
1057 1043
1058 1044
@@ -2592,8 +2578,7 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2592 // check frame events first 2578 // check frame events first
2593 frame().buttonPressEvent(be); 2579 frame().buttonPressEvent(be);
2594 2580
2595 if (be.button == 1 || (be.button == 3 && 2581 if (be.button == 1) {
2596 be.state == Fluxbox::instance()->getModKey())) {
2597 if (!m_focused) //check focus 2582 if (!m_focused) //check focus
2598 focus(); 2583 focus();
2599 2584
@@ -2618,28 +2603,14 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2618 2603
2619void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { 2604void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
2620 2605
2621 if ((re.button == 1) && (re.state & Fluxbox::instance()->getModKey())
2622 && !screen().clickRaises()) {
2623
2624 if (!isMoving())
2625 raise();
2626
2627 }
2628
2629 if (isMoving()) 2606 if (isMoving())
2630 stopMoving(); 2607 stopMoving();
2631 else if (isResizing()) 2608 else if (isResizing())
2632 stopResizing(); 2609 stopResizing();
2633 else if (m_attaching_tab) 2610 else if (m_attaching_tab)
2634 attachTo(re.x_root, re.y_root); 2611 attachTo(re.x_root, re.y_root);
2635 else if (re.window == frame().window()) { 2612 else
2636 if (re.button == 2 && re.state == Fluxbox::instance()->getModKey())
2637 ungrabPointer(CurrentTime);
2638 else
2639 frame().buttonReleaseEvent(re);
2640 } else {
2641 frame().buttonReleaseEvent(re); 2613 frame().buttonReleaseEvent(re);
2642 }
2643} 2614}
2644 2615
2645 2616
@@ -2654,9 +2625,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2654 || frame().handle() == me.window 2625 || frame().handle() == me.window
2655 || frame().window() == me.window); 2626 || frame().window() == me.window);
2656 2627
2657 if (Fluxbox::instance()->getIgnoreBorder() 2628 if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0
2658 && !(me.state & Fluxbox::instance()->getModKey()) // really should check for exact matches 2629 && !(isMoving() || isResizing())) {
2659 && !(isMoving() || isResizing() || m_attaching_tab != 0)) {
2660 int borderw = frame().window().borderWidth(); 2630 int borderw = frame().window().borderWidth();
2661 //!! TODO(tabs): the below test ought to be in FbWinFrame 2631 //!! TODO(tabs): the below test ought to be in FbWinFrame
2662 // if mouse is currently on the window border, ignore it 2632 // if mouse is currently on the window border, ignore it
@@ -2787,23 +2757,13 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2787 2757
2788 if (! resizing) { 2758 if (! resizing) {
2789 2759
2790 int cx = frame().width() / 2;
2791 int cy = frame().height() / 2;
2792 ResizeDirection resize_corner = RIGHTBOTTOM; 2760 ResizeDirection resize_corner = RIGHTBOTTOM;
2793 if (me.window == frame().gripRight()) 2761 if (me.window == frame().gripRight())
2794 resize_corner = RIGHTBOTTOM; 2762 resize_corner = RIGHTBOTTOM;
2795 else if (me.window == frame().gripLeft()) 2763 else if (me.window == frame().gripLeft())
2796 resize_corner = LEFTBOTTOM; 2764 resize_corner = LEFTBOTTOM;
2797 else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) { 2765 else // dragging border of window, so choose nearest corner
2798 if (screen().getResizeModel() == BScreen::CENTERRESIZE) 2766 resize_corner = getResizeDirection(me.x, me.y, QUADRANTRESIZE);
2799 resize_corner = ALLCORNERS;
2800 else
2801 resize_corner = RIGHTBOTTOM;
2802 } else if (me.x < cx)
2803 resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
2804 else
2805 resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
2806
2807 2767
2808 // We are grabbing frame window in startResizing 2768 // We are grabbing frame window in startResizing
2809 // we need to translate coordinates to it. 2769 // we need to translate coordinates to it.
@@ -3404,6 +3364,31 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
3404 3364
3405} 3365}
3406 3366
3367FluxboxWindow::ResizeDirection FluxboxWindow::getResizeDirection(int x, int y,
3368 ResizeModel model) {
3369 int cx = frame().width() / 2;
3370 int cy = frame().height() / 2;
3371 if (model == CENTERRESIZE)
3372 return ALLCORNERS;
3373 if (model == NEARESTEDGERESIZE) {
3374 if (abs(cy - abs(y - cy)) > abs(cx - abs(x - cx))) // y is nearest
3375 return (y > cy) ? BOTTOM : TOP;
3376 return (x > cx) ? RIGHT : LEFT;
3377 }
3378 if (model == QUADRANTRESIZE) {
3379 if (x < cx)
3380 return (y < cy) ? LEFTTOP : LEFTBOTTOM;
3381 return (y < cy) ? RIGHTTOP : RIGHTBOTTOM;
3382 }
3383 if (model == TOPLEFTRESIZE) return LEFTTOP;
3384 if (model == TOPRESIZE) return TOP;
3385 if (model == TOPRIGHTRESIZE) return RIGHTTOP;
3386 if (model == LEFTRESIZE) return LEFT;
3387 if (model == RIGHTRESIZE) return RIGHT;
3388 if (model == BOTTOMLEFTRESIZE) return LEFTBOTTOM;
3389 if (model == BOTTOMRESIZE) return BOTTOM;
3390 return RIGHTBOTTOM;
3391}
3407 3392
3408void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { 3393void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) {
3409 3394
diff --git a/src/Window.hh b/src/Window.hh
index 3a87463..6fb258a 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -137,6 +137,22 @@ public:
137 DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB 137 DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB
138 }; 138 };
139 139
140 /// Different resize modes when resizing a window
141 enum ResizeModel {
142 QUADRANTRESIZE, ///< resizes from one quadrant
143 CENTERRESIZE, ///< resizes from center
144 NEARESTEDGERESIZE, ///< resizes the nearest edge
145 TOPLEFTRESIZE, ///< resizes top left corner
146 TOPRESIZE, ///< resizes top edge
147 TOPRIGHTRESIZE, ///< resizes top right corner
148 LEFTRESIZE, ///< resizes left edge
149 RIGHTRESIZE, ///< resizes right edge
150 BOTTOMLEFTRESIZE, ///< resizes bottom left corner
151 BOTTOMRESIZE, ///< resizes bottom edge
152 BOTTOMRIGHTRESIZE, ///< resizes bottom right corner
153 DEFAULTRESIZE = BOTTOMRIGHTRESIZE ///< default resize mode
154 };
155
140 /** 156 /**
141 * Resize direction while resizing 157 * Resize direction while resizing
142 */ 158 */
@@ -369,6 +385,8 @@ public:
369 * @param dir the resize direction 385 * @param dir the resize direction
370 */ 386 */
371 void startResizing(int x, int y, ResizeDirection dir); 387 void startResizing(int x, int y, ResizeDirection dir);
388 /// determine which edge or corner to resize
389 ResizeDirection getResizeDirection(int x, int y, ResizeModel model);
372 /// stops the resizing 390 /// stops the resizing
373 void stopResizing(bool interrupted = false); 391 void stopResizing(bool interrupted = false);
374 392
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 80d055b..058c858 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -211,7 +211,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
211 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), 211 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"),
212 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), 212 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"),
213 m_rc_auto_raise_delay(m_resourcemanager, 250, "session.autoRaiseDelay", "Session.AutoRaiseDelay"), 213 m_rc_auto_raise_delay(m_resourcemanager, 250, "session.autoRaiseDelay", "Session.AutoRaiseDelay"),
214 m_rc_mod_key(m_resourcemanager, "Mod1", "session.modKey", "Session.ModKey"),
215 m_masked_window(0), 214 m_masked_window(0),
216 m_mousescreen(0), 215 m_mousescreen(0),
217 m_keyscreen(0), 216 m_keyscreen(0),
@@ -643,7 +642,7 @@ void Fluxbox::setupConfigFiles() {
643 if (create_init) 642 if (create_init)
644 FbTk::FileUtil::copyFile(DEFAULT_INITFILE, init_file.c_str()); 643 FbTk::FileUtil::copyFile(DEFAULT_INITFILE, init_file.c_str());
645 644
646#define CONFIG_VERSION 3 645#define CONFIG_VERSION 4
647 FbTk::Resource<int> config_version(m_resourcemanager, 0, 646 FbTk::Resource<int> config_version(m_resourcemanager, 0,
648 "session.configVersion", "Session.ConfigVersion"); 647 "session.configVersion", "Session.ConfigVersion");
649 if (*config_version < CONFIG_VERSION) { 648 if (*config_version < CONFIG_VERSION) {
@@ -1707,22 +1706,3 @@ void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1707 (*it).first->updateFrameExtents(win); 1706 (*it).first->updateFrameExtents(win);
1708 } 1707 }
1709} 1708}
1710
1711unsigned int Fluxbox::getModKey() const {
1712 if (!(m_rc_mod_key->c_str()))
1713 return 0;
1714 else
1715 return FbTk::KeyUtil::instance().getModifier(m_rc_mod_key->c_str());
1716}
1717
1718void Fluxbox::setModKey(const char* modkeyname) {
1719
1720 if (!modkeyname)
1721 return;
1722
1723 unsigned int modkey = FbTk::KeyUtil::instance().getModifier(modkeyname);
1724
1725 if (modkey > 0) {
1726 m_rc_mod_key = modkeyname;
1727 }
1728}
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 625a906..82ff76d 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -135,9 +135,6 @@ public:
135 unsigned int getCacheMax() const { return *m_rc_cache_max; } 135 unsigned int getCacheMax() const { return *m_rc_cache_max; }
136 136
137 137
138 unsigned int getModKey() const;
139 void setModKey(const char*);
140
141 void maskWindowEvents(Window w, FluxboxWindow *bw) 138 void maskWindowEvents(Window w, FluxboxWindow *bw)
142 { m_masked = w; m_masked_window = bw; } 139 { m_masked = w; m_masked_window = bw; }
143 140
@@ -246,7 +243,6 @@ private:
246 FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area; 243 FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area;
247 FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max; 244 FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
248 FbTk::Resource<time_t> m_rc_auto_raise_delay; 245 FbTk::Resource<time_t> m_rc_auto_raise_delay;
249 FbTk::Resource<std::string> m_rc_mod_key;
250 246
251 typedef std::map<Window, WinClient *> WinClientMap; 247 typedef std::map<Window, WinClient *> WinClientMap;
252 WinClientMap m_window_search; 248 WinClientMap m_window_search;
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc
index 2dc5eb6..27c8b48 100644
--- a/util/fluxbox-update_configs.cc
+++ b/util/fluxbox-update_configs.cc
@@ -182,6 +182,38 @@ int run_updates(int old_version, FbTk::ResourceManager rm) {
182 new_version = 3; 182 new_version = 3;
183 } 183 }
184 184
185 if (old_version < 4) { // move modkey to keys file
186 string whole_keyfile = read_file(keyfilename);
187 string new_keyfile = "";
188 // let's put our new keybindings first, so they're easy to find
189 new_keyfile += "!mouse actions added by fluxbox-update_configs\n";
190
191 // need to match user's resize model
192 FbTk::Resource<string> rc_mode(rm, "Bottom",
193 "session.screen0.resizeMode",
194 "Session.Screen0.ResizeMode");
195 FbTk::Resource<string> rc_modkey(rm, "Mod1",
196 "session.modKey",
197 "Session.ModKey");
198
199 new_keyfile += "OnWindow " + *rc_modkey + " Mouse1 :StartMoving\n";
200 if (strcasecmp((*rc_mode).c_str(), "Quadrant") == 0) {
201 new_keyfile += "OnWindow " + *rc_modkey +
202 " Mouse3 :StartResizing NearestCorner\n";
203 } else if (strcasecmp((*rc_mode).c_str(), "Center") == 0) {
204 new_keyfile += "OnWindow " + *rc_modkey +
205 " Mouse3 :StartResizing Center\n";
206 } else {
207 new_keyfile += "OnWindow " + *rc_modkey +
208 "StartResizing BottomRight\n";
209 }
210 new_keyfile += "\n"; // just for good looks
211 new_keyfile += whole_keyfile; // don't forget user's old keybindings
212
213 write_file(keyfilename, new_keyfile);
214 new_version = 4;
215 }
216
185 return new_version; 217 return new_version;
186} 218}
187 219