all repos — fluxbox @ 10ce5372d99251d65ff0d4e65c6e19cf05bb208a

custom fork of the fluxbox windowmanager

quadrant-resizing (Thanks Mathias Gumz)
rathnor rathnor
commit

10ce5372d99251d65ff0d4e65c6e19cf05bb208a

parent

48cc8772e32ad9cb56a0086840be41e72e94c41e

M ChangeLogChangeLog

@@ -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
M src/FbWinFrameTheme.ccsrc/FbWinFrameTheme.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ Display *disp = FbTk::App::instance()->display();

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() {
M src/FbWinFrameTheme.hhsrc/FbWinFrameTheme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@

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 @@ FbTk::GContext m_button_pic_focus_gc, m_button_pic_unfocus_gc;

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
M src/Screen.ccsrc/Screen.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ antialias(rm, false, scrname+".antialias", altscrname+".Antialias"),

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"),
M src/Screen.hhsrc/Screen.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ inline bool doFullMax() const { return *resource.full_max; }

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 @@ inline int getColPlacementDirection() const { return resource.col_direction; }

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 @@ desktop_wheeling, show_window_pos,

focus_last, focus_new, antialias, auto_raise, click_raises; FbTk::Resource<std::string> rootcommand; + FbTk::Resource<std::string> resizemode; FbTk::Resource<Fluxbox::FocusModel> focus_model; bool ordered_dither; FbTk::Resource<int> workspaces, edge_snap_threshold, menu_alpha;
M src/Window.ccsrc/Window.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ m_client(&client),

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 @@ ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);

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 @@ (((me.state & Button1Mask) && (me.window == frame().gripRight() ||

me.window == frame().gripLeft())) || me.window == frame().window())) { - bool left = (me.window == frame().gripLeft()); + if (! resizing) { + + 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; - if (! resizing) { - startResizing(me.window, me.x, me.y, left); + startResizing(me.window, me.x, me.y); } else if (resizing) { // draw over old rect parent().drawRectangle(screen().rootTheme().opGC(),

@@ -2404,23 +2418,24 @@

// 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(),

@@ -2877,13 +2892,16 @@

} -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 @@ m_last_resize_y = frame().y();

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 @@ m_last_resize_h - 1 + 2 * frame().window().borderWidth());

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::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 @@ frame().handle().borderWidth() : 0);

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 @@

// 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,
M src/Window.hhsrc/Window.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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

@@ -129,6 +129,13 @@ DECORM_SHADE = (1<<8),

DECORM_TAB = (1<<9), DECORM_ENABLED = (1<<10), DECORM_LAST = (1<<11) // useful for getting "All" + }; + + enum ResizeCorner { + LEFTTOP, + LEFTBOTTOM, + RIGHTBOTTOM, + RIGHTTOP }; typedef struct _blackbox_hints {

@@ -366,7 +373,7 @@ void grabButtons();

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 @@ void downsize();

// 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);

@@ -455,6 +461,8 @@ FbTk::XLayerItem m_layeritem;

int m_layernum; FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window") + + ResizeCorner m_resize_corner; ExtraMenus m_extramenus; };