Trivial feature - "Raise, Move, or Squeeze"

Swirling Vortex <[email protected]> Thu, 19 Dec 2024 11:42:57 -0700
Newsgroups gmane.comp.window-managers.ctwm
Message-ID <[email protected]>
With most window managers, I usually set them up as a 
MacOS/NextStep/WindowMaker style "click the titlebar to raise, drag to 
move, double-click to squeeze/shade it".  So when I started to 
experiment with ctwm, it was one of the first things I tried to replicate.

"f.raiseorsqueeze" comes close by itself, but obviously lacks the "drag" 
functionality, and I couldn't seem to get the right behaviour with a 
function using, say, "f.move f.deltastop f.raiseorsqueeze"-- seemed like 
it was eating the double click somehow.

I cobbled together some of the existing parts to make a handler for a 
new operation "f.raisemoveorsqueeze".  It seems to work pretty well for 
a trifling amount of hacking on an unfamiliar code base. :)

It consists of adding this to functions_win_moveresize.c

DFHANDLER(raisemoveorsqueeze)
{
     /* Raise the window with the "tinyraise" logic */
     if(tmp_win->icon && (w == tmp_win->icon->w) && Context != C_ROOT) {
         OtpTinyRaise(tmp_win, IconWin);
     }
     else {
         OtpTinyRaise(tmp_win, WinWin);
         WMapRaise(tmp_win);
     }

     /* FIXME using the same double-click ConstrainedMoveTime here */
     if((eventp->xbutton.time - last_time) < ConstrainedMoveTime) {
         Squeeze(tmp_win);
         return;
     }
     func = F_MOVEPACK;
     movewindow(EF_ARGS);
}

and then the corresponding details need to be added to 
functions_defs.list and functions_internal.h to expose it as a new 
function.  Obviously, my preferences are visible (defaulting to movepack 
behaviour instead of move)

Semi-related question:  Is there a general way to bind a double-click?  
In fvwm, I set the "delete" commands to only run on a double-click as 
protection against accidentally pressing the button.  I could see adding 
another action that basically falls back to a no-op if a single click is 
recorded to achieve this in ctwm, but if there's a "standard" way to do 
it with configuration, better that than writing one off customizations.  
There's probably a way to do what this does in ctwmrc too, just haven't 
figured it out and went straight to the power tools. :)