LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Forcing Click-to-focus for TWM using WMCTRL.... (https://www.linuxquestions.org/questions/linux-desktop-74/forcing-click-to-focus-for-twm-using-wmctrl-4175471229/)

Xeratul 07-28-2013 02:57 PM

Forcing Click-to-focus for TWM using WMCTRL....
 
2 Attachment(s)
Hello,

I have been working a bit with TWM, and I must say
that the biggest issue with using TWM is
the need for click to focus, and not following the mouse.

If you mouse is somewhere, no positioned where it should, then, click to focus will be your friend.

A possibility is for instance to map the button
button 2 (middle click) and to "remember" the name of the :ACTIVE: window
using wmctrl.

wmctrl is everywhere. xdotool not. Notice.


So the trick would be to start from .xinitrc a bash script
that would regularly check the set active ("the one that you click on
with button 2 and your setting wmctrl function") window, and if not the
set/selected one, then, to bring the mouse in the center of this window
and re-activate the focus.
It might work on most machines using wmctrl.


Another way is to simply fix that in the source code, which
is not not too hard, but takes time.

Regards




Code:

 
"r" = m : root|window|frame|title : !"grun &"       
"e" = m : root|window|frame|title : !"gentoo &"       
"w" = m : root|window|frame|title : f.delete
"d" = m : root|window|frame|title : f.iconify
"q" = m : root|window|frame|title : f.iconify
"space" = m : root|window|frame|title : f.fullzoom


 

Color
{
BorderColor        "#000000"
DefaultBackground  "#D1D1D1"
DefaultForeground  "#7F7F7F"

TitleBackground    "#005B5B"
TitleForeground    "White"

MenuTitleBackground "#005B5B"
MenuTitleForeground "White"

MenuBackground      "#D1D1D1"
MenuForeground      "#7F7F7F"

MenuShadowColor    "#363636"
MenuBorderColor    "#000000"
}


NoDefaults                        # turn off iconify and resize button
LeftTitleButton "menu12" = f.menu "windowmenu"        # add a menu to each window
TitleButtonBorderWidth 0        # don't want to see box around button
ButtonIndent 0                        # button doesn't have to be smaller




# Pixel width of border around windows.
BorderWidth                        4

AutoRelativeResize                # don't require resize to cross border to start


Button1 =  : root : f.menu "DesktopMenuApps"
# Size of border around desktop icons.
#IconBorderWidth                3

# Desktop-style icons will be put in the following screen region. (we use IconManger instead)
IconRegion                        "72x60+0+0" NORTH EAST 72 72

# Initial location of Icon Manager, colums of icons.
IconManagerGeometry                "700+0-100" 1


# This makes sure child windows have a border and title bar.
DecorateTransients

# Display Icon Manager on startup.
# Sort icons in Icon Manager in alphabetical order.
ShowIconManager
SortIconManager

NoTitleFocus                        # avoid keystrokes in wrong window cause of lag

NoSaveUnders                        # faster to just repaint then save
ConstrainedMoveTime 0                # turn off horizontal/vertical only moving
NoCaseSensitive                        # turn off case-sensitivity in sorting icons


# Named windows will not be shown in Icon Manager
IconManagerDontShow                { "xclock" "Virtual Desktop" }

# Named windows will _not_ go to icon manager, but will have desktop icons.
#DontIconifyByUnmapping                { "xclock" "Virtual Desktop" }


# Length of time to achieve a "double-click" for constained move.
ConstrainedMoveTime                400

"d" = m : root|window|frame|title : f.iconify
Movedelta 1                  # need to move this much before takes effect
Button1=        :title: f.function "raise-lower-move"
Function "raise-lower-move" { f.move f.raiselower    }

Button2 =  : title: f.iconify
Button3 =  : title: f.menu "WindowOpsMenu"



Button2 = m : title: f.iconify
Button3 = m : title: f.move





"KP_Subtract"        = mod5        : all                        : f.colormap "prev"
"KP_Add"        = mod5        : all                        : f.colormap "next"
"KP_Enter"        = mod5        : all                        : f.colormap "default"

# Mouse settings and Window beahviours ------------------------------------------
#
# Button1=left, Button2=middle, Button3=right, m=alt, c=ctrl, s=shift


# Hold alt key and left click to move entiiconifyre window
Button1 =  : icon : f.iconify
Button2 =  : icon : f.iconify
Button3 =  : icon : f.iconify

Button1 = m : icon : f.move
Button2 = m : icon : f.iconify
Button3 = m : icon : f.iconify


# Hold alt key and left click to move entire window
Button1 = m : window : f.function "raise-lower-move"
Button2 = m : window: f.iconify
Button3 = m : window : f.resize




Button1 =  : frame : f.resize





# Title bar buttons

IconDirectory "/home/<myusername>/.twm/icons" # Directory for non default icons
RightTitleButton "minimize.xbm"=f.iconify
RightTitleButton "maximize.xbm"=f.fullzoom
RightTitleButton "close.xbm"=f.delete



# Windows are automatically placed; no need to drag out outline.
RandomPlacement


# Clicking on the desktop brings up the system-wide menu.



Button1 =  : root : f.menu "DesktopMenuApps" 
Button2 = root : f.menu "main"
Button3 = : root : f.menu "TwmWindows"


Function "restart-refresh" { f.refresh f.restart f.refresh }



# Hold Alt and Tab cycles through windows bringing up focus
Function "winup" { f.circleup }
"Tab" = m : root|window|frame|title : f.function "winup"




Menu "WindowOpsMenu" {
        "Iconify"                f.iconify
        "Move .."                f.move
        "Resize..."                f.resize
        "Zoom"                        f.fullzoom
        "Refresh"                f.winrefresh
        ""                        f.nop
        "Close"                        f.delete
        "Kill"                        f.destroy
}


# Hold Alt and Tab cycles through windows bringing up focus
Function "winup" { f.circleup }
"Tab" = m : root|window|frame|title : f.function "winup"
        "Xterm"                        f.exec "xterm -ls -bg black -fg gray85 &"
        "vi"                        f.exec "xterm -ls -bg black -fg gray85 -e vi &"
        ""                        f.nop
        "Restart"                f.restart
        "Exit"                        f.quit
}

Menu "DesktopMenuTools" {
        "Tools"                        f.title
        "Iconify"                f.iconify
        "Maximize"                f.fullzoom
        "Move ..."                f.move
        "Resize ..."                f.resize
        "Refresh"                f.winrefresh
        ""                        f.nop
        "Kill"                        f.destroy
        "Close"                        f.delete
}


 
Menu "DesktopMenuApps" {
        "Applications"                f.title
        "SetBg"                        f.exec "xsetroot -solid 'rgb:2/a/9'"
        "Clock"                        f.exec "xclock -bg 'rgb:2/a/9' -fg black -digital -geometry '-0-0' -padding 0 &"
        ""                        f.nop
        "Xterm"                        f.exec "xterm -ls -bg black -fg gray85 &"
        "vi"                        f.exec "xterm -ls -bg black -fg gray85 -e vi &"
        ""                        f.nop
        "Refresh"                f.refresh
        "Restart"                f.restart
        "Exit"                        f.quit
}



Icons {
        "XTerm"        "terminal"
        "mush"  "mailempty"
        "pine"  "mailempty"
        "Leafpad"        "terminal"
}

 



###############################################################################
#                                                                            #
#    Display an icon manager across the top of the screen.  Don't manage    #
#                the windows for which you don't show a title.                #
#                                                                            #
###############################################################################
 

SortIconManager                        # keep them in alphabetic order
ShowIconManager                        # start with iconmgr up
IconManagerGeometry "4400x50+246+2" 14        # strip across top
IconRegion "200x300+950+2" North East 50 50

IconManagerDontShow                # but ignore these windows

{
  "xclock"
  "xbiff"
  "xload"
  "oclock"
  "xcutsel"
  "XLogout"
}
DontIconifyByUnmapping                # don't lose them (still in TwmWindows menu)
{
  "xclock"
  "xbiff"
  "xload"
  "oclock"
  "xcutsel"
  "Untitled"
}
NoTitle                                # little programs that look like icons
{
  "xclock"
  "xbiff"
  "xload"
  "TWM Icon Manager"
  "xcutsel"
}

NoStackMode                        # prevent hostile clients from hosing display
{
    "saber"
}

WindowRing                        # f.warpring acts along these windows
{
    "XTerm"
    "emacs"
    "Xmh"
}

Button1 =  : iconmgr : f.iconify
Button3 =  : iconmgr : f.menu "WindowOpsMenu"



#NoTitleFocus
WarpCursor

/*
the config is herewith in the tar.gz (mv'ed to txt) and shot has been edited with Linux xpaint (particularly buggy as you may notice)
*/


All times are GMT -5. The time now is 04:42 PM.