unx46.htm

来自「Unix Unleashed, Third Edition is written」· HTM 代码 · 共 2,180 行 · 第 1/5 页

HTM
2,180
字号
<BR>

<BR></LI>

<LI>Understand how to set your environment to your liking.

<BR>

<BR></LI>

<LI>Use some standard tools available in X.

<BR>

<BR></LI>

<LI>See what's in the future with COSE, CDE, and X11R6, and how vendors support various interfaces for their UNIX systems.

<BR>

<BR></LI></UL>

<H3 ALIGN="CENTER">

<CENTER><A ID="I4" NAME="I4">

<FONT SIZE=4><B>What Is a GUI?</B>

<BR></FONT></A></CENTER></H3>

<P>UNIX's user interface was character based when it was first developed. The curses window package was somewhat of a relief but offered nothing in the way of displaying complex graphics or pictures on a monitor. Something more was needed, something that 
would provide a graphical interface for the user.

<BR></P>

<P>This brought about the birth of the term graphical user interface (GUI). A GUI is the graphical interface to an underlying operating system.

<BR></P>

<P>The minimal components for a GUI are the following:

<BR></P>

<UL>

<LI>A screen to show the data in a textual and/or graphical form.

<BR>

<BR></LI>

<LI>A keyboard interface for the user to type in information.

<BR>

<BR></LI>

<LI>A device to control the movement of a cursor or pointing device that the user can move on the screen. The devices for this interface could be a mouse, light pen, palette, or glove.

<BR>

<BR></LI></UL>

<P>This list is by no means complete, but it illustrates some of the minimum requirements for a typical GUI.

<BR></P>

<P>UNIX's standard character-based interface is a reminder of its age. X Windows is UNIX's breaking into the GUI age. X Windows was developed to be a standard graphical user interface for UNIX platforms. The development work was done at the Massachusetts 
Institute of Technology (MIT). The MIT project was called Project Athena and was funded by many corporations. The largest contribution came from Digital Equipment Corporation (DEC).

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>The X Window system is sometimes referred to as X, X Windows, X11R5, or X11, depending on what you happen to be reading.

<BR></NOTE>

<HR ALIGN=CENTER>

<H3 ALIGN="CENTER">

<CENTER><A ID="I5" NAME="I5">

<FONT SIZE=4><B>X Window</B>

<BR></FONT></A></CENTER></H3>

<P>The first commercial release of X Windows was X10.4 in 1986 and was the basis for some commercial applications. The next release was X11R1 in 1987, followed by X11R2 in 1988. Version 11 was a complete windowing package that outperformed X10 in its 
speed, flexibility of features, and styles for multiple screens. X11 and later versions have become the de facto standard GUI for UNIX systems and are therefore the focus of this chapter.

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>The way to read X11R4 is X version 11, Are Four.

<BR></NOTE>

<HR ALIGN=CENTER>

<P>The main features offered by X Windows are the following:

<BR></P>

<UL>

<LI>Standard GUI for more UNIX workstations. See Chapter 47, &quot;Graphical User Interfaces for Programmers,&quot; which is on multiple windowing platforms and standards.

<BR>

<BR></LI>

<LI>High portability. It's written in C and is designed to be portable.

<BR>

<BR></LI>

<LI>It's highly extensible. New features can be implemented into the kernel, run as separate applications, or can use the pre-existing applications that come with X.

<BR>

<BR></LI>

<LI>It's very flexible. The number of features in X make it very complicated. However, you can do a lot more with it because you can modify it to your needs and you have access to the large collection of UNIX tools.

<BR>

<BR></LI></UL>

<H3 ALIGN="CENTER">

<CENTER><A ID="I6" NAME="I6">

<FONT SIZE=4><B>Displays, Screens, and Windows</B>

<BR></FONT></A></CENTER></H3>

<P>X is typically run on a large screen with special graphics capabilities. X allows you to work with multiple processes, each in its own window. Next you'll look at a screen dump of a typical window. Depending on your installation, you might see a 
different screen. Figure 46.1 shows a typical X display running under Motif. The same window will look different under a different Tab Window Manager (TWM). (See Figure 46.2.) See the section &quot;Introduction to Window Managers&quot; for more details.

<BR></P>

<P>

<BR><B><A HREF="46unx01.gif">Figure 46.1. A typical X display with the Motif </B><B>Window Manager (mwm).</A></B>

<BR></P>

<P>

<BR><B><A HREF="46unx02.gif">Figure 46.2. A typical X window in the Tab Window </B><B>Manager (TWM).</A></B>

<BR></P>

<P>The operations on a particular window can vary greatly. Some windows are used only for displaying data, some for input and output of data. Some windows can be resized or moved, or they can overlap or hide contents of another window. Each window is 
generally independent and contains information about its contents, including how to draw itself on the screen. The window does not have to care about itself being hidden from view by another window because its internal operations are not affected when it 
is overlapped by another window.

<BR></P>

<P>The display in Figure 46.1 shows a clock and an xterm. A clock simply shows the time of day. An xterm is a terminal emulator and provides a window into the UNIX operating system. You can have several X Windows open at one time on a display. Each xterm 
is a window independent of all other xterms on that display and contains a separate UNIX terminal session.

<BR></P>

<P>The fact that you can run separate processes in simultaneously displayed windows is one of the most powerful features of X. Also, since you have the full networking capabilities of UNIX, you can run remote sessions on several machines on separate 
windows on the same display. In fact, you can even force a window to be displayed on a remote UNIX machine running X Windows.

<BR></P>

<P>The background area is referred to as the root window. All application windows are displayed on top of this window. X maintains a hierarchical tree of all the windows on the root window. All applications that reside on the root window are its children. 

Their parent is the root window. The root window's parent is the root window itself. All components of windows also are child windows of the application window on which they reside.

<BR></P>

<P>For example, button and text widgets you see in an application are all windows on top of their controlling application's window. The depth of the tree is the number of elements in the tree and in some cases can be a very large number. 

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I7" NAME="I7">

<FONT SIZE=4><B>Stacking Order</B>

<BR></FONT></A></CENTER></H3>

<P>The location of the windows relative to each other on the screen itself is referred to as their stacking order. You could compare this to stacking sheets of paper on a large canvas. The writing or pictures on each sheet are not changed when another 
sheet is stacked on top. Some parts of the lower sheet are visible while it is overlapped by the top sheet.

<BR></P>

<P>When the top sheet is moved around, the writing on the lower sheets is visible again. Changing the location and order of papers is analogous to moving windows around on the display.

<BR></P>

<P>The paper on the top of the stack is always fully visible. The topmost window is analogous to the top sheet of paper. Knowing which window is on top is very important when working in the X Window environment. The control of the windows, their placement, 

and their stacking order is handled by a special client called the window manager. See the section &quot;Introduction to Window Managers&quot; later in this chapter.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I8" NAME="I8">

<FONT SIZE=4><B>Pointers in X</B>

<BR></FONT></A></CENTER></H3>

<P>All X displays require some sort of pointing device. This is generally a three-button mouse; however, you are not limited to a mouse. You can have many types of pointers, including pens, tablets, and so on. You can get by without a pointer in some very 

limited cases, but this is not the way X was designed and is therefore not recommended practice.

<BR></P>

<P>A cursor represents the pointer position on the screen. The cursor follows your movement of the pointer on the screen. As you slide the pointer across the screen, you should see the cursor move with your movements. Several cursors exist in the X Window 

environment for you to use in customizing. See the section &quot;Customizing mwm&quot; for details.

<BR></P>

<P>Keep in mind that Display and Screen are not equivalent in X. You can actually hook two monitors and have a screen on each of them hooked to a common display area. A display can have multiple screens. As you move the cursor to the edge of a screen, it 
will appear on the other screen. Screens are numbered from 0 up. By default, your screen 0 is hooked to display 0 for normal operations. You can also define two screens on the same monitor. See the installation instructions for your hardware vendor for 
more details.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I9" NAME="I9">

<FONT SIZE=3><B>The Client/Server Architecture</B>

<BR></FONT></A></CENTER></H4>

<P>X Window was designed to be platform and kernel independent. Therefore, it is not part of any formal operating system. X's architecture is based on a client&#151;server architecture. The server in the X Window system is very different from the network 
servers.

<BR></P>

<P>Servers provide the display capabilities to user applications clients. This is why they are referred to as display servers. The server sits between the client and the hardware. A client makes a request for display operations to the server. The server 
translates these requests into hardware directives for the underlying system. Figure 46.3 shows the logical relationship between servers and clients.

<BR></P>

<P>

<BR><B><A HREF="46unx03.gif">Figure 46.3. The logical relationship of X servers </B><B>and clients.</A></B>

<BR></P>

<P>The requests are made via message queues, using the X protocol. The X protocol is the means of communication requests and responses between clients and servers. The X server tracks all the user input from the keyboard and pointer. It conveys this 
information via the X protocol back to the clients.

<BR></P>

<P>The division of work between the client and server allows each to run on completely different platforms connected via a network. This provides several advantages: If most of the computationally intensive work can be done on a remote site, you could run 

the server on another system to spare the already overloaded system from the overhead of graphics.

<BR></P>

<P>Also, only the server application has to be hardware specific. All client software can be designed to be platform independent and easier to port.

<BR></P>

<P>You can run several clients on several machines from your server. Each client can then take advantage of the machine on which it is running.

<BR></P>

<P>Clients can also communicate with other clients. The server can keep this information in a common place and have it available for all other clients. This information is referred to as properties. A property is simply a piece of information recorded by 
the server for a client. Refer to the xprop program offered by the X Window system for more information.

<BR></P>

<P>A lot of options exist for all the options available for customizing clients. Look at the man page for xterm as an example. X also provides another way of customizing appearances, using the resources file called .Xresources. This file is usually located 

in the home directory.

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>The .Xresources file is sometimes called .Xdefaults.

<BR></NOTE>

<HR ALIGN=CENTER>

<H3 ALIGN="CENTER">

<CENTER><A ID="I10" NAME="I10">

<FONT SIZE=4><B>Introduction to Window Managers</B>

<BR></FONT></A></CENTER></H3>

<P>How the windows are arranged is a function of a special program called the window manager. The window manager controls the &quot;look and feel&quot; of all the windows on a particular display. The window manager allows the user to move, restack, resize, 

and iconify windows.

<BR></P>

<P>X Window comes with two window managers. These managers are called the Tab Window Manager (TWM) and the OPEN LOOK Window Manager (OLWM). The TWM is also referred to as Tom's Window Manager, after its author, Tom LaStrange. Earlier versions of X also 
offered the Universal Window Manager (UWM); however, this is no longer offered since it does not conform to the X Consortium's Inter-Client Communications Conventions Manual (ICCCM) standards.

<BR></P>

<P>Window managers in X are different from other windowing system managers because you are allowed to choose whichever manager you like. As long as a manager follows the ICCCM standard, it can serve as your window manager.

<BR></P>

<P>The most prevalent window manager today is the Motif Window Manager (mwm) from the OSF/Motif distribution. The Motif window manager is now more important than ever before since being adopted by Common Open Software Environment (COSE) as the standard 
interface for future UNIX GUIs. It's most famous for its borders around all the windows it displays. Figure 46.4 shows the frame mwm puts around each window.

<BR></P>

<P>

<BR><B><A HREF="46unx04.gif">Figure 46.4. A typical Motif Frame.</A></B>

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I11" NAME="I11">

<FONT SIZE=4><B>Getting Started with X Window</B>

<BR></FONT></A></CENTER></H3>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> The first thing to remember is that X is very flexible. You can customize almost anything in X. Therefore, be warned that even though this chapter attempts to describe the most common features of X, 
they may not work exactly as described. This is the price of flexibility. This is especially true for all the different versions of X and window managers offered in X.

<BR></NOTE>

<HR ALIGN=CENTER>

<P>On some systems, you may have to start X from the command line after you log in. On other systems you may have to interface through the xdm client. The case of the xdm manager already running on your system is easy, so that's a good place to begin.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I12" NAME="I12">

<FONT SIZE=3><B>Using xdm</B>

<BR></FONT></A></CENTER></H4>

<P>The xdm utility stands for X Display Manager. It manages several X displays. It is designed to provide the same services as getty, init, and login on character terminals. This is where the system verifies your password and performs the login procedure. 

xdm runs in the background by default. It was first introduced in X11R4 and conforms to the X Display Manager Control Protocol (XDMCP) developed by the X Consortium.

<BR></P>

<P>When xdm is running on a system, a typical display would look like the one shown in Figure 46.5.

<BR></P>

<P>

<BR><B><A HREF="46unx05.gif">Figure 46.5. A typical xdm display.</A></B>

<BR></P>

<P>The xdm session will ask for your login id and password as with any character-based session. However, it would then bring up the X server with an xterm by default instead of just presenting the shell prompt. This book is written with the understanding 
that no customization has been done on your site or that particular machine. xdm emulates the login and getty programs and must be run from the /etc/rc system file. In UNIX, login verifies your password. Under xdm, the login and getty are replaced by xdm's 

own functionality.

<BR></P>

<P>By default, the mwm window manager should be running. See if the familiar borders exist around the xterm. If mwm is not running, type mwm &amp; on the xterm prompt to invoke it. Later in this section you will learn more about how to invoke mwm.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I13" NAME="I13">

<FONT SIZE=3><B>The Hard Way to Start X</B>

<BR></FONT></A></CENTER></H4>

<P>If you do not see any windows at all and you do not see a cursor, then you do not have the X server running. In this case you have to start X server yourself.

<BR></P>

<P>There are several steps to take before you start X:

<BR></P>

<OL>

<LI>If you are new to UNIX and X, contact your system administrator for help. If you are the system administrator, this chapter will only guide you in the right direction. Now would be a good time to read the hardware manual.

<BR>

<BR></LI>

<LI>Confirm that xinit exists in your PATH. Use the echo $PATH command to see if /usr/bin/X11 is in your path.

<BR>

<BR></LI>

<LI>Look for a file called Xconfig in /usr/lib/X11 or /usr/bin/X11. This file will contain hardware-specific information about your system. Contact your vendor if this file does not exist.

<BR>

<BR></LI>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>Always make a copy of Xconfig and save it before you modify it. Do not edit this file while you are already in X, because X may be reading it while you are trying to edit.

<BR></NOTE>

<HR ALIGN=CENTER>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?