From 10ce5372d99251d65ff0d4e65c6e19cf05bb208a Mon Sep 17 00:00:00 2001 From: rathnor Date: Mon, 29 Sep 2003 12:53:58 +0000 Subject: quadrant-resizing (Thanks Mathias Gumz) --- ChangeLog | 2 + src/FbWinFrameTheme.cc | 5 +- src/FbWinFrameTheme.hh | 10 +++- src/Screen.cc | 3 +- src/Screen.hh | 7 ++- src/Window.cc | 132 +++++++++++++++++++++---------------------------- src/Window.hh | 16 ++++-- 7 files changed, 87 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02a7a8d..5576fc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.6: *03/09/29: + * Nearest-quadrant resizing (Thanks Mathias Gumz) + Window.hh/cc Screen.hh/cc FbWinFrameTheme.hh/cc * Update from Han - make startup executable to save one process - make pixmaps-dir diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index 5ac0d3d..67a618d 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrameTheme.cc,v 1.12 2003/09/12 23:37:12 fluxgen Exp $ +// $Id: FbWinFrameTheme.cc,v 1.13 2003/09/29 12:53:58 rathnor Exp $ #include "FbWinFrameTheme.hh" #include "App.hh" @@ -78,7 +78,8 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_cursor_move = XCreateFontCursor(disp, XC_fleur); m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_ll_angle); m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle); - + m_cursor_upper_right_angle = XCreateFontCursor(disp, XC_ur_angle); + m_cursor_upper_left_angle = XCreateFontCursor(disp, XC_ul_angle); } FbWinFrameTheme::~FbWinFrameTheme() { diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index 6b4edd4..712f4be 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrameTheme.hh,v 1.11 2003/09/12 23:37:12 fluxgen Exp $ +// $Id: FbWinFrameTheme.hh,v 1.12 2003/09/29 12:53:58 rathnor Exp $ #ifndef FBWINFRAMETHEME_HH #define FBWINFRAMETHEME_HH @@ -90,6 +90,8 @@ public: inline Cursor moveCursor() const { return m_cursor_move; } inline Cursor lowerLeftAngleCursor() const { return m_cursor_lower_left_angle; } inline Cursor lowerRightAngleCursor() const { return m_cursor_lower_right_angle; } + inline Cursor upperLeftAngleCursor() const { return m_cursor_upper_left_angle; } + inline Cursor upperRightAngleCursor() const { return m_cursor_upper_right_angle; } inline Shape::ShapePlace shapePlace() const { return *m_shape_place; } inline const BorderTheme &border() const { return m_border; } @@ -122,7 +124,11 @@ private: FbTk::Subject m_theme_change; - Cursor m_cursor_move, m_cursor_lower_left_angle, m_cursor_lower_right_angle; + Cursor m_cursor_move; + Cursor m_cursor_lower_left_angle; + Cursor m_cursor_lower_right_angle; + Cursor m_cursor_upper_left_angle; + Cursor m_cursor_upper_right_angle; }; #endif // FBWINFRAMETHEME_HH diff --git a/src/Screen.cc b/src/Screen.cc index ade286d..f2466e3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.234 2003/09/24 14:26:01 rathnor Exp $ +// $Id: Screen.cc,v 1.235 2003/09/29 12:53:58 rathnor Exp $ #include "Screen.hh" @@ -254,6 +254,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, auto_raise(rm, false, scrname+".autoRaise", altscrname+".AutoRaise"), click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), + resizemode(rm, "", scrname+".resizeMode", altscrname+".ResizeMode"), focus_model(rm, Fluxbox::CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), diff --git a/src/Screen.hh b/src/Screen.hh index de25c7d..7e221e3 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.124 2003/09/08 16:37:27 fluxgen Exp $ +// $Id: Screen.hh,v 1.125 2003/09/29 12:53:58 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -92,13 +92,14 @@ public: inline bool doFocusNew() const { return *resource.focus_new; } inline bool doFocusLast() const { return *resource.focus_last; } inline bool doShowWindowPos() const { return *resource.show_window_pos; } - bool antialias() const { return *resource.antialias; } + inline bool antialias() const { return *resource.antialias; } inline FbTk::ImageControl &imageControl() { return *m_image_control.get(); } const FbTk::Menu * const getRootmenu() const { return m_rootmenu.get(); } FbTk::Menu * const getRootmenu() { return m_rootmenu.get(); } inline const std::string &getRootCommand() const { return *resource.rootcommand; } + inline const std::string &getResizeMode() const { return *resource.resizemode; } inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; } inline Slit *slit() { return m_slit.get(); } @@ -170,6 +171,7 @@ public: inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; } inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } + inline void saveResizeMode(std::string resizem) { *resource.resizemode = resizem; } inline void saveFocusModel(Fluxbox::FocusModel model) { resource.focus_model = model; } inline void saveWorkspaces(int w) { *resource.workspaces = w; } @@ -421,6 +423,7 @@ private: focus_last, focus_new, antialias, auto_raise, click_raises; FbTk::Resource rootcommand; + FbTk::Resource resizemode; FbTk::Resource focus_model; bool ordered_dither; FbTk::Resource workspaces, edge_snap_threshold, menu_alpha; 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.234 2003/09/24 14:02:25 rathnor Exp $ +// $Id: Window.cc,v 1.235 2003/09/29 12:53:58 rathnor Exp $ #include "Window.hh" @@ -266,7 +266,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), m_layeritem(m_frame->window(), layer), m_layernum(layer.getLayerNum()), - m_parent(scr.rootWindow()) { + m_parent(scr.rootWindow()), + m_resize_corner(RIGHTBOTTOM) { init(); } @@ -934,10 +935,10 @@ void FluxboxWindow::grabButtons() { XGrabButton(display, Button3, Mod1Mask, frame().window().window(), True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, frame().theme().lowerRightAngleCursor()); + GrabModeAsync, None, None); //---grab with "all" modifiers - grabButton(display, Button3, frame().window().window(), frame().theme().lowerRightAngleCursor()); + grabButton(display, Button3, frame().window().window(), None); } @@ -2389,10 +2390,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { me.window == frame().gripLeft())) || me.window == frame().window())) { - bool left = (me.window == frame().gripLeft()); - if (! resizing) { - startResizing(me.window, me.x, me.y, left); + + int cx = frame().width() / 2; + int cy = frame().height() / 2; + + if (me.window == frame().gripRight()) + m_resize_corner = RIGHTBOTTOM; + else if (me.window == frame().gripLeft()) + m_resize_corner = LEFTBOTTOM; + else if (screen().getResizeMode() != "quadrant") + m_resize_corner = RIGHTBOTTOM; + else if (me.x < cx) + m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM; + else + m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM; + + startResizing(me.window, me.x, me.y); } else if (resizing) { // draw over old rect parent().drawRectangle(screen().rootTheme().opGC(), @@ -2404,24 +2418,25 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { // move rectangle int gx = 0, gy = 0; - m_last_resize_h = frame().height() + (me.y - m_button_grab_y); - if (m_last_resize_h < 1) - m_last_resize_h = 1; - - if (left) { - m_last_resize_x = me.x_root - m_button_grab_x; - if (m_last_resize_x > (signed) (frame().x() + frame().width())) - m_last_resize_x = m_last_resize_x + frame().width() - 1; + int dx = me.x - m_button_grab_x; + int dy = me.y - m_button_grab_y; - left_fixsize(&gx, &gy); + if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { + m_last_resize_h = frame().height() - dy; + m_last_resize_y = frame().y() + dy; } else { - m_last_resize_w = frame().width() + (me.x - m_button_grab_x); - if (m_last_resize_w < 1) // clamp to 1 - m_last_resize_w = 1; + m_last_resize_h = frame().height() + dy; + } - right_fixsize(&gx, &gy); + if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) { + m_last_resize_w = frame().width() - dx; + m_last_resize_x = frame().x() + dx; + } else { + m_last_resize_w = frame().width() + dx; } + fixsize(&gx, &gy); + // draw resize rectangle parent().drawRectangle(screen().rootTheme().opGC(), m_last_resize_x, m_last_resize_y, @@ -2877,13 +2892,16 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) { } -void FluxboxWindow::startResizing(Window win, int x, int y, bool left) { +void FluxboxWindow::startResizing(Window win, int x, int y) { resizing = true; + const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() : + (m_resize_corner == RIGHTTOP) ? frame().theme().upperRightAngleCursor() : + (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() : + frame().theme().lowerLeftAngleCursor(); + XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, None, - (left ? frame().theme().lowerLeftAngleCursor() : frame().theme().lowerRightAngleCursor()), - CurrentTime); + GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); int gx = 0, gy = 0; m_button_grab_x = x; @@ -2893,10 +2911,7 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) { m_last_resize_w = frame().width(); m_last_resize_h = frame().height(); - if (left) - left_fixsize(&gx, &gy); - else - right_fixsize(&gx, &gy); + fixsize(&gx, &gy); if (screen().doShowWindowPos()) screen().showGeometry(gx, gy); @@ -2917,11 +2932,7 @@ void FluxboxWindow::stopResizing(Window win) { screen().hideGeometry(); - if (win && win == frame().gripLeft()) - left_fixsize(); - else - right_fixsize(); - + fixsize(); moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h); @@ -3155,49 +3166,7 @@ void FluxboxWindow::downsize() { } -void FluxboxWindow::right_fixsize(int *gx, int *gy) { - // calculate the size of the client window and conform it to the - // size specified by the size hints of the client window... - int dx = m_last_resize_w - m_client->base_width; - int titlebar_height = (decorations.titlebar ? - frame().titlebar().height() + - frame().titlebar().borderWidth() : 0); - int handle_height = (decorations.handle ? - frame().handle().height() + - frame().handle().borderWidth() : 0); - - int dy = m_last_resize_h - m_client->base_height - titlebar_height - handle_height; - if (dx < (signed) m_client->min_width) - dx = m_client->min_width; - if (dy < (signed) m_client->min_height) - dy = m_client->min_height; - if (m_client->max_width > 0 && (unsigned) dx > m_client->max_width) - dx = m_client->max_width; - if (m_client->max_height > 0 && (unsigned) dy > m_client->max_height) - dy = m_client->max_height; - - // make it snap - - if (m_client->width_inc == 0) - m_client->width_inc = 1; - if (m_client->height_inc == 0) - m_client->height_inc = 1; - - dx /= m_client->width_inc; - dy /= m_client->height_inc; - - if (gx) *gx = dx; - if (gy) *gy = dy; - - dx = (dx * m_client->width_inc) + m_client->base_width; - dy = (dy * m_client->height_inc) + m_client->base_height + - titlebar_height + handle_height; - - m_last_resize_w = dx; - m_last_resize_h = dy; -} - -void FluxboxWindow::left_fixsize(int *gx, int *gy) { +void FluxboxWindow::fixsize(int *gx, int *gy) { int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0); @@ -3207,7 +3176,8 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) { int decoration_height = titlebar_height + handle_height; // dx is new width = current width + difference between new and old x values - int dx = frame().width() + frame().x() - m_last_resize_x; + //int dx = frame().width() + frame().x() - m_last_resize_x; + int dx = m_last_resize_w - m_client->base_width; // dy = new height (w/o decorations), similarly int dy = m_last_resize_h - m_client->base_height - decoration_height; @@ -3247,7 +3217,15 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) { // update last resize m_last_resize_w = dx; m_last_resize_h = dy; + + if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) { m_last_resize_x = frame().x() + frame().width() - m_last_resize_w; + } + + if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) { + m_last_resize_y = frame().y() + frame().height() - m_last_resize_h; + } + } void FluxboxWindow::resizeClient(WinClient &client, diff --git a/src/Window.hh b/src/Window.hh index 8c2fe46..e023253 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.95 2003/09/24 14:02:25 rathnor Exp $ +// $Id: Window.hh,v 1.96 2003/09/29 12:53:58 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -131,6 +131,13 @@ public: DECORM_LAST = (1<<11) // useful for getting "All" }; + enum ResizeCorner { + LEFTTOP, + LEFTBOTTOM, + RIGHTBOTTOM, + RIGHTTOP + }; + typedef struct _blackbox_hints { unsigned long flags, attrib, workspace, stack; int decoration; @@ -366,7 +373,7 @@ private: void startMoving(Window win); void stopMoving(); - void startResizing(Window win, int x, int y, bool left); + void startResizing(Window win, int x, int y); void stopResizing(Window win=0); void updateIcon(); /// try to attach current attaching client to a window at pos x, y @@ -391,8 +398,7 @@ private: // modifies left and top if snap is necessary void doSnapping(int &left, int &top); - void right_fixsize(int *x = 0, int *y = 0); - void left_fixsize(int *x = 0, int *y = 0); + void fixsize(int *x = 0, int *y = 0); void resizeClient(WinClient &client, unsigned int width, unsigned int height); /// sends configurenotify to all clients void sendConfigureNotify(bool send_to_netizens = true); @@ -456,6 +462,8 @@ private: FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window") + ResizeCorner m_resize_corner; + ExtraMenus m_extramenus; }; -- cgit v0.11.2