Question

I'm looking for a way to programmatically manipulate a windows program running on Linux under Wine.

Is there something similar on Linux to the Windows SetWindowForeground win32 command? A function that sets a window by name to the foreground, that will work with a Windows program running under Wine on Linux?

Doe's wine use X11? If so I may be able to utilize this answer, will experiment and circle back

Was it helpful?

Solution 2

You can use X11 window manager xdotool or X window manager wmctrl.
Consider the following scenario. A MS windows application titled WordWeb Installer running in wine on Ubuntu on workspace 2. Current workspace : 1. To switch to workspace 2 and focus the wine app execute
wmctrl -R wordweb or
xdotool windowactivate $( xdotool search --name wordweb )

OTHER TIPS

In Linux application windows (including your wine apps window) are managed by your desktop environment's Window Manager (WM). The Window Manager controls how windows are placed and the controls which operate on the windows (resizing, minimize, maxize etc).

Unfortunately there is no standardised Window Manager the major desktop environments (GNOME, KDE etc) have developed their own Window Managers and some people run stand alone WMs like IceWM or more exotic tiling WMs etc.

KDE's WM is called KWin, Gnome's is Mutter, Unity uses Compiz (I think - haven't used Ubuntu for a long time).

When the WM is running in an X sesion it probably uses X11 API internally to raise and lower windows.

However most modern WMs will prevent userpace X calls from popping up windows (because of security concerns etc) You will need to use the WM's wrapper functions. I think Wayland (whenever it is finally available) will have a proper secure API so this shouldn't be an issue.

The short answer to your question is any program you write will likely need to be Windows Manager specific and you should consult the documentation for your WM.

Long Answer - there is a freedesktop.org standard called Extended Windows Manager Hints I'm not sure how good conformance to the spec is among differing WMs (major ones like Gnome and kDE should be good). The property you are interested in is Window State (NET_WM_STATE)

See: http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html

I hope that helps - my knowledge of WMs is probably outdated but should steer you in the right direction - I haven't really played around with WMs since GLX first came out and Compositing (wobbly windows and all that jazz) was in vogue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top