checkpoint
This commit is contained in:
parent
2634795b5f
commit
78e51a8c66
314 changed files with 48199 additions and 300 deletions
249
man/man3/mouse.html
Normal file
249
man/man3/mouse.html
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
<head>
|
||||
<title>mouse(3) - Plan 9 from User Space</title>
|
||||
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
|
||||
</head>
|
||||
<body bgcolor=#ffffff>
|
||||
<table border=0 cellpadding=0 cellspacing=0 width=100%>
|
||||
<tr height=10><td>
|
||||
<tr><td width=20><td>
|
||||
<tr><td width=20><td><b>MOUSE(3)</b><td align=right><b>MOUSE(3)</b>
|
||||
<tr><td width=20><td colspan=2>
|
||||
<br>
|
||||
<p><font size=+1><b>NAME </b></font><br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
initmouse, readmouse, closemouse, moveto, cursorswitch, getrect,
|
||||
drawgetrect, menuhit, setcursor – mouse control<br>
|
||||
|
||||
</table>
|
||||
<p><font size=+1><b>SYNOPSIS </b></font><br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
<tt><font size=+1>#include <u.h><br>
|
||||
#include <libc.h><br>
|
||||
#include <draw.h><br>
|
||||
#include <thread.h><br>
|
||||
#include <mouse.h><br>
|
||||
#include <cursor.h><br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>Mousectl *initmouse(char *file, Image *i)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>int readmouse(Mousectl *mc)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>int atomouse();<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>void closemouse(Mousectl *mc)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>void moveto(Mousectl *mc, Point pt)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>void setcursor(Mousectl *mc, Cursor *c)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>Rectangle getrect(int but, Mousectl *mc)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>void drawgetrect(Rectangle r, int up)<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
<tt><font size=+1>int menuhit(int but, Mousectl *mc, Menu *menu, Screen *scr)<br>
|
||||
</font></tt>
|
||||
</table>
|
||||
<p><font size=+1><b>DESCRIPTION </b></font><br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
These functions access and control a mouse in a multi-threaded
|
||||
environment. They use the message-passing <tt><font size=+1>Channel</font></tt> interface in
|
||||
the threads library (see <a href="../man3/thread.html"><i>thread</i>(3)</a>); programs that wish a more
|
||||
event-driven, single-threaded approach should use <a href="../man3/event.html"><i>event</i>(3)</a>.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
The state of the mouse is recorded in a structure, <tt><font size=+1>Mouse</font></tt>, defined
|
||||
in <tt><font size=+1><mouse.h></font></tt>:<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
<tt><font size=+1>typedef struct Mouse Mouse;<br>
|
||||
struct Mouse<br>
|
||||
{<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
int buttons; /* bit array: LMR=124 */<br>
|
||||
Point xy;<br>
|
||||
ulong msec;<br>
|
||||
|
||||
</table>
|
||||
};<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
|
||||
</table>
|
||||
The <tt><font size=+1>Point xy</font></tt> records the position of the cursor, <tt><font size=+1>buttons</font></tt> the state
|
||||
of the buttons (three bits representing, from bit 0 up, the buttons
|
||||
from left to right, 0 if the button is released, 1 if it is pressed),
|
||||
and <tt><font size=+1>msec</font></tt>, a millisecond time stamp.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
The routine <tt><font size=+1>initmouse</font></tt> returns a structure through which one may
|
||||
access the mouse:<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
<tt><font size=+1>typedef struct Mousectl Mousectl;<br>
|
||||
struct Mousectl<br>
|
||||
{<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
Mouse;<br>
|
||||
Channel *c; /* chan(Mouse)[16] */<br>
|
||||
Channel *resizec; /* chan(int)[2] */<br>
|
||||
char *file;<br>
|
||||
int mfd; /* to mouse file */<br>
|
||||
int cfd; /* to cursor file */<br>
|
||||
int pid; /* of slave proc */<br>
|
||||
Image* image; /* of associated window/display */<br>
|
||||
|
||||
</table>
|
||||
};<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
|
||||
</table>
|
||||
The arguments to <i>initmouse</i> are a <i>file</i> naming the device file connected
|
||||
to the mouse and an <i>Image</i> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) on which the mouse will
|
||||
be visible. Typically the file is nil, which requests the default
|
||||
<tt><font size=+1>/dev/mouse</font></tt>; and the image is the window in which the program is
|
||||
running, held in the variable <tt><font size=+1>screen</font></tt> after a call
|
||||
to <i>initdraw</i>.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
Once the <tt><font size=+1>Mousectl</font></tt> is set up, mouse motion will be reported by
|
||||
messages of type <tt><font size=+1>Mouse</font></tt> sent on the <tt><font size=+1>Channel Mousectl.c</font></tt>. Typically,
|
||||
a message will be sent every time a read of <tt><font size=+1>/dev/mouse</font></tt> succeeds,
|
||||
which is every time the state of the mouse changes.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
When the window is resized, a message is sent on <tt><font size=+1>Mousectl.resizec</font></tt>.
|
||||
The actual value sent may be discarded; the receipt of the message
|
||||
tells the program that it should call <tt><font size=+1>getwindow</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>)
|
||||
to reconnect to the window.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Readmouse</i> updates the <tt><font size=+1>Mouse</font></tt> structure held in the <tt><font size=+1>Mousectl</font></tt>, blocking
|
||||
if the state has not changed since the last <i>readmouse</i> or message
|
||||
sent on the channel. It calls <tt><font size=+1>flushimage</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>) before
|
||||
blocking, so any buffered graphics requests are displayed.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Closemouse</i> closes the file descriptors associated with the mouse,
|
||||
kills the slave processes, and frees the <tt><font size=+1>Mousectl</font></tt> structure.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Moveto</i> moves the mouse cursor on the display to the position specified
|
||||
by <i>pt</i>.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Setcursor</i> sets the image of the cursor to that specified by <i>c</i>.
|
||||
If <i>c</i> is nil, the cursor is set to the default. The format of the
|
||||
cursor data is spelled out in <tt><font size=+1><cursor.h></font></tt> and described in <a href="../man3/graphics.html"><i>graphics</i>(3)</a>.
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Getrect</i> returns the dimensions of a rectangle swept by the user,
|
||||
using the mouse, in the manner <a href="../man1/rio.html"><i>rio</i>(1)</a> or <a href="../man1/sam.html"><i>sam</i>(1)</a> uses to create
|
||||
a new window. The <i>but</i> argument specifies which button the user
|
||||
must press to sweep the window; any other button press cancels
|
||||
the action. The returned rectangle is all zeros if the user
|
||||
cancels.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Getrect</i> uses successive calls to <i>drawgetrect</i> to maintain the red
|
||||
rectangle showing the sweep-in-progress. The rectangle to be drawn
|
||||
is specified by <i>rc</i> and the <i>up</i> parameter says whether to draw (1)
|
||||
or erase (0) the rectangle.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
<i>Menuhit</i> provides a simple menu mechanism. It uses a <tt><font size=+1>Menu</font></tt> structure
|
||||
defined in <tt><font size=+1><mouse.h></font></tt>:<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
<tt><font size=+1>typedef struct Menu Menu;<br>
|
||||
struct Menu<br>
|
||||
{<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
char **item;<br>
|
||||
char *(*gen)(int);<br>
|
||||
int lasthit;<br>
|
||||
|
||||
</table>
|
||||
};<br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
</font></tt>
|
||||
|
||||
</table>
|
||||
<i>Menuhit</i> behaves the same as its namesake <i>emenuhit</i> described in
|
||||
<a href="../man3/event.html"><i>event</i>(3)</a>, with two exceptions. First, it uses a <tt><font size=+1>Mousectl</font></tt> to access
|
||||
the mouse rather than using the event interface; and second, it
|
||||
creates the menu as a true window on the <tt><font size=+1>Screen</font></tt> <i>scr</i> (see <a href="../man3/window.html"><i>window</i>(3)</a>),
|
||||
permitting the menu to be displayed in parallel
|
||||
with other activities on the display. If <i>scr</i> is null, <i>menuhit</i>
|
||||
behaves like <i>emenuhit</i>, creating backing store for the menu, writing
|
||||
the menu directly on the display, and restoring the display when
|
||||
the menu is removed.
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||||
|
||||
|
||||
</table>
|
||||
<p><font size=+1><b>SOURCE </b></font><br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
<tt><font size=+1>/usr/local/plan9/src/libdraw<br>
|
||||
</font></tt>
|
||||
</table>
|
||||
<p><font size=+1><b>SEE ALSO </b></font><br>
|
||||
|
||||
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||||
|
||||
<a href="../man3/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/event.html"><i>event</i>(3)</a>, <a href="../man3/keyboard.html"><i>keyboard</i>(3)</a>, <a href="../man3/thread.html"><i>thread</i>(3)</a>.<br>
|
||||
|
||||
</table>
|
||||
|
||||
<td width=20>
|
||||
<tr height=20><td>
|
||||
</table>
|
||||
<!-- TRAILER -->
|
||||
<table border=0 cellpadding=0 cellspacing=0 width=100%>
|
||||
<tr height=15><td width=10><td><td width=10>
|
||||
<tr><td><td>
|
||||
<center>
|
||||
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
|
||||
</center>
|
||||
</table>
|
||||
<!-- TRAILER -->
|
||||
</body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue