gtk and fvwm questions

Hi all,

I’m working on a gtk application that I want to use in fvwm, but I’m running into a few fvwm specific problems. Hopefully my descriptions make sense, if not just ask for clarification.

  1. When I mouse over a specific widget in my application I want to display a new window and when I leave the widget I want to window to disappear. I am doing this via gtk enter/leave notify events. The code looks something like this:

[code]on_enter_notify_event()
{
gtk_widget_show (mywidget->window);
}

on_leave_notify_event()
{
gtk_widget_hide (mywidget->window);
}
[/code]

The problem is that fvwm seems to quickly switch focus to the new window and back, thus causing the sequence of events to be:

enter_notify_event leave_notify_event enter_notify_event
each time my mouse pointer enters the window. (Note: it should just execute the enter_notify event).

I have tested this in KDE, and it works properly (executing the enter_notify_event once when the mouse enters the widget and the leave event when the mouse leaves the widget).

I was assuming that Fvwm was grabbing focus somehow, so I tried to append some useful looking options to the style of the app, but this didn’t help. This is the style of the popup window I currently have in my .fvwm2rc:

Style popup_window    NoTitle, WindowListSkip, CirculateSkip, NeverFocus, StaysOnTop, NoHandles, GrabFocusOff, StartsRaised, NoPPosition

Obviously this is not working or I wouldn’t be posting. Is there any way I can prevent Fvwm from stealing focus from the main window for the app?

  1. The popup window I described in #1 also should be displayed at a specific position that the application defines. Fvwm seems to want to place it elsewhere. Is there a way to set fvwm to use the application position settings instead of its own?
    I’m setting the window position in my app via:
gtk_widget_set_uposition( widget->window, x, y );

Please show your:

  1. fvwm focus policy
  2. fvwm window placement policy

Also tell us your fvwm version.

I’m using SloppyFocus. Here are the lines in my fvwm2rc that configure my global style:Style * DecorateTransient, NoPPosition, IconBox 20 20 100 -15, IconGrid 3 3, IconFill left top Style * SloppyFocus, MouseFocusClickRaises, TileCascadePlacement, WindowShadeSteps 20 Style * GrabFocusOff, NoIconTitle, !AllowMaximizeFixedSize, FPReleaseFocus, IndexedIconName

I realised just now that I was using NoPPosition globally (which was doing the opposite of what I wanted). Removing this option anwsered my question to #2, although #1 is still open.

I’m using fvwm 2.6.16 on gentoo.

Well, at least SloppyFocus + MouseFocusClickRaises would switch the focus and raising whatever window happens to be under the mouse cursor.
You also have NeverFocus on your popup windows, which does exactly what the option name implies.
I would suggest trying:
Style * FPGrabFocus, FPGrabFocusTransient # grabs focus for newly created windows
And remove the NeverFocus from popup_app

Actually I do want the popup window to never focus. My description above was a little verbose, so it was probably hard to follow. I’ll describe it a little more concise here.

2 windows: main_app and popup

What should happen:

  1. mouse enters main_app
  2. enter_event triggers and popup window appears
  3. mouse leaves main_app
  4. leave_event triggers and popup window disappears

What actually happens:

  1. mouse enters main_app
  2. enter_event, leave_event, and enter_event trigger
    this causes the popup window to appear for a split second and then disappear
  3. mouse leaves main_app and the leave_event triggers again

I decided to try my app with a blank fvwm session and it worked properly, which is good because I know fvwm is capable of handling what I need… now I need to find the bad options in my config.

Ok it looks like I solved my problem but I’m still confused as to why it works.

I have this section in my fvwm2rc:

# FvwmEvent can bind Commands to Events DestroyModuleConfig FvwmEvent: * *FvwmEvent: deiconify DeThumbnail *FvwmEvent: add_window NewWindowFunc *FvwmEvent: new_desk "SendToModule DeskControl ChangeButton desk Title $$[desk.n]"

If I comment out the line:

*FvwmEvent: add_window NewWindowFunc then everything works well.

I’m not really sure why, since thi sis what NewWindowFunc looks like:

[code]#####

Use This to execute commands on new windows as they appear.

########
DestroyFunc NewWindowFunc
AddToFunc NewWindowFunc

  • I ThisWindow (xmessage) Jiggle 2
    #+ I ThisWindow (MyTerm) Maximize
    #+ I ThisWindow (AnnoyingWindow) Close[/code]
    If anyone knows what is happening I’d like to know, if not at least I solved the issue.

This is because Fvwm grabs the pointer before executing any complex function. When the pointer is grabbed an XCrossingEvent with type LeaveNotify and mode NotifyGrab is sent to the application currently having the pointer. Then the function is done executing an EnterNotify with mode NotifyUngrab is generated. GTK lacks ability to check the mode of an XCrossingEvent without using native X checks.

Not only that, but have you actually read the description for Event.{xcrossing,ycrossing}? :) Even the Xlib manual states that it’s difficult to understand, and that most applications won’t hardly ever use it. :)

– Thomas Adam