Defocusing any iconified window

Basic FVWM questions can be asked here.
User avatar
lynxlynx
Kitten
Kitten
Posts: 22
Joined: Sun Jan 29, 2017 4:02 pm

Defocusing any iconified window

Postby lynxlynx » Sat May 13, 2017 4:25 pm

Is there a way to completely loose a focus from all windows on current desktop? Both iconified and active.
When I iconify a window, some other window (even iconified) gets focus, and sometimes I do hit random keys by accident, which are then sent to that window, causing unwanted effects.

somiaj
Administrator
Administrator
Posts: 46
Joined: Mon Nov 08, 2004 9:54 pm
Location: Idaho (USA)
Contact:

Re: Defocusing any iconified window

Postby somiaj » Mon May 15, 2017 2:59 am

This has to do with your focus policy. For example, MouseFocus will give focus to the window the mouse is in. If the mouse leaves that window it will loose focus. SloppyFocus or ClickToFocus will not take focus away from a window when the mouse leaves it.

A bit more details is you can configure windows to gain focus on mouse enter or click events, FPEnterToFocus and FPClickToFocus, and loose focus with a mouse leave, FPLeaveToUnfocus. One note if using MouseFocus is you loose focus if the window is visible and the mouse moves out of the window and over the root window. SloppyFocus will not do that.

I don't see a way to tell fvwm to take away focus from all windows outside of the MouseFocus or FPLeaveToUnfocus styles.
-jaimos

User avatar
lynxlynx
Kitten
Kitten
Posts: 22
Joined: Sun Jan 29, 2017 4:02 pm

Re: Defocusing any iconified window

Postby lynxlynx » Mon May 15, 2017 9:05 am

Basically I try to mix both Unix and Windows like behavior when it comes with GUI. Thus I am trying to restore this when it comes to focusing windows. I thought it was possible. Okay, maybe someday later. :)

User avatar
lynxlynx
Kitten
Kitten
Posts: 22
Joined: Sun Jan 29, 2017 4:02 pm

Re: Defocusing any iconified window

Postby lynxlynx » Sat Nov 04, 2017 2:32 pm

The story gets continuation.
I recently was VERY annoyed by the behavior FVWM does with ClickToFocus policy being completely unable to lose a focus to nowhere. Sometimes it happens that focused iconified window gets my random input and, believe me - this is very nasty. Someday I typed password into wrong window. Fortunately it was not a chat window or anything else connected to outside world (password got typed into rxvt window with local shell). This have to be done fixed ASAP I thought at moment.

Since MouseFocus permits completely loosing focus when pointer floats over root window, I first thought to implement same for ClickToFocus. But then I quickly withdrawn the idea because of it is an incompatible change.

I found it is best to implement builtin for that. I used ForceDeleteFocus() inside FVWM to implement DeleteFocus builtin, which does what I exactly want - removes focus from any focused window, and no any window is focused anymore. The builtin approach is best because I can use it in my functions.

I propose a simple patch which adds DeleteFocus builtin. It was made for FVWM 2.6.5. Feel free to discuss the idea and apply patch as you wish. No credits are required.

Code: Select all

--- fvwm-2.6.5.o/fvwm/commands.h
+++ fvwm-2.6.5/fvwm/commands.h
@@ -40,6 +40,7 @@
    F_COPY_MENU_STYLE,
    F_CURRENT,
    F_CURSOR_STYLE,
+   F_DELETEFOCUS,
    F_DESCHEDULE,
    F_DESKTOP_NAME,
    F_DESTROY_FUNCTION,
@@ -279,6 +280,7 @@
 P(FakeKeypress);
 P(FlipFocus);
 P(Focus);
+P(DeleteFocus);
 P(FocusStyle);
 P(Function);
 P(GlobalOpts);
--- fvwm-2.6.5.o/fvwm/focus.c
+++ fvwm-2.6.5/fvwm/focus.c
@@ -1191,6 +1191,13 @@
    return;
 }
 
+void CMD_DeleteFocus(F_CMD_ARGS)
+{
+   ForceDeleteFocus();
+
+   return;
+}
+
 void CMD_WarpToWindow(F_CMD_ARGS)
 {
    int val1_unit, val2_unit, n;
--- fvwm-2.6.5.o/fvwm/functable.c
+++ fvwm-2.6.5/fvwm/functable.c
@@ -177,6 +177,9 @@
       FUNC_NEEDS_WINDOW, CRS_DESTROY),
    /* - Try to delete a window using the X delete protocol */
 
+   CMD_ENT("deletefocus", CMD_DeleteFocus, F_DELETEFOCUS, 0, 0),
+   /* - Remove focus from all windows */
+
    CMD_ENT("deschedule", CMD_Deschedule, F_DESCHEDULE, 0, 0),
    /* - Remove commands sheduled earlier using Schedule */
 

phleagol
Cat in the hat
Cat in the hat
Posts: 41
Joined: Sun Nov 24, 2013 1:19 pm
Location: New Zealand

Re: Defocusing any iconified window

Postby phleagol » Sun Nov 05, 2017 12:07 am

lynxlynx wrote:Is there a way to completely loose a focus from all windows on current desktop? Both iconified and active.
When I iconify a window, some other window (even iconified) gets focus...

I like using NeverFocus to prevent my iconified windows from receiving focus. But to lose focus for all windows on the CurrentDesk, this also works...

Code: Select all

All (CurrentDesk) WindowStyle NeverFocus
UpdateStyles
All (CurrentDesk) WindowStyle ClickToFocus

User avatar
lynxlynx
Kitten
Kitten
Posts: 22
Joined: Sun Jan 29, 2017 4:02 pm

Re: Defocusing any iconified window

Postby lynxlynx » Tue Nov 07, 2017 9:48 am

phleagol wrote:
lynxlynx wrote:Is there a way to completely loose a focus from all windows on current desktop? Both iconified and active.
When I iconify a window, some other window (even iconified) gets focus...

I like using NeverFocus to prevent my iconified windows from receiving focus. But to lose focus for all windows on the CurrentDesk, this also works...

Code: Select all

All (CurrentDesk) WindowStyle NeverFocus
UpdateStyles
All (CurrentDesk) WindowStyle ClickToFocus

Hm, maybe. It is not obvious to me however, hence I invented the command and I continue to use it anyway.
But thanks for the suggestion!


Return to “Basic questions”

Who is online

Users browsing this forum: No registered users and 1 guest