aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2006-02-19 12:50:01 (GMT)
committerfluxgen <fluxgen>2006-02-19 12:50:01 (GMT)
commit6d42d1cf5ed7d4ae6b3941727bf17cb6b48defd4 (patch)
tree44e9885bbea7777ca2729ce51964b9fed3f0763d /src
parent98209ba704e047c8f8f7df08fbb5849e3294cc68 (diff)
downloadfluxbox-6d42d1cf5ed7d4ae6b3941727bf17cb6b48defd4.zip
fluxbox-6d42d1cf5ed7d4ae6b3941727bf17cb6b48defd4.tar.bz2
Added center resize. Resizes all corners at the same time.
Diffstat (limited to 'src')
-rw-r--r--src/Screen.hh1
-rw-r--r--src/ScreenResources.cc4
-rw-r--r--src/Window.cc55
-rw-r--r--src/Window.hh3
4 files changed, 48 insertions, 15 deletions
diff --git a/src/Screen.hh b/src/Screen.hh
index 4f91d9c..7954456 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -90,6 +90,7 @@ public:
90 enum ResizeModel { 90 enum ResizeModel {
91 BOTTOMRESIZE = 0, 91 BOTTOMRESIZE = 0,
92 QUADRANTRESIZE, 92 QUADRANTRESIZE,
93 CENTERRESIZE,
93 DEFAULTRESIZE = BOTTOMRESIZE }; 94 DEFAULTRESIZE = BOTTOMRESIZE };
94 95
95 96
diff --git a/src/ScreenResources.cc b/src/ScreenResources.cc
index f26a376..7a58914 100644
--- a/src/ScreenResources.cc
+++ b/src/ScreenResources.cc
@@ -58,6 +58,8 @@ std::string FbTk::Resource<BScreen::ResizeModel>::getString() const {
58 return std::string("Quadrant"); 58 return std::string("Quadrant");
59 case BScreen::BOTTOMRESIZE: 59 case BScreen::BOTTOMRESIZE:
60 return std::string("Bottom"); 60 return std::string("Bottom");
61 case BScreen::CENTERRESIZE:
62 return std::string("Center");
61 } 63 }
62 64
63 return std::string("Default"); 65 return std::string("Default");
@@ -70,6 +72,8 @@ setFromString(char const *strval) {
70 m_value = BScreen::BOTTOMRESIZE; 72 m_value = BScreen::BOTTOMRESIZE;
71 } else if (strcasecmp(strval, "Quadrant") == 0) { 73 } else if (strcasecmp(strval, "Quadrant") == 0) {
72 m_value = BScreen::QUADRANTRESIZE; 74 m_value = BScreen::QUADRANTRESIZE;
75 } else if (strcasecmp(strval, "Center") == 0) {
76 m_value = BScreen::CENTERRESIZE;
73 } else 77 } else
74 m_value = BScreen::DEFAULTRESIZE; 78 m_value = BScreen::DEFAULTRESIZE;
75} 79}
diff --git a/src/Window.cc b/src/Window.cc
index a3b20f9..e6db450 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -2814,9 +2814,12 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2814 m_resize_corner = RIGHTBOTTOM; 2814 m_resize_corner = RIGHTBOTTOM;
2815 else if (me.window == frame().gripLeft()) 2815 else if (me.window == frame().gripLeft())
2816 m_resize_corner = LEFTBOTTOM; 2816 m_resize_corner = LEFTBOTTOM;
2817 else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) 2817 else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) {
2818 m_resize_corner = RIGHTBOTTOM; 2818 if (screen().getResizeModel() == BScreen::CENTERRESIZE)
2819 else if (me.x < cx) 2819 m_resize_corner = ALLCORNERS;
2820 else
2821 m_resize_corner = RIGHTBOTTOM;
2822 } else if (me.x < cx)
2820 m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM; 2823 m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
2821 else 2824 else
2822 m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM; 2825 m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
@@ -2835,21 +2838,45 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2835 2838
2836 int dx = me.x - m_button_grab_x; 2839 int dx = me.x - m_button_grab_x;
2837 int dy = me.y - m_button_grab_y; 2840 int dy = me.y - m_button_grab_y;
2838 2841 switch (m_resize_corner) {
2839 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { 2842 case LEFTTOP:
2843 m_last_resize_w = frame().width() - dx;
2844 m_last_resize_x = frame().x() + dx;
2845 // no break, use code below too
2846 case RIGHTTOP:
2840 m_last_resize_h = frame().height() - dy; 2847 m_last_resize_h = frame().height() - dy;
2841 m_last_resize_y = frame().y() + dy; 2848 m_last_resize_y = frame().y() + dy;
2842 } else { 2849 break;
2843 m_last_resize_h = frame().height() + dy; 2850 case LEFTBOTTOM:
2844 }
2845
2846 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) {
2847 m_last_resize_w = frame().width() - dx; 2851 m_last_resize_w = frame().width() - dx;
2848 m_last_resize_x = frame().x() + dx; 2852 m_last_resize_x = frame().x() + dx;
2849 } else { 2853 break;
2850 m_last_resize_w = frame().width() + dx; 2854 case ALLCORNERS:
2851 } 2855 // dx or dy must be at least 2
2856 if (abs(dx) >= 2 || abs(dy) >= 2) {
2857 // take max and make it even
2858 int diff = 2 * (max(dx, dy) / 2);
2859
2860 m_last_resize_h = frame().height() + diff;
2861
2862 m_last_resize_w = frame().width() + diff;
2863 m_last_resize_x = frame().x() - diff/2;
2864 m_last_resize_y = frame().y() - diff/2;
2865 }
2866 break;
2867 };
2852 2868
2869 // if not on top or all corner then move bottom
2870
2871 if (!(m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP ||
2872 m_resize_corner == ALLCORNERS))
2873 m_last_resize_h = frame().height() + dy;
2874
2875 // if not top or left bottom or all corners then move right side
2876 if (!(m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM ||
2877 m_resize_corner == ALLCORNERS))
2878 m_last_resize_w = frame().width() + dx;
2879
2853 fixsize(&gx, &gy); 2880 fixsize(&gx, &gy);
2854 2881
2855 if (old_resize_x != m_last_resize_x || 2882 if (old_resize_x != m_last_resize_x ||
@@ -3692,7 +3719,7 @@ void FluxboxWindow::fixsize(int *user_w, int *user_h) {
3692 // move X if necessary 3719 // move X if necessary
3693 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) { 3720 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) {
3694 m_last_resize_x = frame().x() + frame().width() - m_last_resize_w; 3721 m_last_resize_x = frame().x() + frame().width() - m_last_resize_w;
3695 } 3722 }
3696 3723
3697 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { 3724 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) {
3698 m_last_resize_y = frame().y() + frame().height() - m_last_resize_h; 3725 m_last_resize_y = frame().y() + frame().height() - m_last_resize_h;
diff --git a/src/Window.hh b/src/Window.hh
index 87a78af..7c59371 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -137,7 +137,8 @@ public:
137 LEFTTOP, 137 LEFTTOP,
138 LEFTBOTTOM, 138 LEFTBOTTOM,
139 RIGHTBOTTOM, 139 RIGHTBOTTOM,
140 RIGHTTOP 140 RIGHTTOP,
141 ALLCORNERS
141 }; 142 };
142 143
143 typedef struct _blackbox_hints { 144 typedef struct _blackbox_hints {