hacking x11 protocol

Glynn Clements glynn at gclements.plus.com
Tue Feb 6 06:44:39 PST 2007

Lucio Crusca wrote:

> I'm a newbie here. Here is my problem:
> My customer asked me to setup a linux system so that it loops some flash 
> movies all the time (commercials).
> Adobe has recently released a standalone flash player for linux 
> (http://download.macromedia.com/pub/flashplayer/updaters/9/flash_player_9_linux_dev.tar.gz). 
> Quite a dumb one to be honest (it doesn't even support a playlist). So I've 
> written a bash script that fires up the Adobe player once for each SWF file 
> in a given directory. Each SWF file is a fullscreen commercial ."Fullscreen" 
> is an attribute (or something like that) embedded in the SWF file.
> The problem is that when my script opens a new instance of the player, the 
> player first displays its window for a fraction of a second and then goes 
> fullscreen. That's quite ugly to see between commercials.
> Now the fu**ed Adobe player is closed source, non free and whatever, so I 
> can't patch it (besides, I could happen to lack the skills...). I was 
> wondering if it was possible to hack the X11 protocol with a local protocol 
> forwarder to force every window not to show its frame and to open up 
> fullscreen from scratch.
> Can you point me in the right direction please? Or have you got better ideas 
> on how to solve the problem with something maybe already present in XOrg?

This is what window managers are for.

Many window managers will let you do this simply through
configuration; no code required. Typically, you first need to find out
the "name" of the window using xprop. Then, you add something to the
WM's config file (exactly what depends upon which WM you are using) to
tell it that any window with that name should have a specific size
(the size of the screen), position ((0,0), i.e. the top-left corner)
and no title bar, border, or other decorations. If the WM doesn't
provide an option to force the size, the player might allow the
size/position to be specified via the -geometry switch.

If you can't figure out how to do this with an existing WM, you can
write your own without too much trouble (certainly, less trouble than
hacking the X server or Xlib). Essentially, you need to use
XSelectInput on the root window with a mask of SubstructureRedirectMask.

Thereafter, any attempt by X clients to map, unmap, move, resize,
raise or lower top-level windows will result in the corresponding
event (CirculateRequest, ConfigureRequest, and MapRequest) being
delivered to your WM. The WM then gets to decide what to do with it;
e.g. if you get a MapRequest event, you resize the window to the size
of the screen (with XConfigureWindow) then map it (with XMapWindow).

The only exception is for windows with the override_redirect flag set. 
Flash Player *might* use this flag when creating its full-screen
window; you don't actually need to do anything about that, but you
might need to be aware of it (e.g. don't assume that your WM will be
told about the full-screen window).

Glynn Clements <glynn at gclements.plus.com>

More information about the xorg mailing list