📄 ch23.htm
字号:
or you can start a window manager. For example, to get the Motif Window Manager,
use the following command in an xterm:
</DL>
<PRE><FONT COLOR="#0066FF">mwm &
</FONT></PRE>
<H3 ALIGN="CENTER"><A NAME="Heading16<FONT COLOR="#000077">Listing 23.1. A
sample startx file.</FONT></H3>
<PRE><FONT COLOR="#0066FF">
$ less /usr/X11R6/bin/startx
#!/bin/sh
# $Xconsortium: startx.cpp,v 1.4 91/108/22 11:41:29 rws Exp $
# $Xfree86: xc/programs/xinit/startx.cpp,v 3.0 1994/05/22 00:02:23 dawes Exp $
#
# This is just a sample implementation of a slightly less primitive
# interface than xinit. It looks for user .xinitrc and .xerverrc
# files, then system xinitrc should probably do things like check
# for .Xresources file and merge them in, startup in a window manager,
# and pop a clock and serveral xterms.
#
# Site administrators are STRONGLY urged to write nicer versions.
#
userclientrc=$HOME/.xinitrc
userserverrc=$HOME/.xserverrc
sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc
sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc
clientargs=""
serverargs=""
if [ -f $userclientrc ]; then
clientargs=$userclientrc
else if [ -f $sysclientrc]; then
clientargs=$sysclientc
fi
fi
if [ -f $userserverrc ]; then
serverargs=$userserverrc
else if [ if $sysserverrc ]; then
serverargs=$sysserverrc
fi
fi
whoseargs="client"
while [ "x$1" != "x" ]; do
case "$1" in
/''*|\.*) if [ "$whoseargs" = "client" ]; then
clientargs="$1"
else
serverargs="$1"
fi ;;
--) whoseargs="server" ;;
*) if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
serverargs="$serverargs $1"
fi ;;
esac
shift
done
xinit $clientargs -- $serverargs
</FONT></PRE>
<P>Of course, you can run any ol' manager you have--fvwm, twnm, olwm, and so on.
I am simply using mwm as an example. Also note that you are running the mwm in the
background. If you do not do this, you can't issue any commands to the xterm. See
Figure 23.1 for what your display might now look like. Keep in mind that your display
might look quite different from the picture in Figure 23.1 because your startup code
has different applications.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading17<FONT COLOR="#000077"><B>TIP:</B> </FONT>If you are in the
bash, Korn, C, or any other common shell at this point, and you forgot the <TT>&</TT>,
press Ctrl-Z to put the job in the background. If you are not running the Korn or
C shells, you can kill mwm with Ctrl-C and then restart it with the ampersand.
<HR>
</DL>
<P>Congratulations! You are now running Motif.
<H6></H6>
<P><A NAME="Heading18<A HREF="../art/23/23lnx01.jpg"><FONT COLOR="#000077">FIGURE
23.1.</FONT></A><FONT COLOR="#000077"> </FONT><I>A typical Motif session. </I><BR>
<BR>
Note that a lot of things can go wrong while you're getting to this point. Here are
a few of the most common problems:
<UL>
<LI>You cannot find the correct files. Ensure that the path includes <TT>/usr/X11/bin</TT>
or the like.
<P>
<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 onto 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) is sent to that window. mwm changes the color of
the window border to show that it has received the focus.
<P>
<LI>There is not enough memory to run the system. This is especially true if you
are on a PC-based platform. Typically, you can get away with 4MB of dynamic RAM for
a simple X Window system, but you almost certainly need 8MB or more to be able to
get a reasonable response time on a PC. The memory upgrade to 8MB is well worth it,
given the performance on a 4MB machine. Only a patient person can live with 4MB.
<P>
<LI>The configuration does not look right. You have to modify the default startup
parameters. See the section "Customizing Motif."
<P>
<LI>Exiting the last command in your <TT>.xinitrc</TT> file terminates your entire
X session. If your last command was an xterm and you logged off that xterm, your
entire session is terminated. Generally, the last command in your <TT>.xinitrc</TT>
file would be the window manager so that terminating the window manager will also
terminate your session.
</UL>
<H3 ALIGN="CENTER"><A NAME="Heading19<FONT COLOR="#000077">Working with Motif
Windows in mwm</FONT></H3>
<P>Take a look at the typical xterm window in Motif, shown in Figure 23.2.
<H6></H6>
<P><A NAME="Heading20<A HREF="../art/23/23lnx02.jpg"><FONT COLOR="#000077">FIGURE
23.2.</FONT></A><FONT COLOR="#000077"> </FONT><I>A typical xterm window. <BR>
</I><BR>
The title bar is the wide horizontal band on the top of the window. This contains
the title for the application. In this case, this is the application itself (usually
either xterm or the name of your shell, such as bash or pdksh). You can modify it
to your needs. Try this:</P>
<PRE><FONT COLOR="#0066FF">xterm -name "I am here" &
</FONT></PRE>
<P>The minimize button is used to iconify this xterm. The maximize button can be
used to resize the window to occupy the entire display area. All corners can be used
to resize the window with the mouse. Note the pseudo-three-dimensional appearance
of the borders.
<H4 ALIGN="CENTER"><A NAME="Heading21<FONT COLOR="#000077">Using the Pointer</FONT></H4>
<P>You will now work with some of the Motif windows you have on the screen. Typically,
you work with a mouse for the pointer, so the text refers to mice at times. You can
always substitute your device name, however, for the word mouse or pointer, and not
lose any of the meaning of the discussion.</P>
<P>Pointers in the mwm environment typically use three buttons, called Button1, Button2,
and Button3. As an affront to left-handed individuals, Button1 is usually referred
to as the left button because it is the most used button of the three. The left button
on a mouse is the one that is pressed with your right index finger. When you take
the pointer to an item and press a button, you are clicking the button.</P>
<P>If you are left handed, you can map your mouse or pointer buttons differently.
See the section "Help for Left-Handed Users: xmodmap," later in this chapter.
<H4 ALIGN="CENTER"><A NAME="Heading22<FONT COLOR="#000077">Icons and Windows</FONT></H4>
<P>The minimize button enables 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 can be updated internally by its process. Icons can be moved around
on-screen, but they cannot be resized. Inactive windows that become active can hide
icons. Icons save valuable screen space when you're using applications that do not
require your constant attention.
<H4 ALIGN="CENTER"><A NAME="Heading23<FONT COLOR="#000077">Iconifying a Window</FONT></H4>
<P>Move the cursor to the minimize button, and press the left button on the mouse.
The window is removed from the screen, and a smaller icon is seen somewhere on the
left side of the screen. The minimize button is the button with the smaller square
near the right side of the frame. The maximize button is the one next to it, with
the bigger square.</P>
<P>To restore an icon to a screen, move the cursor to the icon and click Button1
twice in quick succession. This is known as double-clicking the mouse. Some Motif
icons are shown in the lower portion of Figure 23.3.
<H6></H6>
<P><A NAME="Heading24<A HREF="../art/23/23lnx03.jpg"><FONT COLOR="#000077">FIGURE
23.3.</FONT></A><FONT COLOR="#000077"> </FONT><I>Some typical Motif icons.</I>
<H4 ALIGN="CENTER"><A NAME="Heading25<FONT COLOR="#000077">Maximizing a Window</FONT></H4>
<P>Move the cursor to the maximize button, and press Button1. This action enlarges
the window to the size of the root window. This way, you can have, say, a huge clock
on your screen. Some applications, such as older versions of calc, do not adjust
their internal graphics areas when their frames are resized. This leads to annoying
blank space on a screen.</P>
<P>Use the maximize button as a toggle. Clicking this button on an already maximized
window causes the window to revert to its size and position (also known as geometry)
before it was maximized. Clicking it again remaximizes it.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading26<FONT COLOR="#000077"><B>TIP: </B></FONT>Avoid resizing a
window when running a vi session under an xterm. This action leads to unpredictable
results and can cause vi to behave very strangely.
<HR>
</DL>
<H4 ALIGN="CENTER"><A NAME="Heading27<FONT COLOR="#000077">Sizing a Window</FONT></H4>
<P>The entire frame on a Motif window is a control that enables you to resize the
window. Refer to Figure 23.2 for the size controls. Each of the four corners of the
frame enables you to stretch the window. The four long bars of the frame let you
move the edges of the window with the mouse.</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, and a thin border appears, indicating the size and orientation
of the current stretch operation. Size the window by moving the mouse with Button1
pressed. Release the button when you have achieved the desired size.</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, or the clock
program called oclock, shown in Figure 23.4.
<H6></H6>
<P><A NAME="Heading28<A HREF="../art/23/23lnx04.jpg"><FONT COLOR="#000077">FIGURE
23.4.</FONT></A><FONT COLOR="#000077"> </FONT><I>The oclock program has a window
without resize borders. <BR>
</I><BR>
To move the edges of the window, move the mouse to one edge. Your cursor should change
shape to a vertical double-headed arrow if you are on a horizontal edge (top or bottom
of the window). As you move the pointer, a thin border appears, indicating the size
and orientation of the current stretch operation. If you are on a vertical edge,
the double-headed arrow is 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.</P>
<P>While you are resizing this window, you 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 number of characters) if it's 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.
<H4 ALIGN="CENTER"><A NAME="Heading29<FONT COLOR="#000077">Focus and Selecting
a Window</FONT></H4>
<P>You can select a window or an icon to get the 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 isn't obscured by any other screen item.</P>
<P>When a window has the focus, it collects all the user input from the pointer and
the keyboard. A window can have two types of focus: 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 the focus. The explicit focus requires only that the cursor be in the window
for the window to get the focus. Explicit focus is sometimes referred to as real-estate
driven focus.</P>
<P>In some cases, you want to have the focus where the mouse is, without having to
click the pointer button. Sometimes this is not useful for touch typists, because
a single movement of the pointer can send the keystroke to the wrong window.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading30<FONT COLOR="#000077"><B>TIP: </B></FONT>Sometimes it's a
good idea to click on the frame to get the focus to a window because clicking within
the window might accidentally press a button or other control in the window.
<HR>
</DL>
<P>After you give the focus to a client, it collects all typed or graphics information
until the user clicks elsewhere. It has the focus.</P>
<P>Getting the focus also raises the window to the top of the stack. The window frame
color changes at this point. You can set the focus to an icon too 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 retains
the focus until you click elsewhere.</P>
<P>The color-change scheme depends on your site's default colors. You might not see
any color change if the focused and out-of-focus colors are the same.
<H4 ALIGN="CENTER"><A NAME="Heading31<FONT COLOR="#000077">Moving a Window
or an Icon</FONT></H4>
<P>To move a window's location on the screen, complete the following steps:
<DL>
<DD><B>1.</B> Move the cursor on top of the title bar.<BR>
<B><BR>
2.</B> Press and hold down pointer Button1.<BR>
<B><BR>
3.</B> Move the pointer to the desired location. You should see an outline of the
window border move with your pointer.<BR>
<B><BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -