Design of X-Window System

Source: Internet
Author: User
X Server

The most common X implementation on Linux and other pc-based systems is XFree86 (URL click to open link)

The x server in this package is an X-protocol specially written for various graphics cards used on PC PCs.

The X protocol is not only capable of traversing the network, but also applies to the Xlib library between the client and server running on the same machine

Most x software needs to use a C language function library as a program design interface, Xlib Library

It provides an API for information interchange in the X protocol

Xlib itself does not add too much, it can only draw lines on the screen and the mouse action to make a corresponding

If you need menu/button/roll Shi and other things, you must write yourself
X Tool Kit

Detailed introduction to the book 482 pages

including XT/OPENLOOK/MOTIF/QT and GTK +

The differences caused by the toolkit:

There are two different editors in Linux Xedit and Textedit.xedit are a very simple editor, want to load a file, must be typed into a frame, and then click the "Load" button

TextEdit was written by Sun Openlook Toolkit. When you open a file, users can browse the file system out of the file they want to open, providing a familiar 3D effect start

Display *xopendisplay (char *display_name);
int Xclosedisplay (Display *display);
The Display_name parameter specifies the display device we intend to link to. If he is null, use the value of the environment variable display
Its format is "Hostname:server[.display]", a host can have more than one X server, each server can control more than one display device

For example, the desktop is really big, you can use ": 0.1"

When the client finishes using the X server, it must call the Dispay structure that was originally returned by the Xopendisplay call Xclosedisplay

environment variable display is used to direct the application to each particular display server

X used Events

Keyboard events Press and release of the key
Mouse events Button press and release, mouse movement, mouse into/out of a window
Window events

window creation/shutdown; window to get/lose focus; window to be obscured/re-displayed

TK Toolkit

The TK material is written in C and is bound to the event handler via the TCL language

Download Address click Open link

Prior to TK programming, it is necessary to ensure that TK's windowing shell, the wish

You also need to set environment variables tk_library and tcl_library point to the correct location wish

Shell typing wish, pop-up interactive wish window, Wish is a built-in TK function of the Tclsh window program design

First, create the appearance of the program, add the necessary components to access the functionality that is ultimately included in the program, pick a material from the TK Toolkit, and initialize its appearance

Then, use the TK Geometry Manager to arrange its relative position in the screen window with the other material

Next, write the code so that each GUI part responds correctly to the corresponding user commands

For example, click the "Load" button
Material command

button. b

Create a new material and a material command called ". B"

. b configure-text "Hello"

Set the text on the button ". B" to "Hello" and start by saying "Hello"

#!/usr/bin/wish-f

Pack [button. b-text "Hello\nworld!!!" \
                -juntify center \        
                -width \-command
                (puts "Hi")]

#./hello.tk

Can appear in the window of Hello World

The-command option links an event handler to this button

When this button is clicked, the string "Hi" is printed in the parent window.

". A.b.c" represents the material, ". C" is the grandchild/application footage of the ". A.b"/". a". The Scion


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.