📄 ch23.htm
字号:
4.</B> Place the outline at the part of the screen where you want your window to
be. This is referred to as dragging the window.<BR>
<B><BR>
5. </B>Release Button1. The window now appears at the new location. It is also the
window with the focus by default.
</DL>
<P>This procedure can be duplicated for an icon. In the case of an icon, you click
and drag with the cursor in the icon itself.</P>
<P>While you are moving the window, you see a small box in the center of the screen
with two numbers in it. These are positive X and Y offsets of the upper-left corner
of the window from the upper-left corner of the screen. This information is very
useful when you're trying to precisely place a window on the screen.</P>
<P>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.
<H4 ALIGN="CENTER"><A NAME="Heading32<FONT COLOR="#000077">Adding a New Window</FONT></H4>
<P>Say you want to add a calculator to your screen. At the prompt in an xterm window,
type this:</P>
<PRE><FONT COLOR="#0066FF">$ xcalc &
</FONT></PRE>
<P>The calculator should appear on-screen. To get another xterm, type the following
command:</P>
<PRE><FONT COLOR="#0066FF">$ xterm &
</FONT></PRE>
<P>Depending on your site, the new window can appear anywhere on the screen. Typically,
it is placed in the upper-left corner (x=0,y=0) or in the center of the root window.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading33<FONT COLOR="#000077"><B>NOTE: </B></FONT>The reason you
launch applications with an ampersand (<TT>&</TT>) at the end of the command
is to run the application in the background and free up the xterm from which the
application is being run. If you do not type the ampersand, the xterm will not accept
input until that application is either suspended or killed. Also, the use of the
ampersand allows the appli-cation to run even after the xterm from which it was run
is killed.
<HR>
</DL>
<H4 ALIGN="CENTER"><A NAME="Heading34<FONT COLOR="#000077">Window Geometry</FONT></H4>
<P>Almost all clients accept the <TT>-geometry</TT> command-line option. This option
tells the window manager where to locate the window on the screen. If you do not
specify any geometry, the window manager uses its defaults.</P>
<P>The coordinate system for the root window is as listed here:
<UL>
<LI>The origin is top left (0,0).
<P>
<LI>The number of display units is in pixels for graphics.
<P>
<LI>The number of display units is in character sizes for xterms.
</UL>
<P>A pixel is the smallest unit available on a screen. Usually, screens are displayed
in 1024x768 pixels, 2048x2048 pixels, or something similar. The size of a pixel on-screen
is very much hardware-dependent. A 200x200 window appears as different sizes on monitors
with different resolutions.</P>
<P>The geometry parameter is of the following form:</P>
<PRE><FONT COLOR="#0066FF">widthxheight[{+-}xoff{-+}yoff]
</FONT></PRE>
<P>The height and width are usually given in pixels. In the case of xterms, height
is given in lines, and width is given in characters per line. It is common to have
a 24x80 xterm.</P>
<P>The <TT>xoff</TT> and <TT>yoff</TT> are offsets from the left and top edges of
the screen, respectively. These represent the location of the window on the root
window. The curly braces show that either the <TT>-</TT> or the <TT>+</TT> character
can be included, but not both. These are the different parameters in the command:
<TABLE BORDER="0" WIDTH="439">
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="112" ALIGN="LEFT"><TT>+xoff</TT></TD>
<TD ALIGN="LEFT">A positive offset from the left edge of the screen to the left edge of the window.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="112" ALIGN="LEFT"><TT>-xoff</TT></TD>
<TD ALIGN="LEFT">A negative offset from the right edge of the screen to the right edge of the window.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="112" ALIGN="LEFT"><TT>+yoff</TT></TD>
<TD ALIGN="LEFT">A positive offset from the top edge of the screen to the top edge of the window.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="112" ALIGN="LEFT"><TT>-yoff</TT></TD>
<TD ALIGN="LEFT">A negative offset from the bottom edge of the screen to the bottom edge of the window.</TD>
</TR>
</TABLE>
A visual representation of the geometry is shown in Figure 23.5. For example, the
line</P>
<PRE><FONT COLOR="#0066FF">xterm -geometry -50+50 &
</FONT></PRE>
<P>places the xterm on the upper-right corner, 50 pixels from the right edge of the
screen and 50 pixels from the top of the screen. The following parameters specify
the edges of the screen:
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>-0-0</TT></TD>
<TD ALIGN="LEFT">Lower-right corner</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>-0+0</TT></TD>
<TD ALIGN="LEFT">Upper-right corner</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>+0-0</TT></TD>
<TD ALIGN="LEFT">Lower-left corner</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>+0+0</TT></TD>
<TD ALIGN="LEFT">Upper-left corner</TD>
</TR>
</TABLE>
<H6></H6>
<P><A NAME="Heading35<A HREF="../art/23/23lnx05.jpg"><FONT COLOR="#000077">FIGURE
23.5.</FONT></A><FONT COLOR="#000077"> </FONT><I>Window geometry.</I>
<CENTER>
<H3><A NAME="Heading36<FONT COLOR="#000077">Using the Window Menu</FONT></H3>
</CENTER>
<P>Using the window menu requires you to have the focus on a window. Let's look at
a typical window menu. This also might be different on your screen, but the basic
functionality listed here should exist for all later versions of Motif. Take the
cursor to the window menu button, and press the left button. The following menu (or
something close to it) should appear:
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Restore</TD>
<TD ALIGN="LEFT">alt-F5</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Move</TD>
<TD ALIGN="LEFT">alt-F7</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Size</TD>
<TD ALIGN="LEFT">alt-F8</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Minimize</TD>
<TD ALIGN="LEFT">alt-F9</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Maximize</TD>
<TD ALIGN="LEFT">alt-F10</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Lower</TD>
<TD ALIGN="LEFT">alt-F3</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="114" ALIGN="LEFT">Close</TD>
<TD ALIGN="LEFT">alt-F4</TD>
</TR>
</TABLE>
<CENTER>
<H3><A NAME="Heading37<FONT COLOR="#000077">Using the Keyboard in X and the
Meta Key</FONT></H3>
</CENTER>
<P>It's important to bring up this point about the keyboard and its special keys
under X. Keyboards come in different types, and the most important key for using
keystrokes in X can be radically different from one keyboard to another. On PC-based
keyboards, it is usually the Alt key; on Macintoshes, it is the fan-shaped key; on
Suns, it is Left, Alternate; and other keyboards use other keys.</P>
<P>In short, the Meta key is the special key for your special keyboard. For a PC-based
keyboard, this is the Alt key, so don't look for a key called Meta on your keyboard.
Where the text reads Meta, use Alt, the fan key, or whatever key your special keyboard
is mapped to.</P>
<P>You can invoke any item on this window menu in one of two ways:
<UL>
<LI>You can use the pointer. This way, you click on the window menu and press Button1.
Then move the cursor to the item you want, and release Button1; or press the Meta
key and the character that is underlined in the menu. For moving a window, you press
Meta-M. Note that this does not work on some Motif distributions.
</UL>
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading38<FONT COLOR="#000077"><B>NOTE:</B> </FONT>Alt-key combinations
might not always work. In Metro's version of Motif 1.2, the Meta-F7 key moves a window,
but the Meta-M key does not work at all. You might have a completely different experience
with your keyboard.
<HR>
</DL>
<UL>
<LI>While the window has focus, you can press the Meta-function key combination.
Then use the arrow keys on your keyboard to simulate the movement of the cursor,
or just use the pointer.
</UL>
<P>Note that some of these functions might not be available for a menu shown for
an icon. You might not be able to size or minimize an icon, but you can move, maximize,
or close it.
<CENTER>
<H3><A NAME="Heading39<FONT COLOR="#000077">Using the Root Menu</FONT></H3>
</CENTER>
<P>Click Button3 while the cursor is in the root window. You see a menu pop up on
top of all the windows. This is known as the root menu. Keep in mind that this menu
is very customizable, so it might look radically different on your machine.</P>
<P>A typical root menu might list the following items (your system might have a different
list depending on the type of Motif you purchased): <BR>
<BR>
"Root Menu"</P>
<P>New Window</P>
<P>Shuffle Up</P>
<P>Shuffle Down</P>
<P>Refresh</P>
<P>Utils ></P>
<P>Restart<BR>
<BR>
Exit<BR>
<BR>
While holding down Button1, move the cursor down the list to the item you want to
select. When you get to the menu item you want, release the button. If you do not
want to select any items, move the cursor off the menu and release the button.</P>
<P>In the preceding list, the functionality can be set in this way:
<UL>
<LI>New Window starts a new xterm and sets focus to it.
<H1></H1>
<LI>Shuffle Up and Shuffle Down shuffle the stacking order of the windows up or down.
The current window with focus is moved down to the bottom when shuffling down, and
the next highest window is given the focus. The last window in the stack is brought
to the top and given the focus when shuffling up.
<P>
<LI>Refresh redraws the entire screen and all windows.
<P>
<LI>Utils brings up another submenu with more choices to select from. See the "Customizing
Motif" section, later in this chapter, for details on how to set your menu items.
<P>
<LI>Restart kills mwm and restarts it.
<P>
<LI>Exit kills mwm and leaves you without a window manager. If this is the last command
in your startup script, your windowing session terminates.
</UL>
<P>Now, let's work with Motif clients.
<CENTER>
<H3><A NAME="Heading40<FONT COLOR="#000077">Working with Motif Clients</FONT></H3>
</CENTER>
<P>Most programmers find the X Window system libraries too basic to work with, so
they use the next building block, called toolkits. The most common interface toolkit
is the XtIntrinsics toolkit from MIT. This is called Xt. On top of Xt, you can have
other toolkits such as Motif or the Open Look Interface Toolkit (OLIT). When you
are working with Motif, you are working with a Motif toolkit. In Motif, you are working
with Motif Widgets.</P>
<P>Widgets help developers program consistent user interfaces in Motif. By using
Widgets, programmers can quickly put together interfaces that have the same look
and feel of all Motif applications.</P>
<P>Some Widgets display information. Some Widgets collect user input (mouse or keyboard)
information. Some Widgets react to user input by changing their appearance or performing
some programmed function. Some Widgets are simply containers for other Widgets. All
Widgets can be customized in one form or another, whether it is appearance, font
size or style, colors, or whatever other parameter is required.</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -