unx46.htm

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

HTM
2,180
字号

<LI>Look for a file starting with the letter X with a machine name after it. This is your X server. You will usually find X386 on PCs, Xsun on Suns, and so on.

<BR>

<BR></LI>

<LI>Use the which command to find out the location of the xinit command. Use the following command on the /usr directory:

<BR>

<BR>find . -name xinit -print

<BR></LI>

<LI>Type the command xinit at your prompt.

<BR>

<BR></LI>

<LI>Wait a few seconds (or minutes, depending on your hardware). You should see several messages whisk by, and the screen should change to that of a session without a window manager.

<BR>

<BR></LI>

<LI>At this point, you could run with this somewhat crippled windowing system or you could start a window manager. For the Motif Window Manager, use the command in the xterm:

<BR>

<BR>mwm &amp;

<BR></LI></OL>

<P>Note that you are running the mwm in the background. If you do not do this, you will not be able to issue any commands to the xterm.

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>If you are in the Korn or C shell at this point and you forgot the &amp;, then type Ctrl+z to put the job in the background. If you are not running the Korn or C shell, you can kill mwm with Ctrl+c and 

then restart it with the ampersand.

<BR></NOTE>

<HR ALIGN=CENTER>

<P>So now you are running Motif and X Window on your system. Remember that a lot of things can go wrong while you're getting to this point. Here are a few of the most common problems:

<BR></P>

<UL>

<LI>You cannot find the correct files. Ensure that the path includes /usr/bin/X11 or the like. On some systems, it could be /usr/bin/X11R4 or /usr/bin/X11R5, or something similar. Use the find command to locate it.

<BR>

<BR></LI>

<LI>When working on Suns, some of your system files may reside in the /usr/openwin directories.

<BR>

<BR></LI>

<LI>You moved the cursor into the window, but now you have to click to be able to type commands to your xterm. By itself, X Window gives the focus to a window when a cursor is moved on to it. mwm, on the other hand, requires that you actually click the 
left mouse button (Button1) for that window to get focus. Focus means that all user input (keyboard and pointer) will now be sent to that window. mwm will change the color of the window border to show that it has received focus.

<BR>

<BR></LI>

<LI>You do not have enough memory to run the system. This is especially true if you are on a PC-based platform. Typically you can get away with 4 MB of dynamic RAM for a simple X Window system, but you will almost certainly require 8 MB or more to be able 

to get a reasonable response time on a PC. The memory upgrade to 8 MB is well worth it, given the performance on a 4 MB machine. Those who are patient can live with 4 MB.

<BR>

<BR></LI>

<LI>The configuration does not look right. You have to modify the default start-up parameters. See the section &quot;Customizing mwm&quot; for more information.

<BR>

<BR></LI>

<LI>Exiting the last command in your xinit file will terminate your entire X session. If your last command was an xterm and you logged off that xterm, your entire session will be terminated.

<BR>

<BR>Congratulations! You are now running Motif.

<BR>

<BR></LI></UL>

<P>Figure 46.6 shows a typical xterm window in Motif.

<BR></P>

<P>

<BR><B><A HREF="46unx06.gif">Figure 46.6. A typical </B><B><I>xterm</I></B><B> window.</A></B>

<BR></P>

<P>The title bar is the wide horizontal band on the top of the window. This contains the title for the application itself. In this case, this is the application itself, xterm. You can modify it to your needs. Try this:

<BR></P>

<PRE>xterm -name &quot;I am here&quot; &amp;</PRE>

<P>You can use the minimize button to iconify this xterm or the maximize button to resize the window to occupy the entire display area. The sides and corners can be used to resize the window by using the mouse. Note the pseudo-3D appearance of the borders. 

The area of window that is used to display output and get input is also called the window pane.

<BR></P>

<H3 ALIGN="CENTER">

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

<FONT SIZE=4><B>Working with Motif Windows in mwm</B>

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

<P>This section deals with some of the Motif windows you have on the screen. Typically, you will work with a mouse for the pointer, so the text will refer to mouse devices at times. However, you can always substitute your device name for the word 
&quot;mouse&quot; or &quot;pointer&quot; and not lose any meaning of the discussion.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Using the Pointer</B>

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

<P>Pointers in the mwm environment typically use three buttons, called Button1, Button2, and Button3. Button1 is the most-used button of the three and is usually referred to as the &quot;left button.&quot; The left button on a mouse is the one that is 
pressed with your righthand index finger.

<BR></P>

<P>When you take the pointer to an item and press a button, you are clicking the button. If you hold the pointer down with your finger and the object moves with your pointer movements, you are dragging the object. If you click twice or thrice in quick 
succession, you are double-clicking or triple-clicking, respectively. Drag and drop is when you drag an object to a new location and the object stays in the new location after you release the pointer button.

<BR></P>

<P>If you are left-handed, you can map your mouse or pointer buttons differently. See the section &quot;Help for Left-Handed Users&quot; later in this chapter.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Icons and Windows</B>

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

<P>The minimize button allows you to iconify an application. An icon is a small symbol that represents an inactive window. The contents of that window are not visible, although they may be updated internally by the processes running in that window. Icons 
can be moved around on a window, but they cannot be resized. Icons save you valuable screen space for applications that do not require your constant attention.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Iconifying a Window</B>

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

<P>Move the cursor to the minimize button and press the left mouse button. The window is removed from the screen and a smaller icon appears somewhere on the left of the screen.

<BR></P>

<P>To restore an icon to a screen, move the cursor to the icon and click on Button1 twice in quick succession. This is known as double-clicking the mouse. A typical Motif icon is shown in Figure 46.7.

<BR></P>

<P>

<BR><B><A HREF="46unx07.gif">Figure 46.7. A typical Motif icon.</A></B>

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Maximizing a Window</B>

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

<P>Move the cursor to the maximize window and press the pointer Button1. This enlarges the window to the size of the root window. This way you can have a huge clock on your screen. Some applications, such as older versions of calc, do not adjust their 
internal graphic areas when their frame is resized. This leads to annoying blank space on a screen.

<BR></P>

<P>Use the maximize button as a toggle. Clicking on an already maximized window causes it to revert to its size and position (also known as geometry) before it was maximized. Clicking on it again maximizes it (again).

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>Avoid resizing a window when running a vi session under an xterm. This usually leads to unpredictable results and may cause vi to behave very strangely.

<BR></NOTE>

<HR ALIGN=CENTER>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Sizing a Window</B>

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

<P>The entire frame on a Motif window is a control that allows you to resize the window. See Figure 46.8 for the size controls. You can use any of the four corners to stretch the window. You can use the mouse to move the edges of the window by dragging the 

four long bars.

<BR></P>

<P>

<BR><B><A HREF="46unx08.gif">Figure 46.8. The eight sizing controls for </B><B>windows.</A></B>

<BR></P>

<P>To stretch the window using a corner, move the mouse to that corner. Press Button1 and while keeping it pressed, move the mouse. The cursor changes its shape to a double-headed arrow. Size the window by moving the mouse while pressing Button1. Release 
the button when you have achieved the desired size.

<BR></P>

<P>Note that some applications do not have these sizing controls enabled. An example is the cute, but not very useful, pointer tracking program called xeyes. (See Figure 46.9.)

<BR></P>

<P>

<BR><B><A HREF="46unx09.gif">Figure 46.9. A window of the </B><B><I>Xeyes</I></B><B> program without </B><B>resize borders.</A></B>

<BR></P>

<P>To move the edge of the window, move the mouse to that edge. You should see your cursor change shape to a vertical double-headed arrow if you are on a horizontal edge (top or bottom of the window). If you are on a vertical edge, the double-headed arrow 

will be horizontal. Press Button1 and while keeping it pressed move the pointer around. This moves the edge along with your pointer. Release the button when you have the edge where you want it.

<BR></P>

<P>While you are resizing this window, you will see a small box come up in the center of the display. This box contains the size of the window in pixels if it's a graphics image or in rows and columns (in the number of characters) if this is an xterm. On 
some systems you can use the arrow keys on your keyboard to achieve precision when resizing your windows. Remember to keep the button pressed while you use the arrow keys on your keyboard to do the precise adjustment.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Focus and Selecting a Window</B>

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

<P>You can select which window or icon gets focus by moving the pointer to that item and pressing the left button. This moves the window or icon to the top of the stack. This way the window or icon will not be obscured by any other screen item.

<BR></P>

<P>When a window has focus, it collects all the user input from the pointer and the keyboard. There are two types of focus for a window: click to type and explicit. The click to type focus requires a user to click a pointer button in a window for it to get 

focus. The explicit focus requires only that the cursor be in the window for the window to get focus. Explicit focus is sometimes referred to as real estate&#151;driven focus.

<BR></P>

<P>In some cases you might want to have focus where the mouse was without having to click the pointer button. Sometimes this is not useful for touch typists, because a single movement of the pointer can have the keystroke sent to the wrong window.

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>Sometimes it's a good idea to click on the frame to get focus to a window since clicking in the window might accidentally press a button or other control in the window.

<BR></NOTE>

<HR ALIGN=CENTER>

<P>Once you give the focus to a client, the client window will collect all typed or graphics information until the user clicks elsewhere. It has the focus.

<BR></P>

<P>Getting focus also raises the window to the top of the stack. The window frame color also changes at this point. You can set the focus to an icon also by selecting it with a mouse. The name of the icon expands at that point, and you see the window menu 

for that icon. You can move the mouse away from the menu, but the icon will retain the focus until you click elsewhere.

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> The color change scheme will depend on your site's default colors. In some cases you may not see any color change at all if the focused and out-of-focus colors are the same.

<BR></NOTE>

<HR ALIGN=CENTER>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Moving a Window or an Icon</B>

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

<P>To move a window's location on the screen do the following:

<BR></P>

<OL>

<LI>Move the cursor on top of the title bar.

<BR>

<BR></LI>

<LI>Press and hold down pointer Button1.

<BR>

<BR></LI>

<LI>Move the pointer to the desired location. You should see an outline of the window border move with your pointer.

<BR>

<BR></LI>

<LI>Move the outline to the part of the screen where you want your window to be. This is referred to as dragging the window.

<BR>

<BR></LI>

<LI>Release Button1. The window now appears at the new location. It also is the window with the focus (by default).

<BR>

<BR></LI></OL>

<P>This procedure can be duplicated for an icon. In the case of an icon, you would click and drag with the cursor in the icon itself.

<BR></P>

<P>While you are moving the window, you will see a small box in the center of the screen with two numbers in it. These are positive X and Y offsets of the top-left corner of the window from the top-left corner of the screen. This is very useful information 

when trying to precisely place a window on the screen.

<BR></P>

<P>On some workstations, you can achieve some fine precision by pressing the arrow keys on the numeric keypad to move the window one step at a time. You must keep the pointer button pressed while you use the arrow keys.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Adding a New Window</B>

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

<P>If you want to add a calculator to your screen, you can type

<BR></P>

<PRE>xcalc &amp;</PRE>

<P>at the prompt. The calculator appears on the screen.

<BR></P>

<P>For an xterm, type this:

<BR></P>

<PRE>xterm &amp;</PRE>

<P>Depending on your site, this can appear anywhere on the screen. Typically, the new window is placed in the upper-left corner (X=0,Y=0) of the root window or in the center of the root window.

<BR></P>

<P>The size and location of a window is referred to as the window's geometry.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Window Geometry</B>

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

<P>Almost all clients accept the -geometry command line option. This option tells the window manager where to locate the window on a screen. If you do not specify any geometry, the window manager will use its defaults.

<BR></P>

<P>The coordinate system for the root window is as follows:

<BR></P>

<UL>

<LI>The origin is top left (0,0).

<BR>

<BR></LI>

<LI>The number of display units is pixels for graphics.

<BR>

<BR></LI>

⌨️ 快捷键说明

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