aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-09-29 12:53:58 (GMT)
committerrathnor <rathnor>2003-09-29 12:53:58 (GMT)
commit10ce5372d99251d65ff0d4e65c6e19cf05bb208a (patch)
tree554880caa9be789ff07b38393f36b9aba8e875b7 /src/Window.cc
parent48cc8772e32ad9cb56a0086840be41e72e94c41e (diff)
downloadfluxbox-10ce5372d99251d65ff0d4e65c6e19cf05bb208a.zip
fluxbox-10ce5372d99251d65ff0d4e65c6e19cf05bb208a.tar.bz2
quadrant-resizing (Thanks Mathias Gumz)
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc132
1 files changed, 55 insertions, 77 deletions
diff --git a/src/Window.cc b/src/Window.cc
index f35c21e..193f689 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.234 2003/09/24 14:02:25 rathnor Exp $ 25// $Id: Window.cc,v 1.235 2003/09/29 12:53:58 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -266,7 +266,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t
266 m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), 266 m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)),
267 m_layeritem(m_frame->window(), layer), 267 m_layeritem(m_frame->window(), layer),
268 m_layernum(layer.getLayerNum()), 268 m_layernum(layer.getLayerNum()),
269 m_parent(scr.rootWindow()) { 269 m_parent(scr.rootWindow()),
270 m_resize_corner(RIGHTBOTTOM) {
270 271
271 init(); 272 init();
272} 273}
@@ -934,10 +935,10 @@ void FluxboxWindow::grabButtons() {
934 935
935 XGrabButton(display, Button3, Mod1Mask, frame().window().window(), True, 936 XGrabButton(display, Button3, Mod1Mask, frame().window().window(), True,
936 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, 937 ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
937 GrabModeAsync, None, frame().theme().lowerRightAngleCursor()); 938 GrabModeAsync, None, None);
938 939
939 //---grab with "all" modifiers 940 //---grab with "all" modifiers
940 grabButton(display, Button3, frame().window().window(), frame().theme().lowerRightAngleCursor()); 941 grabButton(display, Button3, frame().window().window(), None);
941} 942}
942 943
943 944
@@ -2389,10 +2390,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2389 me.window == frame().gripLeft())) || 2390 me.window == frame().gripLeft())) ||
2390 me.window == frame().window())) { 2391 me.window == frame().window())) {
2391 2392
2392 bool left = (me.window == frame().gripLeft());
2393
2394 if (! resizing) { 2393 if (! resizing) {
2395 startResizing(me.window, me.x, me.y, left); 2394
2395 int cx = frame().width() / 2;
2396 int cy = frame().height() / 2;
2397
2398 if (me.window == frame().gripRight())
2399 m_resize_corner = RIGHTBOTTOM;
2400 else if (me.window == frame().gripLeft())
2401 m_resize_corner = LEFTBOTTOM;
2402 else if (screen().getResizeMode() != "quadrant")
2403 m_resize_corner = RIGHTBOTTOM;
2404 else if (me.x < cx)
2405 m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
2406 else
2407 m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
2408
2409 startResizing(me.window, me.x, me.y);
2396 } else if (resizing) { 2410 } else if (resizing) {
2397 // draw over old rect 2411 // draw over old rect
2398 parent().drawRectangle(screen().rootTheme().opGC(), 2412 parent().drawRectangle(screen().rootTheme().opGC(),
@@ -2404,24 +2418,25 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2404 // move rectangle 2418 // move rectangle
2405 int gx = 0, gy = 0; 2419 int gx = 0, gy = 0;
2406 2420
2407 m_last_resize_h = frame().height() + (me.y - m_button_grab_y); 2421 int dx = me.x - m_button_grab_x;
2408 if (m_last_resize_h < 1) 2422 int dy = me.y - m_button_grab_y;
2409 m_last_resize_h = 1;
2410
2411 if (left) {
2412 m_last_resize_x = me.x_root - m_button_grab_x;
2413 if (m_last_resize_x > (signed) (frame().x() + frame().width()))
2414 m_last_resize_x = m_last_resize_x + frame().width() - 1;
2415 2423
2416 left_fixsize(&gx, &gy); 2424 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) {
2425 m_last_resize_h = frame().height() - dy;
2426 m_last_resize_y = frame().y() + dy;
2417 } else { 2427 } else {
2418 m_last_resize_w = frame().width() + (me.x - m_button_grab_x); 2428 m_last_resize_h = frame().height() + dy;
2419 if (m_last_resize_w < 1) // clamp to 1 2429 }
2420 m_last_resize_w = 1;
2421 2430
2422 right_fixsize(&gx, &gy); 2431 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) {
2432 m_last_resize_w = frame().width() - dx;
2433 m_last_resize_x = frame().x() + dx;
2434 } else {
2435 m_last_resize_w = frame().width() + dx;
2423 } 2436 }
2424 2437
2438 fixsize(&gx, &gy);
2439
2425 // draw resize rectangle 2440 // draw resize rectangle
2426 parent().drawRectangle(screen().rootTheme().opGC(), 2441 parent().drawRectangle(screen().rootTheme().opGC(),
2427 m_last_resize_x, m_last_resize_y, 2442 m_last_resize_x, m_last_resize_y,
@@ -2877,13 +2892,16 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
2877} 2892}
2878 2893
2879 2894
2880void FluxboxWindow::startResizing(Window win, int x, int y, bool left) { 2895void FluxboxWindow::startResizing(Window win, int x, int y) {
2881 resizing = true; 2896 resizing = true;
2882 2897
2898 const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() :
2899 (m_resize_corner == RIGHTTOP) ? frame().theme().upperRightAngleCursor() :
2900 (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() :
2901 frame().theme().lowerLeftAngleCursor();
2902
2883 XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask, 2903 XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask,
2884 GrabModeAsync, GrabModeAsync, None, 2904 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
2885 (left ? frame().theme().lowerLeftAngleCursor() : frame().theme().lowerRightAngleCursor()),
2886 CurrentTime);
2887 2905
2888 int gx = 0, gy = 0; 2906 int gx = 0, gy = 0;
2889 m_button_grab_x = x; 2907 m_button_grab_x = x;
@@ -2893,10 +2911,7 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) {
2893 m_last_resize_w = frame().width(); 2911 m_last_resize_w = frame().width();
2894 m_last_resize_h = frame().height(); 2912 m_last_resize_h = frame().height();
2895 2913
2896 if (left) 2914 fixsize(&gx, &gy);
2897 left_fixsize(&gx, &gy);
2898 else
2899 right_fixsize(&gx, &gy);
2900 2915
2901 if (screen().doShowWindowPos()) 2916 if (screen().doShowWindowPos())
2902 screen().showGeometry(gx, gy); 2917 screen().showGeometry(gx, gy);
@@ -2917,11 +2932,7 @@ void FluxboxWindow::stopResizing(Window win) {
2917 2932
2918 screen().hideGeometry(); 2933 screen().hideGeometry();
2919 2934
2920 if (win && win == frame().gripLeft()) 2935 fixsize();
2921 left_fixsize();
2922 else
2923 right_fixsize();
2924
2925 2936
2926 moveResize(m_last_resize_x, m_last_resize_y, 2937 moveResize(m_last_resize_x, m_last_resize_y,
2927 m_last_resize_w, m_last_resize_h); 2938 m_last_resize_w, m_last_resize_h);
@@ -3155,49 +3166,7 @@ void FluxboxWindow::downsize() {
3155} 3166}
3156 3167
3157 3168
3158void FluxboxWindow::right_fixsize(int *gx, int *gy) { 3169void FluxboxWindow::fixsize(int *gx, int *gy) {
3159 // calculate the size of the client window and conform it to the
3160 // size specified by the size hints of the client window...
3161 int dx = m_last_resize_w - m_client->base_width;
3162 int titlebar_height = (decorations.titlebar ?
3163 frame().titlebar().height() +
3164 frame().titlebar().borderWidth() : 0);
3165 int handle_height = (decorations.handle ?
3166 frame().handle().height() +
3167 frame().handle().borderWidth() : 0);
3168
3169 int dy = m_last_resize_h - m_client->base_height - titlebar_height - handle_height;
3170 if (dx < (signed) m_client->min_width)
3171 dx = m_client->min_width;
3172 if (dy < (signed) m_client->min_height)
3173 dy = m_client->min_height;
3174 if (m_client->max_width > 0 && (unsigned) dx > m_client->max_width)
3175 dx = m_client->max_width;
3176 if (m_client->max_height > 0 && (unsigned) dy > m_client->max_height)
3177 dy = m_client->max_height;
3178
3179 // make it snap
3180
3181 if (m_client->width_inc == 0)
3182 m_client->width_inc = 1;
3183 if (m_client->height_inc == 0)
3184 m_client->height_inc = 1;
3185
3186 dx /= m_client->width_inc;
3187 dy /= m_client->height_inc;
3188
3189 if (gx) *gx = dx;
3190 if (gy) *gy = dy;
3191
3192 dx = (dx * m_client->width_inc) + m_client->base_width;
3193 dy = (dy * m_client->height_inc) + m_client->base_height +
3194 titlebar_height + handle_height;
3195
3196 m_last_resize_w = dx;
3197 m_last_resize_h = dy;
3198}
3199
3200void FluxboxWindow::left_fixsize(int *gx, int *gy) {
3201 int titlebar_height = (decorations.titlebar ? 3170 int titlebar_height = (decorations.titlebar ?
3202 frame().titlebar().height() + 3171 frame().titlebar().height() +
3203 frame().titlebar().borderWidth() : 0); 3172 frame().titlebar().borderWidth() : 0);
@@ -3207,7 +3176,8 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) {
3207 int decoration_height = titlebar_height + handle_height; 3176 int decoration_height = titlebar_height + handle_height;
3208 3177
3209 // dx is new width = current width + difference between new and old x values 3178 // dx is new width = current width + difference between new and old x values
3210 int dx = frame().width() + frame().x() - m_last_resize_x; 3179 //int dx = frame().width() + frame().x() - m_last_resize_x;
3180 int dx = m_last_resize_w - m_client->base_width;
3211 3181
3212 // dy = new height (w/o decorations), similarly 3182 // dy = new height (w/o decorations), similarly
3213 int dy = m_last_resize_h - m_client->base_height - decoration_height; 3183 int dy = m_last_resize_h - m_client->base_height - decoration_height;
@@ -3247,7 +3217,15 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) {
3247 // update last resize 3217 // update last resize
3248 m_last_resize_w = dx; 3218 m_last_resize_w = dx;
3249 m_last_resize_h = dy; 3219 m_last_resize_h = dy;
3220
3221 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) {
3250 m_last_resize_x = frame().x() + frame().width() - m_last_resize_w; 3222 m_last_resize_x = frame().x() + frame().width() - m_last_resize_w;
3223 }
3224
3225 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) {
3226 m_last_resize_y = frame().y() + frame().height() - m_last_resize_h;
3227 }
3228
3251} 3229}
3252 3230
3253void FluxboxWindow::resizeClient(WinClient &client, 3231void FluxboxWindow::resizeClient(WinClient &client,