Sloppy Focus and desktop switch

Hi,

I’m using sloppy focus as focus policy. When i try to switch to another desktop(using keybinding) and comeback the focus changes to the window where the pointer is. How to keep the focus to the same window that had focus. Couldn’t figure out with focus settings.

Let me describe in little more detail:
I have xterm and gvim on desk 0, initially focus and pointer are with xterm, now change the focus to gvim with M+tab. I don’t use pointer warping to focused window, pointer still resides above xterm. now change to another desktop(with GotoDesk) say desk 1 running ddd debugger, then switch back to desk 0. Now instead of gvim the focus shifts to xterm. It’s annoying that i type into xterm instead of gvim. (Typing is little ok, but sometime when i close the focused window after switching back with keybinding often wrong window is being closed making me nervous). Is there any setting i could use to get the desired behaviour.

Have attempted to get the functionality with the following config, this mostly works as needed, with a glitch.

Same as above xterm and gvim on desk 0, pointer on xterm, change focus to gvim, switch to desk 1, switch back to desk 0. with this config the focus stays with gvim, and pointer above xterm, the expected behaviour. With the normal case when i continue to work in gvim after switching back no issues. but for some reason(like after switching to desk 1running ddd, came to know that forgot to make after code edit), i want to focus the xterm on desk 0 with mouse(remember the pointer is still above xterm) the click and mouse moves don’t focus xterm until the mouse pointer goes out of that window. ie i need to move the mouse outside xterm to root window or gvim and come back to focus the xterm. Please guide me how to fix this.

DestroyFunc SwitchToDesk
AddToFunc SwitchToDesk

  • I All (CurrentDesk) State 1 False
  • I Current State 1 True
    #+ I Current Echo $[w.id]
  • I GotoDesk $0 $1

DestroyFunc SwitchDesk
AddToFunc SwitchDesk

  • I Next (CurrentDesk, State 1) Focus

DestroyModuleConfig DeskSwitch: *
*DeskSwitch: Cmd
*DeskSwitch: new_desk SwitchDesk
Module FvwmEvent DeskSwitch

Sorry for the verbose post, wanted to convey the issue completely.

Thanks,
venkatesh

That’s because there aren’t any. Here’s my approach to this:

DestroyModuleConfig a:*
*a: new_page FuncFoo
*a: new_desk FuncFoo

AddToFunc StartFunction I Module FvwmEvent a

DestroyFunc FuncFoo
AddToFunc FuncFoo
+ I NoWindow Prev (CurrentPage, !Focused, AcceptsFocus) Focus

Trying to use “State” is always a bad thing because it would assume a window context when applying it before switching pages/desks, which means that if you had no window focused, you’ll be asked for one.

– Thomas Adam

Thomas,

Thanks for the quick response and script. Infact I’m using your fvwm-starter-kit script with some modifications.

Quite often i closed the wrong app after switching. So in the meantime i have come with FvwmEvent and State with my limited knowledge for consistency with past habits :slight_smile:

I have tried with the config you posted, but it seems the focus change works only for two windows. Please correct me if i’m wrong. I want to have the last focused window to be focused regardless of the number of windows.

Figured out for the glitch i have mentioned earlier, adding
Style * FPClickToFocus, FPClickDecorToFocus
helped.

Waiting for your further comment. Still I’d prefer anything simpler than mine. I may be missing something as i refer back and forth with the manpage.

Thanks,
venkatesh

[/quote]

What is this fvwm-starter-kit you speak of? I’ve written no such thing.

Close the wrong window how? That has nothing to do with your original question.

It works fine for me – would need to see how you’ve shoe-horned it in to your config though.

– Thomas Adam

Have taken from github.com/ThomasAdam/Fvwm-Starter-s-Kit.git.
So thanked for that.

I was just mentioning earlier config with SloppyFocus alone, that prompted me to ask here.

I’ve just pasted the snippet into file named test, restarted, will see if i have messed somewhere else with my changes.

Thanks,
venkatesh

That’s not mine. I forked it originally to ensure the people working on it didn’t fuck up and worse yet suggest bad information. Since that point though, I do not recall what happened to it. Needless to say, what you’re using is old, there’s a newer version of that stuff somewhere else, and the product is not mine.

– Thomas Adam

Sorry for the misunderstanding, I just assumed it to be yours given the name. I used that as a starting point until i’m ready with a usable config of mine. I don’t mind much about the decors. Initially I’m configuring the navigation and learning the config in bits and pieces. If you don’t mind can you share your config.

Thanks,
venkatesh

There is a (relatively old) link to his configuration on the main Fvwm website here.

Thanks,

will look into it and get back to you.

Regards,
venkatesh

Thomas,

I have tried this with a new simple config,
1)Initially window1 has focus and pointer, change to another window2 with M+Tab(now focus on window2, but pointer above window1), switch to desk1, comeback to desk0 window2 still has focus, as expected

  1. But this breaks if i use mouse to focus(sloppy focus), initailly window1 has focus and pointer, change focus by mouse move above window2(focus and pointer above window2 now), switch to desk1, comeback to desk0 now window1 is being focused instead of window2.

I need the last focused window to get focus after a deskswitch, regardless of the method to focus(mouse or keyboard).

from my first post

.
I asked for this behaviour, but possibly i didn’t convey it properly.

Please let me know if i made something wrong.

the simple config

[code]ImagePath $[FVWM_USERDIR]/icons;.png:+:$[FVWM_USERDIR]/icons/48;.png:+:$[FVWM_USERDIR]/icons/16;.png:+:$[FVWM_USERDIR]/backdrops

ExecUseShell

ColormapFocus FollowsMouse

CleanupColorsets
Colorset 0 fg rgb:00/00/00, bg rgb:ae/b2/c3, hi rgb:dd/de/e6, sh rgb:5e/60/69, Plain, NoShape
Colorset 1 fg rgb:ff/ff/ff, bg rgb:b2/4d/7a, hi rgb:dc/ad/c2, sh rgb:57/25/3c, Plain, NoShape

DefaultColorset 0
DefaultFont -adobe-helvetica-medium-r---12-------*

EwmhBaseStruts 50 0 0 0

MenuStyle * Mwm, MenuColorset 0

EdgeResistance -1
EdgeThickness 1
EdgeCommand Top WindowList (CurrentPage) NoGeometry, NoIcons

IgnoreModifiers 2L
HideGeometryWindow Never

Style * LowerTransient, RaiseTransient, StackTransientParent

Emulate Mwm
Style * MwmBorder, MwmDecor, MwmFunctions, MwmButtons
Style * DecorateTransient, NoPPosition

Style * BorderWidth 6, HandleWidth 6
Style * BorderColorset 0
Style * HilightBorderColorset 1
Style * IconBackgroundColorset 0
Style * IconBackgroundPadding 0

TitleStyle Centered Height 22

Style * SnapAttraction 16 SameType Screen
Style * SnapGrid 16 9

DesktopSize 1x1
DesktopName 0 Main
DesktopName 1 Work
DesktopName 2 Network
DesktopName 3 Misc

Style * SloppyFocus
Style * FPGrabFocus, FPReleaseFocus

Style * Colorset 0
Style * HilightColorset 1
Style * DecorateTransient, ResizeOpaque

ButtonStyle 2 Vector 5 25x25@1 25x75@1 75x75@0 75x25@0 25x25@1
ButtonStyle 4 Vector 5 40x40@1 60x40@1 60x60@0 40x60@0 40x40@1
ButtonStyle 1 Vector 5 25x40@1 75x40@1 75x60@0 25x60@0 25x40@1

Key Tab A M WindowList (CurrentPage) Root c c NoGeometry, CurrentAtEnd, NoIcons
Key Tab A 4 WindowList Root c c NoGeometryWithInfo, CurrentAtEnd, SelectOnRelease Super_L, NoCurrentDeskTitle, TitleForAllDesks
Key Grave A M WindowList ($[w.class]*) Root c c NoGeometry, CurrentAtEnd, NoIcons, SelectOnRelease Meta_L, NoCurrentDeskTitle, TitleForAllDesks
Key Grave M M MenuMoveCursor 1

Key a A 4 Menu MenuFvwmRoot
Key c W 4 Close
Key h A 4 Maximize 100 0
Key i A 4 All ($[w.class]*) HideWin
Key m A M Module FvwmConsole
Key q A 4 HideWin
Key s A 4 WindowShade
Key t A S4 WinOnTop
Key v A 4 Maximize 0 100
Key w A 4 WindowList NoGeometryWithInfo, NoCurrentDeskTitle, TitleForAllDesks
Key x A 4 Maximize 100 100
Key z A 4 Iconify
Key l A 4 Restart
Key Delete A CM Quit

Key 1 A 4 GotoDesk 0 0
Key 2 A 4 GotoDesk 0 1
Key 3 A 4 GotoDesk 0 2
Key 4 A 4 GotoDesk 0 3

Key F1 A 4 MovetoDesk 0 0
Key F2 A 4 MovetoDesk 0 1
Key F3 A 4 MovetoDesk 0 2
Key F4 A 4 MovetoDesk 0 3

Key KP_Home W 4 Move +0 +0
Key KP_Up W 4 Move 50-50w +0
Key KP_Prior W 4 Move -0 +0
Key KP_Left W 4 Move +0 50-50w
Key KP_Begin W 4 Move 50-50w 50-50w
Key KP_Right W 4 Move -0 50-50w
Key KP_End W 4 Move +0 -0
Key KP_Down W 4 Move 50-50w -0
Key KP_Next W 4 Move -0 -0

Mouse [(window)] Button Context Modifiers Function

Mouse 1 R A Menu FvwmMenuRoot
Mouse 2 R A WindowList NoGeometryWithInfo, NoIcons, NoCurrentDeskTitle, TitleForAllDesks
Mouse 3 RFT A Menu FvwmMenuWindowOps

Mouse 0 1 A FuncWindowOpsOrClose

Mouse 1 2 N Maximize
Mouse 2 2 N Maximize 0 100
Mouse 3 2 N Maximize 100 0

Mouse 1 4 A Iconify
Mouse 3 4 A FuncIconifySameResource $[w.resource]

Mouse 1 I A Iconify
Mouse 3 I A Nop

Style xterm Icon terminal
Style xterm MiniIcon 16/terminal

Functions

DestroyFunc WindowListFunc
AddToFunc WindowListFunc

  • I Iconify off
  • I FlipFocus
  • I Raise

DestroyFunc StartFunction
AddToFunc StartFunction

  • I Exec exec xsetroot -solid “rgb:63/63/9c”
  • I Module FvwmEvent a

AddToFunc FuncIconifySameResource

  • I All ($0) Iconify on

DestroyFunc FuncWindowOpsOrClose
AddToFunc FuncWindowOpsOrClose

  • H Menu FvwmMenuWindowOps
  • C Menu FvwmMenuWindowOps
  • D Close

DestroyMenu “FvwmMenuRoot”
AddToMenu “FvwmMenuRoot” “Root Menu” Title

  • “X &Terminal” Exec exec xterm
  • “&Gvim” Exec exec gvim
  • “&Firefox” Exec exec /opt/firefox/firefox -P venba
  • “&Xfe FileManager” Exec exec xfe

DestroyMenu “FvwmMenuWindowOps”
AddToMenu “FvwmMenuWindowOps” “WindowOps” Title

  • “&Close” Close

DestroyModuleConfig a:*
*a: new_page FuncFoo
*a: new_desk FuncFoo

DestroyFunc FuncFoo
AddToFunc FuncFoo

  • I NoWindow Prev (CurrentPage, !Focused, AcceptsFocus) Focus

vi: set ai sw=4 ts=4:[/code]

Thanks,
venkatesh

Thomas,

Tried to incorporate without state variable for last focused window, but somehow could not make it as needed without State , Attaching the config that works as needed, still work in progress though, please look into that for any errors or suggestions.

Running from cvs 30th aug, move with EWMH area nicely. Thanks.
With
move x y
this works,

It would be nice if interactive move provides some resistance to EWMH strut area.

[code]# Simple Fvwm Configuration for Fvwm version 2.6, heavily borrowed from other fellow Fvwm users,

Fvwm FAQ and Forum postings

For monitor size 1920x1080, Using 10% of horizontal space for icons and, pager etc.

Using 48 pixel icons on left + 2 * 2 pixel borders => 52 pixels + 4 pixels margin,

Pager width 1920/15 = 128 pixels + 2 * 2 pixel borders => 132 pixels + 4 pixels margin

Yields working area with aspect ratio 16:10

Change this as needed for different sized monitor

SetEnv MarginLeft 56
SetEnv MarginRight 136

ImagePath $[FVWM_USERDIR]/icons;.png:+:$[FVWM_USERDIR]/icons/48;.png:+:$[FVWM_USERDIR]/icons/16;.png:+:$[FVWM_USERDIR]/backdrops

ExecUseShell /opt/ast/bin/ksh

ClickTime 240

ColormapFocus FollowsMouse

CleanupColorsets

color values taken from CDE dtstyle -color, hilight and shadow colors picked with gimp color picker

Colorset 0 fg rgb:00/00/00, bg rgb:ae/b2/c3, hi rgb:dd/de/e6, sh rgb:5e/60/69, Plain, NoShape
Colorset 1 fg rgb:ff/ff/ff, bg rgb:b2/4d/7a, hi rgb:dc/ad/c2, sh rgb:57/25/3c, Plain, NoShape

DefaultColorset 0
DefaultFont -adobe-helvetica-medium-r---12-------*

EwmhBaseStruts $[MarginLeft] $[MarginRight] 0 0

MenuStyle * Mwm, MenuColorset 0

Edge settings

EdgeThickness 1
EdgeScroll 0 0
Style * EdgeMoveDelay 250
Style * EdgeMoveResistance 20

IgnoreModifiers 2L
HideGeometryWindow Never
OpaqueMoveSize -1

Emulate Mwm
Style * MwmBorder, MwmDecor, MwmFunctions, MwmButtons
Style * DecorateTransient, NoPPosition

Style * BorderWidth 6, HandleWidth 6
Style * BorderColorset 0
Style * HilightBorderColorset 1
Style * IconBackgroundColorset 0
Style * IconBackgroundPadding 0

TitleStyle Centered Height 22

Style * SnapAttraction 4 SameType Screen
Style * SnapGrid 4 4

DesktopSize 3x3
DesktopName 0 Main
DesktopName 1 Work
DesktopName 2 Network
DesktopName 3 Misc

Style * SloppyFocus
Style * FPGrabFocus, FPReleaseFocus
Style * FPClickToFocus, FPClickDecorToFocus

Style * Colorset 0
Style * HilightColorset 1
Style * DecorateTransient, ResizeOpaque
Style * MinOverlapPlacement
#Style * Font -adobe-helvetica-medium-r---12-------*

ButtonStyle 2 Vector 5 25x25@1 25x75@1 75x75@0 75x25@0 25x25@1
ButtonStyle 4 Vector 5 45x45@1 55x45@1 55x55@0 45x55@0 45x45@1
ButtonStyle 1 Vector 5 25x45@1 75x45@1 75x55@0 25x55@0 25x45@1

Key bindings

Key Tab A M WindowList (CurrentPage) Root c c NoGeometry, CurrentAtEnd, NoIcons
Key Tab A 4 WindowList Root c c NoGeometryWithInfo, CurrentAtEnd, SelectOnRelease Super_L, NoCurrentDeskTitle, TitleForAllDesks
Key Grave A M WindowList ($[w.class]*) Root c c NoGeometry, CurrentAtEnd, NoIcons, SelectOnRelease Meta_L, NoCurrentDeskTitle, TitleForAllDesks
Key Grave M M MenuMoveCursor 1

Key a A 4 Menu FvwmRootMenu
Key c W 4 Close
Key h A 4 Maximize 100 0
Key u A 4 All ($[w.class]*) HideWin
Key m A M Module FvwmConsole
Key q A 4 HideWin
Key r A 4 Exec exec dmenu_run
Key s A 4 WindowShade
Key v A 4 Maximize 0 100
Key w A 4 WindowList NoGeometryWithInfo, NoCurrentDeskTitle, TitleForAllDesks
Key x A 4 Maximize 100 100
Key x A S4 Maximize ewmhiwa
Key z A 4 Iconify
Key h A 4 Direction West (CurrentPage, AcceptsFocus, Visible) Focus
Key j A 4 Direction South (CurrentPage, AcceptsFocus, Visible) Focus
Key k A 4 Direction North (CurrentPage, AcceptsFocus, Visible) Focus
Key l A 4 Direction East (CurrentPage, AcceptsFocus, Visible) Focus
Key n A 4 Next (CurrentPage, AcceptsFocus, Visible) Focus
Key y A 4 Restart
Key Delete A CM Quit

Key 1 A 4 SwitchToPage 0 0
Key 2 A 4 SwitchToPage 1 0
Key 3 A 4 SwitchToPage 2 0
Key 4 A 4 SwitchToPage 0 1
Key 5 A 4 SwitchToPage 1 1
Key 6 A 4 SwitchToPage 2 1
Key 7 A 4 SwitchToPage 0 2
Key 8 A 4 SwitchToPage 1 2
Key 9 A 4 SwitchToPage 2 2

For versions prior to fvwm 2.6.3 20110830

#Key KP_Home A 4 Move +$[MarginLeft]p +0
#Key KP_Up A 4 Move 50-50w-$[MarginLeft]p +0
#Key KP_Prior A 4 Move -$[MarginRight]p +0
#Key KP_Left A 4 Move +$[MarginLeft]p 50-50w
#Key KP_Begin A 4 Move 50-50w-$[MarginLeft]p 50-50w
#Key KP_Right A 4 Move -$[MarginRight]p 50-50w
#Key KP_End A 4 Move +$[MarginLeft]p -0
#Key KP_Down A 4 Move 50-50w-$[MarginLeft]p -0
#Key KP_Next A 4 Move -$[MarginRight]p -0

For versions fvwm 2.6.3 20110830 and later that respect ewmhiwa for Move operation

Key KP_Home A 4 Move +0 +0
Key KP_Up A 4 Move 50-50w +0
Key KP_Prior A 4 Move -0 +0
Key KP_Left A 4 Move +0 50-50w
Key KP_Begin A 4 Move 50-50w 50-50w
Key KP_Right A 4 Move -0 50-50w
Key KP_End A 4 Move +0 -0
Key KP_Down A 4 Move 50-50w -0
Key KP_Next A 4 Move -0 -0

Key Left A 4 Scroll -10 +0 reverse
Key Right A 4 Scroll +10 +0 reverse
Key Up A 4 Scroll +0 -10 reverse
Key Down A 4 Scroll +0 +10 reverse

Mouse [(window)] Button Context Modifiers Function

Mouse 1 R A Menu FvwmRootMenu
Mouse 2 R A WindowList NoGeometryWithInfo, NoIcons, NoCurrentDeskTitle, TitleForAllDesks
Mouse 3 RFT A Menu FvwmWindowOpsMenu

Mouse 0 1 A FuncWindowOpsOrClose

Mouse 1 2 N Maximize
Mouse 2 2 N Maximize 0 100
Mouse 3 2 N Maximize 100 0
Mouse 1 2 M Maximize ewmhiwa

Mouse 1 4 A Iconify
Mouse 3 4 A FuncIconifySameResource $[w.resource]

Mouse 1 I A FuncIconMovesOrDeIconify
Mouse 3 I A Menu FvwmWindowOpsMenu

Mouse 1 W M FvwmMoveOrRaise
Mouse 3 W M FvwmResizeOrRaise

Mouse 1 A 4 Scroll reverse

Style xterm Icon terminal
Style xterm MiniIcon 16/terminal
style xclock !Title, !Handles, BorderWidth 0, Sticky, WindowListSkip, Layer 0

Functions

DestroyFunc StartFunction
AddToFunc StartFunction

  • I Test (Init) Exec exec xsetroot -solid “rgb:63/63/9c”
  • I Test (Init) Exec exec xclock -geometry -0+0
  • I Module FvwmEvent UpdateFocus

DestroyFunc WindowListFunc
AddToFunc WindowListFunc

  • I DeIconify
  • I FlipFocus
  • I Raise

DestroyFunc EWMHActivateWindowFunc

DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc

  • I Iconify off
  • I FlipFocus
  • I Raise

DestroyFunc DeIconify
AddToFunc DeIconify

  • I WindowStyle Icon
  • I Iconify false

AddToFunc FuncIconifySameResource

  • I All ($0) Iconify true

DestroyFunc FuncWindowOpsOrClose
AddToFunc FuncWindowOpsOrClose

  • H Menu FvwmWindowOpsMenu
  • C Menu FvwmWindowOpsMenu
  • D Close

DestroyFunc FuncIconMovesOrDeIconify
AddToFunc FuncIconMovesOrDeIconify

  • M Move
  • D Iconify false

DestroyFunc HideWin
AddToFunc HideWin

  • I WindowStyle !Icon
  • I Iconify true

DestroyFunc SwitchToPage
AddToFunc SwitchToPage

  • I All (CurrentPage) State 31 false
  • I Current State 31 true
  • I GotoPage $0 $1

DestroyFunc FocusLastWindow
AddToFunc FocusLastWindow

  • I Next (CurrentPage, State 31) Focus

DestroyFunc FvwmMoveOrRaise
AddToFunc FvwmMoveOrRaise

  • I Raise
  • M Move

DestroyFunc FvwmResizeOrRaise
AddToFunc FvwmResizeOrRaise

  • I Raise
  • M Resize Direction automatic

DestroyMenu “FvwmRootMenu”
AddToMenu “FvwmRootMenu” “Root Menu” Title

  • “X &Terminal” Exec exec xterm
    #+ “X &Terminal” Exec exec xterm -e tmux a
  • “&Gvim” Exec exec gvim
  • “&Firefox” Exec exec /opt/firefox/firefox -P venba
  • “Xf&e FileManager” Exec exec xfe
  • “Qa&lculate” Exec exec qalculate
  • “” Nop
  • “Log out…” Quit
  • “” Nop
  • “Power Off…” Exec exec poweroff

DestroyMenu “FvwmWindowOpsMenu”
AddToMenu “FvwmWindowOpsMenu” “Window Operations” Title

  • “&Move” Pick Move
  • “&Resize” Pick Resize
  • “R&aise” Raise
  • “&Lower” Lower
  • “(De)&Iconify” Iconify
  • “(Un)&Stick” Stick
  • “(Un)Ma&ximize”
  • “” Nop
  • “&Close” Close

DestroyModuleConfig UpdateFocus: *
*UpdateFocus: Cmd
*UpdateFocus: new_page FocusLastWindow

Style FvwmPager !Title, !Handles, Sticky, WindowListSkip, BorderWidth 2, StaysOnTop,
Style FvwmPager Layer 0

DestroyModuleConfig FvwmPager *
FvwmPager: Rows 1
FvwmPager: Columns 1
FvwmPager: Geometry -0+354
FvwmPager: DeskTopScale 45
FvwmPager: UseSkipList
FvwmPager: Balloons All
FvwmPager: MiniIcons null
FvwmPager: Font -adobe-helvetica-medium-r--
-10-
-
-
-
-
-
-*
FvwmPager: SmallFont none
FvwmPager: BalloonBorderWidth 1
FvwmPager: BalloonYOffset -3
FvwmPager: BalloonFont -adobe-helvetica-medium-r--
-10-
-
-----*
*FvwmPager: BalloonFore rgb:ff/f7/e9
*FvwmPager: BalloonBack rgb:30/30/4c
*FvwmPager: BalloonBorderColor rgb:ff/f7/e9
*FvwmPager: Fore rgb:ff/f7/e9
*FvwmPager: Hilight rgb:63/63/9c
*FvwmPager: Back rgb:63/63/9c

Module FvwmPager 0 3

#References:

http://fvwm.org/documentation/faq/

http://fvwmwiki.xteddy.org/

http://www.zensites.net/fvwm/guide/index.html

http://fvwm.org/screenshots/desktops/Tavis_Ormandy-desk-1152x864/fvwmrc

vi: set ai sw=4 ts=4 syntax=fvwm: [/code]


Regards,
venkatesh

No, it wouldn’t. I toyed with this idea, but it ends up making switching pages/desks a lot harder.

– Thomas Adam

That’s fine.

Can you look into my config, i can’t get the focus issue solved without State. Can you point where i’m making mistake. I tried to incorporate your code snippet as mentioned before. Couldn’t get it to work, so went back to State based method for time being.

Thanks,
venkatesh