Using CTK+ on the X Window SystemUsing CTK+ on the X Window System — X11-specific aspects of using CTK+ |
On UNIX, the X backend is the default build for CTK+. So you don't need to do anything special when compiling it, and everything should "just work."
To mix low-level Xlib routines into a CTK program,
see
CTK+ includes an cross-process embedding facility in the form of
the #CtkSocket and #CtkPlug widgets. These are X11-specific, and
you have to include the ctk/ctkx.h header
to use them.
The X backend understands some additional command line arguments.
--display .
The name of the X display to open instead of the one specified
in the displayDISPLAY environment variable.
The X11 CDK backend can be influenced with some additional environment variables.
CDK_SYNCHRONIZE.
If set, CDK makes all X requests synchronously. This is a useful
option for debugging, but it will slow down the performance considerably.
CDK_CORE_DEVICE_EVENTS.
If set, CDK makes does not use the XInput extension, and only reacts
to core X input events.
CDK_SCALE.
Must be set to an integer, typically 2. If set, CDK will scale all
windows by the specified factor. Scaled output is meant to be used on
high-dpi displays. Normally, CDK will pick up a suitable scale factor
for each monitor from the display system. This environment variable
allows to override that.
CDK_DPI_SCALE.
This can be useful when using scale-aware CTK+ applications together
with scale-unaware applications on a high-dpi display. In that case,
the font resolution can be doubled to make scale-unaware applications
readable, and CDK_DPI_SCALE=0.5 can be set to compensate
for that in CTK+ applications which are already scaled by setting
CDK_SCALE=2.
People coming from a Windows or MacOS background often find certain aspects of the X Window System surprising. This section introduces some basic X concepts at a high level. For more details, the book most people use is called the Xlib Programming Manual by Adrian Nye; this book is volume one in the O'Reilly X Window System series.
Standards are another important resource if you're poking in low-level X11 details, in particular the ICCCM and the Extended Window Manager Hints specifications. freedesktop.org has links to many relevant specifications.
The CDK manual covers
Other window systems typically put all their functionality in the application itself. With X, each application involves three different programs: the X server, the application (called a client because it's a client of the X server), and a special client called the window manager.
The X server is in charge of managing resources, processing drawing requests, and dispatching events such as keyboard and mouse events to interested applications. So client applications can ask the X server to create a window, draw a circle, or move windows around.
The window manager is in charge of rendering the frame or borders around windows; it also has final say on the size of each window, and window states such as minimized, maximized, and so forth. On Windows and MacOS the application handles most of this. On X11, if you wish to modify the window's state, or change its frame, you must ask the window manager to do so on your behalf, using an established convention.
CTK+ has functions for asking the window manager to do various things; see for example ctk_window_iconify() or ctk_window_maximize() or ctk_window_set_decorated(). Keep in mind that ctk_window_move() and window sizing are ultimately controlled by the window manager as well and most window managers will ignore certain requests from time to time, in the interests of good user interface.