LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 07-28-2013, 02:57 PM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
Forcing Click-to-focus for TWM using WMCTRL....


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)
*/
Attached Thumbnails
Click image for larger version

Name:	image.png
Views:	160
Size:	24.2 KB
ID:	13092  
Attached Files
File Type: txt twm.txt (5.1 KB, 106 views)

Last edited by Xeratul; 07-28-2013 at 03:14 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse Logitech MX518 loss focus and don't click on the active window. JohnV2 Linux - Hardware 4 12-16-2011 01:26 PM
[SOLVED] When second monitor loses focus, mouse click won't bring it back again rrrssssss Linux - Desktop 2 12-01-2009 05:37 AM
Focus on Click or anything else besides Focus on mouse. mellor Linux - Newbie 2 05-29-2008 11:31 AM
Window focus: where is click-titlebar-to-raise? TristanDee Debian 2 01-17-2008 09:00 AM
click to focus window dynamicit SUSE / openSUSE 0 08-01-2006 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 09:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration