-->

Desktop integrated application (desktop widget lik

2020-07-14 10:35发布

问题:

i'm currently playing with the idea writing a desktop-integrated application for my personal system, which should act similar like usual desktop widget engines (screenlets, gdesklets, google gadgets). It should give me a complete overview about different information about my system, from the internet and should finally visualize them on my desktop. It should centralized all my daily necessary information.

The easiest way would be surely to write my own widgets for one of the known desktop widget engines, but i would prefer to write it from the scratch. Therefore i'm currently looking for some implementation hints, how i can build a global view on the desktop that is not decorated with borders, titlebars and something else by the window manager and has no background color. Special transparency X% effects are not necessary, where compiz would be needed.

A good example for that would be conky with additional libcario support for drawing. I would also choose a bigger gui toolkit like GTK+ or QT. Direct Use for the more complex X11 API Interface would be also an option. Preferable languages are C and C++.

I would be glad if someone could share his knowledge if he has already some similar experiences in that field.

回答1:

There are two ways to build a borderless window: (1) completely bypassing the window-manager, and (2) using the window manager.

The first one is simple, but limiting (you'll have to manage e.g. window dragging and placement on virtual desktops yourself). It's done by creating a window with the override-redirect flag.

The second method involves setting window properties (as in xprop) known as WM hints. If you want to do it with raw Xlib, you need to study ICCCM for that. Most toolkits like gtk+ have APIs for seting WM hints.

For simple yes-or-no "transparency" there is the XShape API (this is technically an extension, that is, an optional part of X11, but it is present just about everywhere). Or you can just create a window with background set to None (this approach however can have issues with compositing window managers, i.e. Compiz). Or you can just eschew application windows altogether and paint directly on the (virtual) root window. Presumably libcairo would let you do the same, but I'm not familiar with it.

Hope this helps.



回答2:

You didn't say which OS you are targeting, but I am assuming a linux distro.

First of all your window manager has to support borderless and undecorated windows.

Then you need to choose the language (c and c++ are completely different). If you opt for c++, then the Qt seams like an obvious choice.

For Qt, it is easy to create a borderless window : Making a borderless window with for Qt



标签: c++ c desktop x11 gtk