151 lines
7.2 KiB
HTML
151 lines
7.2 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
<title>Using GTK+ on the X Window System: GTK+ 3 Reference Manual</title>
|
||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||
<link rel="home" href="index.html" title="GTK+ 3 Reference Manual">
|
||
<link rel="up" href="platform-support.html" title="Part VII. GTK+ Platform Support">
|
||
<link rel="prev" href="gtk-running.html" title="Running GTK+ Applications">
|
||
<link rel="next" href="gtk-windows.html" title="Using GTK+ on Windows">
|
||
<meta name="generator" content="GTK-Doc V1.33.0 (XML mode)">
|
||
<link rel="stylesheet" href="style.css" type="text/css">
|
||
</head>
|
||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
|
||
<td width="100%" align="left" class="shortcuts"></td>
|
||
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
|
||
<td><a accesskey="u" href="platform-support.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
|
||
<td><a accesskey="p" href="gtk-running.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
|
||
<td><a accesskey="n" href="gtk-windows.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
|
||
</tr></table>
|
||
<div class="refentry">
|
||
<a name="gtk-x11"></a><div class="titlepage"></div>
|
||
<div class="refnamediv"><table width="100%"><tr>
|
||
<td valign="top">
|
||
<h2><span class="refentrytitle">Using GTK+ on the X Window System</span></h2>
|
||
<p>Using GTK+ on the X Window System —
|
||
X11-specific aspects of using GTK+
|
||
</p>
|
||
</td>
|
||
<td class="gallery_image" valign="top" align="right"></td>
|
||
</tr></table></div>
|
||
<div class="refsect1">
|
||
<a name="id-1.8.5.3"></a><h2>GTK+ for the X Window System</h2>
|
||
<p>
|
||
On UNIX, the X backend is the default build for GTK+.
|
||
So you don't need to do anything special when compiling it,
|
||
and everything should "just work."
|
||
</p>
|
||
<p>
|
||
To mix low-level Xlib routines into a GTK program,
|
||
see <GTKDOCLINK HREF="gdk-X-Window-System-Interaction">GDK X Window
|
||
System interaction</GTKDOCLINK> in the GDK manual.
|
||
</p>
|
||
<p>
|
||
GTK+ includes an cross-process embedding facility in the form of
|
||
the #GtkSocket and #GtkPlug widgets. These are X11-specific, and
|
||
you have to include the <code class="filename">gtk/gtkx.h</code> header
|
||
to use them.
|
||
</p>
|
||
<div class="refsect2">
|
||
<a name="x11-cmdline"></a><h3>X11-specific commandline options</h3>
|
||
<p>
|
||
The X backend understands some additional command line arguments.
|
||
</p>
|
||
<p><b><code class="systemitem">--display <em class="replaceable"><code>display</code></em></code>. </b>
|
||
The name of the X display to open instead of the one specified
|
||
in the <code class="envar">DISPLAY</code> environment variable.
|
||
</p>
|
||
</div>
|
||
<hr>
|
||
<div class="refsect2">
|
||
<a name="x11-envar"></a><h3>X11-specific environment variables</h3>
|
||
<p>
|
||
The X11 GDK backend can be influenced with some additional environment variables.
|
||
</p>
|
||
<p><b><code class="envar">GDK_SYNCHRONIZE</code>. </b>
|
||
If set, GDK makes all X requests synchronously. This is a useful
|
||
option for debugging, but it will slow down the performance considerably.
|
||
</p>
|
||
<p><b><code class="envar">GDK_CORE_DEVICE_EVENTS</code>. </b>
|
||
If set, GDK makes does not use the XInput extension, and only reacts
|
||
to core X input events.
|
||
</p>
|
||
<p><b><code class="envar">GDK_SCALE</code>. </b>
|
||
Must be set to an integer, typically 2. If set, GDK will scale all
|
||
windows by the specified factor. Scaled output is meant to be used on
|
||
high-dpi displays. Normally, GDK will pick up a suitable scale factor
|
||
for each monitor from the display system. This environment variable
|
||
allows to override that.
|
||
</p>
|
||
<p><b><code class="envar">GDK_DPI_SCALE</code>. </b>
|
||
This can be useful when using scale-aware GTK+ 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 <code class="envar">GDK_DPI_SCALE=0.5</code> can be set to compensate
|
||
for that in GTK+ applications which are already scaled by setting
|
||
<code class="envar">GDK_SCALE=2</code>.
|
||
</p>
|
||
</div>
|
||
</div>
|
||
<div class="refsect1">
|
||
<a name="gtk-X11-arch"></a><h2>Understanding the X11 architecture</h2>
|
||
<p>
|
||
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 <em class="citetitle">Xlib Programming
|
||
Manual</em> by Adrian Nye; this book is volume one in the
|
||
O'Reilly X Window System series.
|
||
</p>
|
||
<p>
|
||
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. <a class="ulink" href="http://www.freedesktop.org/standards/" target="_top">freedesktop.org</a>
|
||
has links to many relevant specifications.
|
||
</p>
|
||
<p>
|
||
The GDK manual covers <GTKDOCLINK HREF="gdk-X-Window-System-Interaction">using Xlib in a GTK
|
||
program</GTKDOCLINK>.
|
||
</p>
|
||
<div class="refsect2">
|
||
<a name="id-1.8.5.4.5"></a><h3>Server, client, window manager</h3>
|
||
<p>
|
||
Other window systems typically put all their functionality in the
|
||
application itself. With X, each application involves three different
|
||
programs: the <em class="firstterm">X server</em>, the application (called
|
||
a <em class="firstterm">client</em> because it's a client of the X
|
||
server), and a special client called the <em class="firstterm">window
|
||
manager</em>.
|
||
</p>
|
||
<p>
|
||
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.
|
||
</p>
|
||
<p>
|
||
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 <a class="ulink" href="http://www.freedesktop.org/standards/" target="_top">convention</a>.
|
||
</p>
|
||
<p>
|
||
GTK+ has functions for asking the window manager to do various things;
|
||
see for example <a class="link" href="GtkWindow.html#gtk-window-iconify" title="gtk_window_iconify ()">gtk_window_iconify()</a> or <a class="link" href="GtkWindow.html#gtk-window-maximize" title="gtk_window_maximize ()">gtk_window_maximize()</a> or <a class="link" href="GtkWindow.html#gtk-window-set-decorated" title="gtk_window_set_decorated ()">gtk_window_set_decorated()</a>.
|
||
Keep in mind that <a class="link" href="GtkWindow.html#gtk-window-move" title="gtk_window_move ()">gtk_window_move()</a> and window sizing
|
||
are ultimately controlled by the window manager as well and most
|
||
window managers <span class="emphasis"><em>will</em></span> ignore certain requests from
|
||
time to time, in the interests of good user interface.
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="footer">
|
||
<hr>Generated by GTK-Doc V1.33.0</div>
|
||
</body>
|
||
</html> |