@@ -764,17 +764,39 @@ void mousemotion(const Arg *arg) {
764764
765765 if (!d -> curr -> isfloat && !d -> curr -> istrans ) { d -> curr -> isfloat = True ; tile (d ); focus (d -> curr , d ); }
766766
767+ /* init rectangle properties */
768+ XGCValues gv = { .function = GXinvert , .subwindow_mode = IncludeInferiors , .line_width = BORDER_WIDTH };
769+ GC gc = XCreateGC (dis , root , GCFunction |GCSubwindowMode |GCLineWidth , & gv );
770+
771+ /* draw rectangle */
772+ if (arg -> i == MOVE ) XDrawRectangle (dis , root , gc , xw = wa .x , yh = wa .y , wa .width , wa .height );
773+ else XDrawRectangle (dis , root , gc , wa .x , wa .y , xw = wa .width , yh = wa .height );
774+
767775 do {
768776 XMaskEvent (dis , BUTTONMASK |PointerMotionMask |SubstructureRedirectMask , & ev );
769777 if (ev .type == MotionNotify ) {
778+ /* clear rectangle from prev position */
779+ if (arg -> i == MOVE ) XDrawRectangle (dis , root , gc , xw , yh , wa .width , wa .height );
780+ else if (arg -> i == RESIZE ) XDrawRectangle (dis , root , gc , wa .x , wa .y , xw , yh );
781+
770782 xw = (arg -> i == MOVE ? wa .x :wa .width ) + ev .xmotion .x - rx ;
771783 yh = (arg -> i == MOVE ? wa .y :wa .height ) + ev .xmotion .y - ry ;
772- if (arg -> i == RESIZE ) XResizeWindow (dis , d -> curr -> win ,
773- xw > MINWSZ ? xw :wa .width , yh > MINWSZ ? yh :wa .height );
774- else if (arg -> i == MOVE ) XMoveWindow (dis , d -> curr -> win , xw , yh );
784+
785+ /* draw rectangle in new position */
786+ if (arg -> i == MOVE ) XDrawRectangle (dis , root , gc , xw , yh , wa .width , wa .height );
787+ else if (arg -> i == RESIZE ) XDrawRectangle (dis , root , gc , wa .x , wa .y , xw , yh );
775788 } else if (ev .type == ConfigureRequest || ev .type == MapRequest ) events [ev .type ](& ev );
776789 } while (ev .type != ButtonRelease );
777790
791+ /* clear rectangle from last position */
792+ if (arg -> i == MOVE ) XDrawRectangle (dis , root , gc , xw , yh , wa .width , wa .height );
793+ else if (arg -> i == RESIZE ) XDrawRectangle (dis , root , gc , wa .x , wa .y , xw , yh );
794+
795+ /* actually move/resize the window to the new position/size */
796+ if (arg -> i == RESIZE ) XResizeWindow (dis , d -> curr -> win ,
797+ xw > MINWSZ ? xw :wa .width , yh > MINWSZ ? yh :wa .height );
798+ else if (arg -> i == MOVE ) XMoveWindow (dis , d -> curr -> win , xw , yh );
799+
778800 XUngrabPointer (dis , CurrentTime );
779801}
780802
0 commit comments