aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-04-04 13:19:10 (GMT)
committerfluxgen <fluxgen>2002-04-04 13:19:10 (GMT)
commite4d3840f267f95c50299ca725b2dfb1202a09801 (patch)
tree6fbde1b292cfb64736c6558db44ddefddac8dcc5
parent1717c112802ac6828ced2890fd8cfe99ba96cd96 (diff)
downloadfluxbox_paul-e4d3840f267f95c50299ca725b2dfb1202a09801.zip
fluxbox_paul-e4d3840f267f95c50299ca725b2dfb1202a09801.tar.bz2
added startMoving, stopMoving, startResizing and stopResizing and fixed bug 528101
-rw-r--r--src/Window.cc229
-rw-r--r--src/Window.hh67
2 files changed, 161 insertions, 135 deletions
diff --git a/src/Window.cc b/src/Window.cc
index ba18a05..a6689cb 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.37 2002/04/04 11:28:19 fluxgen Exp $ 25// $Id: Window.cc,v 1.38 2002/04/04 13:19:10 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -1495,9 +1495,9 @@ void FluxboxWindow::getWMIconName(void) {
1495 1495
1496 XFree((char *) text_prop.value); 1496 XFree((char *) text_prop.value);
1497 } else 1497 } else
1498 client.icon_title = getTitle(); //assign title to icon title 1498 client.icon_title = getTitle();
1499 } else 1499 } else
1500 client.icon_title = getTitle(); //assign title to icon title 1500 client.icon_title = getTitle();
1501} 1501}
1502 1502
1503 1503
@@ -2035,6 +2035,10 @@ void FluxboxWindow::close(void) {
2035void FluxboxWindow::withdraw(void) { 2035void FluxboxWindow::withdraw(void) {
2036 visible = false; 2036 visible = false;
2037 iconic = false; 2037 iconic = false;
2038 if (isMoving())
2039 stopMoving();
2040 if (isResizing())
2041 stopResizing();
2038 2042
2039 XUnmapWindow(display, frame.window); 2043 XUnmapWindow(display, frame.window);
2040 2044
@@ -3295,46 +3299,11 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) {
3295 if (! validateClient()) 3299 if (! validateClient())
3296 return; 3300 return;
3297 3301
3298 if (moving) { 3302 if (isMoving())
3299 moving = false; 3303 stopMoving();
3300 3304 else if (isResizing())
3301 fluxbox->maskWindowEvents(0, (FluxboxWindow *) 0); 3305 stopResizing();
3302 3306 else if (re->window == frame.window) {
3303 if (! screen->doOpaqueMove()) {
3304 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3305 frame.move_x, frame.move_y, frame.resize_w,
3306 frame.resize_h);
3307
3308 configure(frame.move_x, frame.move_y, frame.width, frame.height);
3309 fluxbox->ungrab();
3310 } else
3311 configure(frame.x, frame.y, frame.width, frame.height);
3312
3313 screen->hideGeometry();
3314 XUngrabPointer(display, CurrentTime);
3315 } else if (resizing) {
3316 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3317 frame.resize_x, frame.resize_y,
3318 frame.resize_w, frame.resize_h);
3319
3320 screen->hideGeometry();
3321
3322 if (re->window == frame.left_grip)
3323 left_fixsize();
3324 else
3325 right_fixsize();
3326
3327 resizing = false;
3328 configure(frame.resize_x, frame.resize_y,
3329 frame.resize_w - screen->getBorderWidth2x(),
3330 frame.resize_h - screen->getBorderWidth2x());
3331
3332 if (tab)
3333 tab->resize();
3334
3335 fluxbox->ungrab();
3336 XUngrabPointer(display, CurrentTime);
3337 } else if (re->window == frame.window) {
3338 if (re->button == 2 && re->state == Mod1Mask) 3307 if (re->button == 2 && re->state == Mod1Mask)
3339 XUngrabPointer(display, CurrentTime); 3308 XUngrabPointer(display, CurrentTime);
3340 } else { 3309 } else {
@@ -3356,39 +3325,13 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) {
3356 3325
3357 3326
3358void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) { 3327void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3359 Fluxbox *fluxbox = Fluxbox::instance();
3360 if ((me->state & Button1Mask) && functions.move && 3328 if ((me->state & Button1Mask) && functions.move &&
3361 (frame.title == me->window || frame.label == me->window || 3329 (frame.title == me->window || frame.label == me->window ||
3362 frame.handle == me->window || frame.window == me->window) && !resizing) { 3330 frame.handle == me->window || frame.window == me->window) && !isResizing()) {
3363 3331
3364 if (! moving) { 3332 if (! isMoving()) {
3365 XGrabPointer(display, me->window, False, Button1MotionMask | 3333 startMoving(me->window);
3366 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 3334 } else {
3367 None, fluxbox->getMoveCursor(), CurrentTime);
3368
3369 if (windowmenu && windowmenu->isVisible())
3370 windowmenu->hide();
3371
3372 moving = true;
3373
3374 fluxbox->maskWindowEvents(client.window, this);
3375
3376 if (! screen->doOpaqueMove()) {
3377 fluxbox->grab();
3378
3379 frame.move_x = frame.x;
3380 frame.move_y = frame.y;
3381 frame.resize_w = frame.width + screen->getBorderWidth2x();
3382 frame.resize_h = ((shaded) ? frame.title_h : frame.height) +
3383 screen->getBorderWidth2x();
3384
3385 screen->showPosition(frame.x, frame.y);
3386
3387 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3388 frame.move_x, frame.move_y,
3389 frame.resize_w, frame.resize_h);
3390 }
3391 } else {
3392 int dx = me->x_root - frame.grab_x, dy = me->y_root - frame.grab_y; 3335 int dx = me->x_root - frame.grab_x, dy = me->y_root - frame.grab_y;
3393 3336
3394 dx -= screen->getBorderWidth(); 3337 dx -= screen->getBorderWidth();
@@ -3429,8 +3372,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3429 3372
3430 if (! screen->doOpaqueMove()) { 3373 if (! screen->doOpaqueMove()) {
3431 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 3374 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3432 frame.move_x, frame.move_y, frame.resize_w, 3375 frame.move_x, frame.move_y, frame.resize_w, frame.resize_h);
3433 frame.resize_h);
3434 3376
3435 frame.move_x = dx; 3377 frame.move_x = dx;
3436 frame.move_y = dy; 3378 frame.move_y = dy;
@@ -3441,7 +3383,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3441 } else 3383 } else
3442 configure(dx, dy, frame.width, frame.height); 3384 configure(dx, dy, frame.width, frame.height);
3443 3385
3444 screen->showPosition(dx, dy); 3386 screen->showPosition(dx, dy);
3445 } 3387 }
3446 } else if (functions.resize && 3388 } else if (functions.resize &&
3447 (((me->state & Button1Mask) && (me->window == frame.right_grip || 3389 (((me->state & Button1Mask) && (me->window == frame.right_grip ||
@@ -3449,35 +3391,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) {
3449 me->window == frame.window)) { 3391 me->window == frame.window)) {
3450 bool left = (me->window == frame.left_grip); 3392 bool left = (me->window == frame.left_grip);
3451 3393
3452 if (! resizing) { 3394 if (! resizing) {
3453 XGrabPointer(display, me->window, false, ButtonMotionMask | 3395 startResizing(me, left);
3454 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None,
3455 ((left) ? fluxbox->getLowerLeftAngleCursor() :
3456 fluxbox->getLowerRightAngleCursor()),
3457 CurrentTime);
3458
3459 resizing = true;
3460
3461// fluxbox->grab();
3462
3463 int gx, gy;
3464 frame.grab_x = me->x - screen->getBorderWidth();
3465 frame.grab_y = me->y - screen->getBorderWidth2x();
3466 frame.resize_x = frame.x;
3467 frame.resize_y = frame.y;
3468 frame.resize_w = frame.width + screen->getBorderWidth2x();
3469 frame.resize_h = frame.height + screen->getBorderWidth2x();
3470
3471 if (left)
3472 left_fixsize(&gx, &gy);
3473 else
3474 right_fixsize(&gx, &gy);
3475
3476 screen->showGeometry(gx, gy);
3477
3478 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3479 frame.resize_x, frame.resize_y,
3480 frame.resize_w, frame.resize_h);
3481 } else if (resizing) { 3396 } else if (resizing) {
3482 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 3397 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3483 frame.resize_x, frame.resize_y, 3398 frame.resize_x, frame.resize_y,
@@ -3566,6 +3481,110 @@ bool FluxboxWindow::validateClient(void) {
3566 return true; 3481 return true;
3567} 3482}
3568 3483
3484void FluxboxWindow::startMoving(Window win) {
3485 moving = true;
3486 Fluxbox *fluxbox = Fluxbox::instance();
3487 XGrabPointer(display, win, False, Button1MotionMask |
3488 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
3489 None, fluxbox->getMoveCursor(), CurrentTime);
3490
3491 if (windowmenu && windowmenu->isVisible())
3492 windowmenu->hide();
3493
3494 fluxbox->maskWindowEvents(client.window, this);
3495
3496 if (! screen->doOpaqueMove()) {
3497 fluxbox->grab();
3498
3499 frame.move_x = frame.x;
3500 frame.move_y = frame.y;
3501 frame.resize_w = frame.width + screen->getBorderWidth2x();
3502 frame.resize_h = ((shaded) ? frame.title_h : frame.height) +
3503 screen->getBorderWidth2x();
3504
3505 screen->showPosition(frame.x, frame.y);
3506
3507 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3508 frame.move_x, frame.move_y,
3509 frame.resize_w, frame.resize_h);
3510 }
3511}
3512
3513void FluxboxWindow::stopMoving() {
3514 moving = false;
3515 Fluxbox *fluxbox = Fluxbox::instance();
3516
3517 fluxbox->maskWindowEvents(0, (FluxboxWindow *) 0);
3518
3519 if (! screen->doOpaqueMove()) {
3520 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3521 frame.move_x, frame.move_y, frame.resize_w,
3522 frame.resize_h);
3523
3524 configure(frame.move_x, frame.move_y, frame.width, frame.height);
3525 fluxbox->ungrab();
3526 } else
3527 configure(frame.x, frame.y, frame.width, frame.height);
3528
3529 screen->hideGeometry();
3530 XUngrabPointer(display, CurrentTime);
3531
3532 XSync(display, False); //make sure the redraw is made before we continue
3533}
3534
3535void FluxboxWindow::startResizing(XMotionEvent *me, bool left) {
3536 resizing = true;
3537 Fluxbox *fluxbox = Fluxbox::instance();
3538 XGrabPointer(display, me->window, false, ButtonMotionMask | ButtonReleaseMask,
3539 GrabModeAsync, GrabModeAsync, None,
3540 ((left) ? fluxbox->getLowerLeftAngleCursor() : fluxbox->getLowerRightAngleCursor()),
3541 CurrentTime);
3542
3543 int gx, gy;
3544 frame.grab_x = me->x - screen->getBorderWidth();
3545 frame.grab_y = me->y - screen->getBorderWidth2x();
3546 frame.resize_x = frame.x;
3547 frame.resize_y = frame.y;
3548 frame.resize_w = frame.width + screen->getBorderWidth2x();
3549 frame.resize_h = frame.height + screen->getBorderWidth2x();
3550
3551 if (left)
3552 left_fixsize(&gx, &gy);
3553 else
3554 right_fixsize(&gx, &gy);
3555
3556 screen->showGeometry(gx, gy);
3557
3558 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3559 frame.resize_x, frame.resize_y,
3560 frame.resize_w, frame.resize_h);
3561}
3562
3563void FluxboxWindow::stopResizing(Window win) {
3564 resizing = false;
3565
3566 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
3567 frame.resize_x, frame.resize_y,
3568 frame.resize_w, frame.resize_h);
3569
3570 screen->hideGeometry();
3571
3572 if (win == frame.left_grip)
3573 left_fixsize();
3574 else
3575 right_fixsize();
3576
3577
3578 configure(frame.resize_x, frame.resize_y,
3579 frame.resize_w - screen->getBorderWidth2x(),
3580 frame.resize_h - screen->getBorderWidth2x());
3581
3582 if (tab)
3583 tab->resize();
3584
3585 Fluxbox::instance()->ungrab();
3586 XUngrabPointer(display, CurrentTime);
3587}
3569 3588
3570void FluxboxWindow::restore(void) { 3589void FluxboxWindow::restore(void) {
3571 XChangeSaveSet(display, client.window, SetModeDelete); 3590 XChangeSaveSet(display, client.window, SetModeDelete);
diff --git a/src/Window.hh b/src/Window.hh
index 73612d9..7d61873 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -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.hh,v 1.15 2002/04/03 23:01:04 fluxgen Exp $ 25// $Id: Window.hh,v 1.16 2002/04/04 13:19:10 fluxgen Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
@@ -120,22 +120,23 @@ public:
120 FluxboxWindow(Window, BScreen * = 0); 120 FluxboxWindow(Window, BScreen * = 0);
121 virtual ~FluxboxWindow(void); 121 virtual ~FluxboxWindow(void);
122 122
123 inline const bool isTransient(void) const { return ((transient) ? true : false); } 123 inline bool isTransient(void) const { return ((transient) ? true : false); }
124 inline const bool hasTransient(void) const { return ((client.transient) ? true : false); } 124 inline bool hasTransient(void) const { return ((client.transient) ? true : false); }
125 inline const bool isManaged() const { return managed; } 125 inline bool isManaged() const { return managed; }
126 inline const bool isFocused(void) const { return focused; } 126 inline bool isFocused(void) const { return focused; }
127 inline const bool isVisible(void) const { return visible; } 127 inline bool isVisible(void) const { return visible; }
128 inline const bool isIconic(void) const { return iconic; } 128 inline bool isIconic(void) const { return iconic; }
129 inline const bool isShaded(void) const { return shaded; } 129 inline bool isShaded(void) const { return shaded; }
130 inline const bool isMaximized(void) const { return maximized; } 130 inline bool isMaximized(void) const { return maximized; }
131 inline const bool isIconifiable(void) const { return functions.iconify; } 131 inline bool isIconifiable(void) const { return functions.iconify; }
132 inline const bool isMaximizable(void) const { return functions.maximize; } 132 inline bool isMaximizable(void) const { return functions.maximize; }
133 inline const bool isResizable(void) const { return functions.resize; } 133 inline bool isResizable(void) const { return functions.resize; }
134 inline const bool isClosable(void) const { return functions.close; } 134 inline bool isClosable(void) const { return functions.close; }
135 inline const bool isStuck(void) const { return stuck; } 135 inline bool isStuck(void) const { return stuck; }
136 inline const bool hasTitlebar(void) const { return decorations.titlebar; } 136 inline bool hasTitlebar(void) const { return decorations.titlebar; }
137 inline const bool hasTab(void) const { return (tab!=0 ? true : false); } 137 inline bool hasTab(void) const { return (tab!=0 ? true : false); }
138 static void showError(FluxboxWindow::Error error); 138 inline bool isMoving(void) const { return moving; }
139 inline bool isResizing(void) const { return resizing; }
139 inline BScreen *getScreen(void) const { return screen; } 140 inline BScreen *getScreen(void) const { return screen; }
140 inline Tab *getTab(void) const { return tab; } 141 inline Tab *getTab(void) const { return tab; }
141 inline FluxboxWindow *getTransient(void) const { return client.transient; } 142 inline FluxboxWindow *getTransient(void) const { return client.transient; }
@@ -148,18 +149,18 @@ public:
148 149
149 inline const std::string &getTitle(void) const { return client.title; } 150 inline const std::string &getTitle(void) const { return client.title; }
150 inline const std::string &getIconTitle(void) const { return client.icon_title; } 151 inline const std::string &getIconTitle(void) const { return client.icon_title; }
151 inline const int getXFrame(void) const { return frame.x; } 152 inline int getXFrame(void) const { return frame.x; }
152 inline const int getYFrame(void) const { return frame.y; } 153 inline int getYFrame(void) const { return frame.y; }
153 inline const int getXClient(void) const { return client.x; } 154 inline int getXClient(void) const { return client.x; }
154 inline const int getYClient(void) const { return client.y; } 155 inline int getYClient(void) const { return client.y; }
155 inline const unsigned int getWorkspaceNumber(void) const { return workspace_number; } 156 inline unsigned int getWorkspaceNumber(void) const { return workspace_number; }
156 inline const int getWindowNumber(void) const { return window_number; } 157 inline int getWindowNumber(void) const { return window_number; }
157 inline const WinLayer getLayer(void) const { return m_layer; } 158 inline WinLayer getLayer(void) const { return m_layer; }
158 inline const unsigned int getWidth(void) const { return frame.width; } 159 inline unsigned int getWidth(void) const { return frame.width; }
159 inline const unsigned int getHeight(void) const { return frame.height; } 160 inline unsigned int getHeight(void) const { return frame.height; }
160 inline const unsigned int getClientHeight(void) const { return client.height; } 161 inline unsigned int getClientHeight(void) const { return client.height; }
161 inline const unsigned int getClientWidth(void) const { return client.width; } 162 inline unsigned int getClientWidth(void) const { return client.width; }
162 inline const unsigned int getTitleHeight(void) const { return frame.title_h; } 163 inline unsigned int getTitleHeight(void) const { return frame.title_h; }
163 164
164 inline void setWindowNumber(int n) { window_number = n; } 165 inline void setWindowNumber(int n) { window_number = n; }
165 166
@@ -197,6 +198,8 @@ public:
197 void exposeEvent(XExposeEvent *); 198 void exposeEvent(XExposeEvent *);
198 void configureRequestEvent(XConfigureRequestEvent *); 199 void configureRequestEvent(XConfigureRequestEvent *);
199 200
201 static void showError(FluxboxWindow::Error error);
202
200 #ifdef SHAPE 203 #ifdef SHAPE
201 void shapeEvent(XShapeEvent *); 204 void shapeEvent(XShapeEvent *);
202 #endif // SHAPE 205 #endif // SHAPE
@@ -212,6 +215,7 @@ public:
212 void setGnomeState(int state); 215 void setGnomeState(int state);
213 inline int getGnomeHints() const { return gnome_hints; } 216 inline int getGnomeHints() const { return gnome_hints; }
214 #endif 217 #endif
218
215private: 219private:
216 BImageControl *image_ctrl; 220 BImageControl *image_ctrl;
217 221
@@ -302,7 +306,10 @@ private:
302 void grabButtons(); 306 void grabButtons();
303 307
304 void createButton(int type, ButtonEventProc, ButtonEventProc, ButtonDrawProc); 308 void createButton(int type, ButtonEventProc, ButtonEventProc, ButtonDrawProc);
305 309 void startMoving(Window win);
310 void stopMoving();
311 void startResizing(XMotionEvent *me, bool left);
312 void stopResizing(Window win=0);
306 #ifdef GNOME 313 #ifdef GNOME
307 314
308 void updateGnomeAtoms(); 315 void updateGnomeAtoms();