开发者

workspaces aka desktops in Java

Has there been any advancement in discovering and/or setting which desktop/workspace my applicat开发者_如何转开发ion is on (under Linux/Solaris of course)?


Discovering/setting the desktop on modern window managers is done through reading/setting the _NET_WM_DESKTOP property from the EWMH specification ( http://packages.debian.org/search?keywords=proftpd-basic&searchon=names&suite=all&section=all )

I'm not aware of any neatly encapsulated API's that expose this functionality, but google turned up http://code.google.com/p/ewm/source/browse/trinity/fusion-X11/trunk/src/main/java/org/fusion/x11/ewmh/NetFrameExtents.java which might be a start.


I'm the author of the project proviously linked by the "NetFrmeExtents.java"

Here's my answer:

It's hard to do in pure java if not impossible unless swing/awt has implemented it by now. The most straightforward (and only?) way is to use JNI and do it through xlib/xcb. But it is possible to do what you ask.

There is a desktop convention called EWMH that can help you with what you want. The basic order of steps you need to is:

  1. Get the window id of your application. To do this Google how to retrieve the window handle/window id in awt.
  2. Next you need to read several "properties" defined by atoms. If you don't know what this is google how to read a property from a window in xlib/xcb.
  3. In the EWMH there is a property that lists all virtual desktops defined by the window manager. See http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#id2449367
  4. Set the property a property on your application's window, see http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#id2507080 to the number of the virtual desktop you want your application to be on.

If you have done everything correct and the window manager supports ewmh (most do) it should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜