aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-03-22 05:13:08 (GMT)
committerrathnor <rathnor>2003-03-22 05:13:08 (GMT)
commit4b2ba8de473c028c16796f5c6cfcd41e97ef239e (patch)
treed67a5b21089d084d9fba3e181d0cd4b7f0dd5813 /src/Window.cc
parent121e135a37c098334d142c5a04990af83fe18b7e (diff)
downloadfluxbox-4b2ba8de473c028c16796f5c6cfcd41e97ef239e.zip
fluxbox-4b2ba8de473c028c16796f5c6cfcd41e97ef239e.tar.bz2
fix outline moving and warping (Simon)
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc68
1 files changed, 49 insertions, 19 deletions
diff --git a/src/Window.cc b/src/Window.cc
index a950ae4..5692008 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.128 2003/03/03 21:51:09 rathnor Exp $ 25// $Id: Window.cc,v 1.129 2003/03/22 05:13:08 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -190,7 +190,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num,
190 // display connection 190 // display connection
191 display = FbTk::App::instance()->display(); 191 display = FbTk::App::instance()->display();
192 192
193 blackbox_attrib.workspace = workspace_number = window_number = -1; 193 blackbox_attrib.workspace = workspace_number = move_ws = window_number = -1;
194 194
195 blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0; 195 blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0;
196 blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; 196 blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0;
@@ -1054,7 +1054,7 @@ void FluxboxWindow::iconify() {
1054void FluxboxWindow::deiconify(bool reassoc, bool do_raise) { 1054void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
1055 if (iconic || reassoc) { 1055 if (iconic || reassoc) {
1056 screen->reassociateWindow(this, screen->getCurrentWorkspace()->workspaceID(), false); 1056 screen->reassociateWindow(this, screen->getCurrentWorkspace()->workspaceID(), false);
1057 } else if (workspace_number != screen->getCurrentWorkspace()->workspaceID()) 1057 } else if (moving || workspace_number != screen->getCurrentWorkspace()->workspaceID())
1058 return; 1058 return;
1059 1059
1060 bool was_iconic = iconic; 1060 bool was_iconic = iconic;
@@ -1120,9 +1120,6 @@ void FluxboxWindow::withdraw() {
1120 visible = false; 1120 visible = false;
1121 iconic = false; 1121 iconic = false;
1122 1122
1123 if (isMoving())
1124 stopMoving();
1125
1126 if (isResizing()) 1123 if (isResizing())
1127 stopResizing(); 1124 stopResizing();
1128 1125
@@ -2065,6 +2062,9 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
2065 2062
2066 2063
2067void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { 2064void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2065 if (isMoving() && me.window == screen->getRootWindow()) {
2066 me.window = m_frame.window().window();
2067 }
2068 if ((me.state & Button1Mask) && functions.move && 2068 if ((me.state & Button1Mask) && functions.move &&
2069 (m_frame.titlebar() == me.window || m_frame.label() == me.window || 2069 (m_frame.titlebar() == me.window || m_frame.label() == me.window ||
2070 m_frame.handle() == me.window || m_frame.window() == me.window) && !isResizing()) { 2070 m_frame.handle() == me.window || m_frame.window() == me.window) && !isResizing()) {
@@ -2084,30 +2084,32 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2084 last_resize_x = me.x_root; 2084 last_resize_x = me.x_root;
2085 last_resize_y = me.y_root; 2085 last_resize_y = me.y_root;
2086 if (moved_x && screen->isWorkspaceWarping()) { 2086 if (moved_x && screen->isWorkspaceWarping()) {
2087 int cur_id = screen->getCurrentWorkspaceID(); 2087 unsigned int cur_id = screen->getCurrentWorkspaceID();
2088 int new_id = cur_id; 2088 unsigned int new_id = cur_id;
2089 const int warpPad = screen->getEdgeSnapThreshold(); 2089 const int warpPad = screen->getEdgeSnapThreshold();
2090 // 1) if we're inside the border threshold
2091 // 2) if we moved in the right direction
2090 if (me.x_root >= int(screen->getWidth()) - warpPad - 1 && 2092 if (me.x_root >= int(screen->getWidth()) - warpPad - 1 &&
2091 m_frame.x() < int(me.x_root - button_grab_x - screen->getBorderWidth())) { 2093 moved_x > 0) {
2092 //warp right 2094 //warp right
2093 new_id = (cur_id + 1) % screen->getCount(); 2095 new_id = (cur_id + 1) % screen->getCount();
2094 dx = - me.x_root; // move mouse back to x=0 2096 dx = - me.x_root; // move mouse back to x=0
2095 } else if (me.x_root <= warpPad && 2097 } else if (me.x_root <= warpPad &&
2096 m_frame.x() > int(me.x_root - button_grab_x - screen->getBorderWidth())) { 2098 moved_x < 0) {
2097 //warp left 2099 //warp left
2098 new_id = (cur_id - 1 + screen->getCount()) % screen->getCount(); 2100 new_id = (cur_id + screen->getCount() - 1) % screen->getCount();
2099 dx = screen->getWidth() - me.x_root-1; // move mouse to screen width - 1 2101 dx = screen->getWidth() - me.x_root-1; // move mouse to screen width - 1
2100 } 2102 }
2101
2102 if (new_id != cur_id) { 2103 if (new_id != cur_id) {
2103 XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0); 2104 XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0);
2104 2105
2105 screen->changeWorkspaceID(new_id); 2106 screen->changeWorkspaceID(new_id);
2106 2107
2107 last_resize_x = me.x_root + dx; 2108 last_resize_x = me.x_root + dx;
2108 2109
2109 // change dx to be relative to window rather than motion event 2110 // dx is the difference, so our new x is what it would have been
2110 dx += m_frame.x(); 2111 // without the warp, plus the difference.
2112 dx += me.x_root - button_grab_x;
2111 } 2113 }
2112 } 2114 }
2113 2115
@@ -2117,7 +2119,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2117 last_move_x, last_move_y, 2119 last_move_x, last_move_y,
2118 m_frame.width() + 2*frame().window().borderWidth(), 2120 m_frame.width() + 2*frame().window().borderWidth(),
2119 m_frame.height() + 2*frame().window().borderWidth()); 2121 m_frame.height() + 2*frame().window().borderWidth());
2120
2121 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2122 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2122 dx, dy, 2123 dx, dy,
2123 m_frame.width() + 2*frame().window().borderWidth(), 2124 m_frame.width() + 2*frame().window().borderWidth(),
@@ -2299,17 +2300,21 @@ bool FluxboxWindow::validateClient() {
2299void FluxboxWindow::startMoving(Window win) { 2300void FluxboxWindow::startMoving(Window win) {
2300 moving = true; 2301 moving = true;
2301 Fluxbox *fluxbox = Fluxbox::instance(); 2302 Fluxbox *fluxbox = Fluxbox::instance();
2302 XGrabPointer(display, win, False, Button1MotionMask | 2303 // grabbing (and masking) on the root window allows us to
2304 // freely map and unmap the window we're moving.
2305 XGrabPointer(display, screen->getRootWindow(), False, Button1MotionMask |
2303 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 2306 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
2304 None, fluxbox->getMoveCursor(), CurrentTime); 2307 None, fluxbox->getMoveCursor(), CurrentTime);
2305 2308
2306 if (m_windowmenu.isVisible()) 2309 if (m_windowmenu.isVisible())
2307 m_windowmenu.hide(); 2310 m_windowmenu.hide();
2308 2311
2309 fluxbox->maskWindowEvents(client.window, this); 2312 move_ws = workspace_number;
2313 fluxbox->maskWindowEvents(screen->getRootWindow(), this);
2310 last_move_x = frame().x(); 2314 last_move_x = frame().x();
2311 last_move_y = frame().y(); 2315 last_move_y = frame().y();
2312 if (! screen->doOpaqueMove()) { 2316 if (! screen->doOpaqueMove()) {
2317 fluxbox->grab();
2313 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2318 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2314 frame().x(), frame().y(), 2319 frame().x(), frame().y(),
2315 frame().width() + 2*frame().window().borderWidth(), 2320 frame().width() + 2*frame().window().borderWidth(),
@@ -2331,6 +2336,11 @@ void FluxboxWindow::stopMoving() {
2331 frame().width() + 2*frame().window().borderWidth(), 2336 frame().width() + 2*frame().window().borderWidth(),
2332 frame().height() + 2*frame().window().borderWidth()); 2337 frame().height() + 2*frame().window().borderWidth());
2333 moveResize(last_move_x, last_move_y, m_frame.width(), m_frame.height()); 2338 moveResize(last_move_x, last_move_y, m_frame.width(), m_frame.height());
2339 if (workspace_number != screen->getCurrentWorkspaceID()) {
2340 screen->reassociateGroup(this, screen->getCurrentWorkspaceID(), true);
2341 m_frame.show();
2342 }
2343 fluxbox->ungrab();
2334 } else 2344 } else
2335 moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); 2345 moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height());
2336 2346
@@ -2341,11 +2351,31 @@ void FluxboxWindow::stopMoving() {
2341} 2351}
2342 2352
2343void FluxboxWindow::pauseMoving() { 2353void FluxboxWindow::pauseMoving() {
2354 if (screen->doOpaqueMove()) {
2355 return;
2356 }
2344 2357
2358 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2359 last_move_x, last_move_y,
2360 m_frame.width() + 2*frame().window().borderWidth(),
2361 m_frame.height() + 2*frame().window().borderWidth());
2362
2345} 2363}
2346 2364
2347 2365
2348void FluxboxWindow::resumeMoving() { 2366void FluxboxWindow::resumeMoving() {
2367 if (screen->doOpaqueMove()) {
2368 return;
2369 }
2370
2371 if (workspace_number == screen->getCurrentWorkspaceID()) {
2372 m_frame.show();
2373 }
2374 XSync(display,false);
2375 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2376 last_move_x, last_move_y,
2377 m_frame.width() + 2*frame().window().borderWidth(),
2378 m_frame.height() + 2*frame().window().borderWidth());
2349 2379
2350} 2380}
2351 2381
@@ -2385,7 +2415,7 @@ void FluxboxWindow::stopResizing(Window win) {
2385 2415
2386 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2416 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2387 last_resize_x, last_resize_y, 2417 last_resize_x, last_resize_y,
2388 last_resize_w - 1 + 2 * m_frame.window().borderWidth(), 2418 last_resize_w - 1 + 2 * m_frame.window().borderWidth(),
2389 last_resize_h - 1 + 2 * m_frame.window().borderWidth()); 2419 last_resize_h - 1 + 2 * m_frame.window().borderWidth());
2390 2420
2391 screen->hideGeometry(); 2421 screen->hideGeometry();