A conditional comnd that tests for a window with titlebar.

On my fvwm, some windows have titlebars, and some do not. I would like to know howto write a conditional command such that it will only run for a window that has a titlebar.

So ,in a perfect world, it might look something like…

ThisWindow (Titled) SomeFunction From the manpage, I see a lot of properties that can be tested for conditional commands, but I don’t see Titled or similar amongst them. So I ask is there another way to do this plz. Or if not with the basic fvwm commands, then can FvwmPerl help with this?

Sorry for the long delay … takes a while to check your problem :blush:

But here’s the solution :wink:

  1. You need an event to tell your function that a new window appears[code]#-----------------------------------------------------------------------

Event Handler

DestroyModuleConfig FvwmEventNewWindow: *
*FvwmEventNewWindow: add_window FE-Notify[/code]
2. The function: [code]DestroyFunc FE-Notify
AddToFunc FE-Notify

  • I Test (!EnvMatch newId $[w.id]) SetEnv newId $[w.id]
  • I TestRc (!Match) Break
  • I SetEnv has_title 0
  • I PipeRead “if [ xwininfo -id $[w.id] -size |grep -c 'y resize increment' = 1 ]; then
    echo SetEnv has_title 1;
  • I Test (EnvMatch has_title 1) echo Title
  • I TestRc (!Match) echo no Title
  • I UnsetEnv has_title
  • I Schedule 3000 UnsetEnv newId[/code]It is a little bit tricky because the add_window event occurs for each available window. to prevent this I set newId with the window id at first appear. All others break the execution.
    To get the info a window has a title we have to check this with xwininfo. The ‘y resize increment’ line occurs only on titled windows. If it is found I set has_title to 1.
    Now I can check whether title is set or not. Instead of ‘echo Title’/‘echo no Title’ replace them with your functions.
    At the end has_title will be removed and 3 seconds later the newId.

Caveat: If you start within the 3 seconds a new app it won’t register.

And last but not least you have to activate the event handler in your StartFunction Module FvwmEvent FvwmEventNewWindow
Have Fun 8)

– Thomas –

I felt sure that fvwm stores info about windows being titled/untitled somewhere. I mean, FvwmIdent obviously has access to that info. But if so, then it may be difficult to get at.

Well I didn’t know you could check for a titlebar with xwininfo. And on the few windows I’ve tested this on, it seems to work okay. So yes, that is good enough to solve my problem for now.

Thanks again Thomas for looking at my problem :slight_smile:

You’re right. FvwmIdent shows this information. To get the same information you should write a FvwmModule with Perl (FvwmPerllib) or C/C++ (Fvwm Module Interface). A good Perl example is module-trackertest. It shows many information. Play a little bit with it or try other examples in this directory.

I found it by chance as I checked the manpage of xprop 8)

You’re welcome :wink:

– Thomas –

The xwininfo method above didn’t work reliably for me. But I found another way to test for the titlebar - something like this… Current PipeRead ' zz=$(( $[w.width] - $[cw.width] )) ; \ uu=$(( $[w.height] - $[cw.height] )) ; \ [ $zz -ne $uu ] && echo "Echo Titled" ; \ [ $zz -eq $uu ] && echo "Echo UnTitled" 'Looking above, you said :-

So I decided to have a go with fvwm-perllib, since I don’t know C. I found that toggling the titlebar always generates a M_CONFIGURE_WINDOW event. So I wrote a test module to dump the values for that event.

use strict;
use warnings ;
use v5.18 ;
use lib fvwm-perllib dir;
use FVWM::Module;

my $numx = 0 ;
say “-----------” ;
my $module = new FVWM::Module(Mask => M_CONFIGURE_WINDOW);

sub testsub {
my ($module, $event) = @;
say “-----”.$numx++."-----\n" ;
foreach (sort keys %{$event->args}) { say $
." ". $event->args->{$_} }
$module->add_handler(M_CONFIGURE_WINDOW, &testsub) ;
$module->event_loop ;[/code]…which yields a typical output of… back_color 1 border_width 0 desk 7 dummy_zero_1 0 dummy_zero_2 0 ewmh_desktop 16777215 ewmh_layer 8421497 ewmh_window_type -1 fore_color 0 frame_height 298 frame_id 8389262 frame_width 501 frame_x 510 frame_y 173 gravity 0 icon_image_id 32767 icon_title_id 32767 layer 4 maximum_height 14 maximum_width 8 minimum_height 14 minimum_width 8 ptr 3220263700 resize_height_inc 14 resize_width_inc 8 title_height 0 win_height 0 win_id 16777225 win_width 0 window_flags tÌ4X%P@ªª
After having experimented, when the titlebar is toggled, it hardly shows in the values above. Some values remain stubbornly 0. frame_width changes with titlebar toggle. And the window_flags always changes with titlebar toggle.

It seems to me that the string from window_flags is actally binary information, a packed version of the various boolean flags that may apply to each window. And I imagine that NoTitle would be one of those flags. But without knowing howto unpack and interprete the window_flags string, that info is basically out of reach.

In short, I’ve concluded that a lot of window info is basically out of reach, even when you are writing an fvwm module.