Associated connection between GTK and Xlib

Source: Internet
Author: User
Tags gtk

First, talk about the relationship between GTK, Qt and Xlib:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/58/D9/wKioL1S_Bo-RXozMAAAvvcsqOXc157.gif "title=" 0_ 1310222074xox4.gif "alt=" Wkiol1s_bo-rxozmaaavvcsqoxc157.gif "/>

Qt is called directly to the Xlib library, and GTK does not call Xlib directly, but instead uses lower-level libraries gdk and glib. This structure allows GTK to be ported to other systems more easily, or to use a graphics library unrelated to the xwindows system.

Second, KDE, GNOME, QT and GTK direct relationship:

KDE and GNOME are window managers, and when we start them we enter a visual operation (graphical interface), since the need to display graphics, naturally with the X protocol Server software, since QT and GTK further encapsulate the X protocol, and they provide a richer window and control mechanism, The implementation of the Windows Manager on the basis of QT is called KDE, and the window manager implemented on GTK is called Gnome.

Again: KDE and GNOME are not just window managers, they provide desktops, menus, and so on.


Third, usually in the Xlib function, you need to specify a specific display and the corresponding widget window (Xwindow ID).

In order to use the Xlib correlation function in the GTK application, we need to find the bridge between GTK and Xlib.

GTK is encapsulated and extended on a gdk basis, and GDK also encapsulates the Xlib functions that are commonly used, so GDK provides functions associated with Xlib for the GTK library.


In Gdk/gdkx.h, you can see variable access that defines the structure in Gdkwindow and xlib, such as Gdk_window_xid get WINDOW (XID),

Display can be either xopendisplay (NULL) or Gdk_window_xdisplay.

After getting these, it's easy to notconsistent the properties of the form control.

For example:

Gtkwidget *win = NULL;

Win = Gtk_window_new (gtk_window_toplevel);

Display *display = Xopendisplay (NULL);

Xresizewindow (Display, Gdk_window_xid (Win->window), 200, 200); Change the size of win

XFlush (display); Instant Refresh

You can use the following interfaces:

Gtkwindow *win;

Gdkwindow *window = Gtk_widget_get_window (Win);

Const window Xwin = gdk_window_xid (window);

Display * Const Display=gdk_window_xdisplay (WINDOW);

To get the window ID and display.



Associated connection between GTK and Xlib

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.