aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2006-06-11 13:09:44 (GMT)
committerfluxgen <fluxgen>2006-06-11 13:09:44 (GMT)
commit331a52115dfa5c681b065d226ee796e52b48fed0 (patch)
tree1bd1282d6374431369e5b1fabda314f7ae7298ec /src
parent9699cda56e0877d361a0a79df3a8ebeea5b36f33 (diff)
downloadfluxbox_paul-331a52115dfa5c681b065d226ee796e52b48fed0.zip
fluxbox_paul-331a52115dfa5c681b065d226ee796e52b48fed0.tar.bz2
support for _NET_WM_MOVERESIZE
Diffstat (limited to 'src')
-rw-r--r--src/Ewmh.cc20
-rw-r--r--src/Window.cc54
-rw-r--r--src/Window.hh54
3 files changed, 83 insertions, 45 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index e034aa9..af9343f 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -166,7 +166,7 @@ void Ewmh::initForScreen(BScreen &screen) {
166 m_net_workarea, 166 m_net_workarea,
167 m_net_restack_window, 167 m_net_restack_window,
168 168
169 // m_net_wm_moveresize, 169 m_net_wm_moveresize,
170 170
171 171
172 // desktop properties 172 // desktop properties
@@ -672,7 +672,9 @@ void Ewmh::updateHints(FluxboxWindow &win) {
672} 672}
673 673
674void Ewmh::updateWorkspace(FluxboxWindow &win) { 674void Ewmh::updateWorkspace(FluxboxWindow &win) {
675 long workspace = win.isInitialized() ? win.workspaceNumber() : win.screen().currentWorkspaceID(); 675 long workspace = win.isInitialized() ?
676 win.workspaceNumber() :
677 win.screen().currentWorkspaceID();
676 678
677 if (win.isStuck()) 679 if (win.isStuck())
678 workspace = -1; // appear on all desktops/workspaces 680 workspace = -1; // appear on all desktops/workspaces
@@ -713,7 +715,8 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
713 // which doesn't apply here (so borrow the variable :) ) 715 // which doesn't apply here (so borrow the variable :) )
714 screen = &fbwin->screen(); 716 screen = &fbwin->screen();
715 // valid workspace number? 717 // valid workspace number?
716 if (static_cast<unsigned int>(ce.data.l[0]) < screen->numberOfWorkspaces()) 718 if (static_cast<unsigned int>
719 (ce.data.l[0]) < screen->numberOfWorkspaces())
717 screen->sendToWorkspace(ce.data.l[0], fbwin, false); 720 screen->sendToWorkspace(ce.data.l[0], fbwin, false);
718 721
719 return true; 722 return true;
@@ -846,8 +849,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
846 849
847 return true; 850 return true;
848 851
849 } /* Still in progress... 852 } else if (ce.message_type == m_net_wm_moveresize) {
850 else if (ce.message_type == m_net_wm_moveresize) {
851 if (winclient == 0 || winclient->fbwindow() == 0) 853 if (winclient == 0 || winclient->fbwindow() == 0)
852 return true; 854 return true;
853 // data.l[0] = x_root 855 // data.l[0] = x_root
@@ -855,10 +857,6 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
855 // data.l[2] = direction 857 // data.l[2] = direction
856 // data.l[3] = button 858 // data.l[3] = button
857 // data.l[4] = source indication 859 // data.l[4] = source indication
858 cerr<<"("<<ce.data.l[0]<<", "<<ce.data.l[1]<<")"<<endl;
859 cerr<<"dir="<<ce.data.l[2]<<endl;
860 cerr<<"button="<<ce.data.l[3]<<endl;
861 cerr<<"source="<<ce.data.l[4]<<endl;
862 switch (ce.data.l[2] ) { 860 switch (ce.data.l[2] ) {
863 case _NET_WM_MOVERESIZE_SIZE_TOPLEFT: 861 case _NET_WM_MOVERESIZE_SIZE_TOPLEFT:
864 case _NET_WM_MOVERESIZE_SIZE_TOP: 862 case _NET_WM_MOVERESIZE_SIZE_TOP:
@@ -883,7 +881,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
883 } 881 }
884 return true; 882 return true;
885 } 883 }
886 */ 884
887 // we didn't handle the ce.message_type here 885 // we didn't handle the ce.message_type here
888 return false; 886 return false;
889} 887}
@@ -929,7 +927,7 @@ void Ewmh::createAtoms() {
929 m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False); 927 m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False);
930 m_net_restack_window = XInternAtom(disp, "_NET_RESTACK_WINDOW", False); 928 m_net_restack_window = XInternAtom(disp, "_NET_RESTACK_WINDOW", False);
931 929
932 // TODO: implement this one 930
933 m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False); 931 m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False);
934 932
935 m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False); 933 m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False);
diff --git a/src/Window.cc b/src/Window.cc
index b87a9a5..2311634 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1158,8 +1158,6 @@ void FluxboxWindow::updateTitleFromClient(WinClient &client) {
1158 m_labelbuttons[&client]->setText(client.title()); 1158 m_labelbuttons[&client]->setText(client.title());
1159 if (&client == m_client) 1159 if (&client == m_client)
1160 frame().setFocusTitle(client.title()); 1160 frame().setFocusTitle(client.title());
1161
1162 titleSig().notify();
1163 } 1161 }
1164} 1162}
1165 1163
@@ -1734,7 +1732,7 @@ void FluxboxWindow::maximize(int type) {
1734 m_last_resize_w = new_w; 1732 m_last_resize_w = new_w;
1735 m_last_resize_h = new_h; 1733 m_last_resize_h = new_h;
1736 1734
1737 ResizeCorner old_resize_corner = m_resize_corner; 1735 ResizeDirection old_resize_corner = m_resize_corner;
1738 m_resize_corner = NOCORNER; 1736 m_resize_corner = NOCORNER;
1739 fixsize(); 1737 fixsize();
1740 m_resize_corner = old_resize_corner; 1738 m_resize_corner = old_resize_corner;
@@ -2525,6 +2523,7 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) {
2525 client.updateIconTitle(); 2523 client.updateIconTitle();
2526 case XA_WM_NAME: 2524 case XA_WM_NAME:
2527 updateTitleFromClient(client); 2525 updateTitleFromClient(client);
2526 titleSig().notify();
2528 break; 2527 break;
2529 2528
2530 case XA_WM_NORMAL_HINTS: { 2529 case XA_WM_NORMAL_HINTS: {
@@ -2774,12 +2773,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2774 !isResizing()) { 2773 !isResizing()) {
2775 2774
2776 if (! isMoving()) { 2775 if (! isMoving()) {
2777 startMoving(me.window); 2776 startMoving(me.x_root, me.y_root);
2778 // save first event point
2779 m_last_resize_x = me.x_root;
2780 m_last_resize_y = me.y_root;
2781 m_button_grab_x = me.x_root - frame().x() - frame().window().borderWidth();
2782 m_button_grab_y = me.y_root - frame().y() - frame().window().borderWidth();
2783 } else { 2777 } else {
2784 int dx = me.x_root - m_button_grab_x, 2778 int dx = me.x_root - m_button_grab_x,
2785 dy = me.y_root - m_button_grab_y; 2779 dy = me.y_root - m_button_grab_y;
@@ -2854,22 +2848,33 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2854 2848
2855 int cx = frame().width() / 2; 2849 int cx = frame().width() / 2;
2856 int cy = frame().height() / 2; 2850 int cy = frame().height() / 2;
2857 2851 ResizeDirection resize_corner = RIGHTBOTTOM;
2858 if (me.window == frame().gripRight()) 2852 if (me.window == frame().gripRight())
2859 m_resize_corner = RIGHTBOTTOM; 2853 resize_corner = RIGHTBOTTOM;
2860 else if (me.window == frame().gripLeft()) 2854 else if (me.window == frame().gripLeft())
2861 m_resize_corner = LEFTBOTTOM; 2855 resize_corner = LEFTBOTTOM;
2862 else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) { 2856 else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) {
2863 if (screen().getResizeModel() == BScreen::CENTERRESIZE) 2857 if (screen().getResizeModel() == BScreen::CENTERRESIZE)
2864 m_resize_corner = ALLCORNERS; 2858 resize_corner = ALLCORNERS;
2865 else 2859 else
2866 m_resize_corner = RIGHTBOTTOM; 2860 resize_corner = RIGHTBOTTOM;
2867 } else if (me.x < cx) 2861 } else if (me.x < cx)
2868 m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM; 2862 resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
2869 else 2863 else
2870 m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM; 2864 resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
2865
2866
2867 // We are grabbing frame window in startResizing
2868 // we need to translate coordinates to it.
2869 int start_x = me.x, start_y = me.y;
2870 Window child;
2871 XTranslateCoordinates(display,
2872 me.window, fbWindow().window(),
2873 start_x, start_y,
2874 &start_x, &start_y,
2875 &child);
2871 2876
2872 startResizing(me.window, me.x, me.y); 2877 startResizing(start_x, start_y, resize_corner);
2873 2878
2874 } else if (resizing) { 2879 } else if (resizing) {
2875 2880
@@ -3236,10 +3241,16 @@ void FluxboxWindow::setDecorationMask(unsigned int mask) {
3236 applyDecorations(); 3241 applyDecorations();
3237} 3242}
3238 3243
3239void FluxboxWindow::startMoving(Window win) { 3244void FluxboxWindow::startMoving(int x, int y) {
3240 if (s_num_grabs > 0) 3245 if (s_num_grabs > 0)
3241 return; 3246 return;
3242 3247
3248 // save first event point
3249 m_last_resize_x = x;
3250 m_last_resize_y = y;
3251 m_button_grab_x = x - frame().x() - frame().window().borderWidth();
3252 m_button_grab_y = y - frame().y() - frame().window().borderWidth();
3253
3243 moving = true; 3254 moving = true;
3244 maximized = MAX_NONE; 3255 maximized = MAX_NONE;
3245 3256
@@ -3498,11 +3509,13 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
3498} 3509}
3499 3510
3500 3511
3501void FluxboxWindow::startResizing(Window win, int x, int y) { 3512void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) {
3502 3513
3503 if (s_num_grabs > 0 || isShaded() || isIconic() ) 3514 if (s_num_grabs > 0 || isShaded() || isIconic() )
3504 return; 3515 return;
3505 3516
3517 m_resize_corner = dir;
3518
3506 resizing = true; 3519 resizing = true;
3507 maximized = MAX_NONE; 3520 maximized = MAX_NONE;
3508 3521
@@ -3511,7 +3524,8 @@ void FluxboxWindow::startResizing(Window win, int x, int y) {
3511 (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() : 3524 (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() :
3512 frame().theme().lowerLeftAngleCursor(); 3525 frame().theme().lowerLeftAngleCursor();
3513 3526
3514 grabPointer(win, false, ButtonMotionMask | ButtonReleaseMask, 3527 grabPointer(fbWindow().window(),
3528 false, ButtonMotionMask | ButtonReleaseMask,
3515 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); 3529 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
3516 3530
3517 int gx = 0, gy = 0; 3531 int gx = 0, gy = 0;
diff --git a/src/Window.hh b/src/Window.hh
index db3e285..27e8138 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -134,13 +134,18 @@ public:
134 DECORM_LAST = (1<<11) // useful for getting "All" 134 DECORM_LAST = (1<<11) // useful for getting "All"
135 }; 135 };
136 136
137 enum ResizeCorner { 137
138 NOCORNER, 138 enum ResizeDirection {
139 LEFTTOP, 139 NOCORNER = -1,
140 LEFTBOTTOM, 140 LEFTTOP = 0,
141 RIGHTBOTTOM, 141 TOP = 1,
142 RIGHTTOP, 142 RIGHTTOP = 2,
143 ALLCORNERS 143 RIGHT = 3,
144 RIGHTBOTTOM = 4,
145 BOTTOM = 5,
146 LEFTBOTTOM = 6,
147 LEFT = 7,
148 ALLCORNERS = 8
144 }; 149 };
145 150
146 typedef struct _blackbox_hints { 151 typedef struct _blackbox_hints {
@@ -274,6 +279,26 @@ public:
274 279
275 unsigned int decorationMask() const; 280 unsigned int decorationMask() const;
276 void setDecorationMask(unsigned int mask); 281 void setDecorationMask(unsigned int mask);
282 /**
283 * Start moving process, grabs the pointer and draws move rectangle
284 * @param x position of pointer
285 * @param y position of pointer
286 */
287 void startMoving(int x, int y);
288 /**
289 * Stop moving process
290 * @param interrupted whether the move was interrupted by hide or destroy
291 */
292 void stopMoving(bool interrupted = false);
293 /**
294 * Starts resizing process
295 * @param x start position
296 * @param y start position
297 * @param dir the resize direction
298 */
299 void startResizing(int x, int y, ResizeDirection dir);
300 /// stops the resizing
301 void stopResizing(bool interrupted = false);
277 302
278 /** 303 /**
279 @name accessors 304 @name accessors
@@ -410,10 +435,6 @@ private:
410 void updateClientLeftWindow(); 435 void updateClientLeftWindow();
411 void grabButtons(); 436 void grabButtons();
412 437
413 void startMoving(Window win);
414 void stopMoving(bool interrupted = false);
415 void startResizing(Window win, int x, int y);
416 void stopResizing(bool interrupted = false);
417 /// try to attach current attaching client to a window at pos x, y 438 /// try to attach current attaching client to a window at pos x, y
418 void attachTo(int x, int y, bool interrupted = false); 439 void attachTo(int x, int y, bool interrupted = false);
419 440
@@ -452,8 +473,13 @@ private:
452 void associateClient(WinClient &client); 473 void associateClient(WinClient &client);
453 474
454 // state and hint signals 475 // state and hint signals
455 WinSubject m_hintsig, m_statesig, m_layersig, m_workspacesig, 476 WinSubject m_hintsig,
456 m_diesig, m_focussig, m_titlesig, m_attentionsig; 477 m_statesig,
478 m_layersig,
479 m_workspacesig,
480 m_diesig, m_focussig,
481 m_titlesig,
482 m_attentionsig;
457 483
458 class ThemeListener: public FbTk::Observer { 484 class ThemeListener: public FbTk::Observer {
459 public: 485 public:
@@ -524,7 +550,7 @@ private:
524 550
525 FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window") 551 FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window")
526 552
527 ResizeCorner m_resize_corner; 553 ResizeDirection m_resize_corner;
528 554
529 static int s_num_grabs; ///< number of XGrabPointer's 555 static int s_num_grabs; ///< number of XGrabPointer's
530}; 556};