3 initmouse, readmouse, closemouse, moveto, getrect, drawgetrect, menuhit, setcursor, enter \- mouse control
20 Mousectl *initmouse(char *file, Image *i)
23 int readmouse(Mousectl *mc)
29 void closemouse(Mousectl *mc)
32 void moveto(Mousectl *mc, Point pt)
35 void setcursor(Mousectl *mc, Cursor *c)
38 Rectangle getrect(int but, Mousectl *mc)
41 void drawgetrect(Rectangle r, int up)
44 int menuhit(int but, Mousectl *mc, Menu *menu, Screen *scr)
47 int enter(char *ask, char *buf, int len,
49 Mousectl *mc, Keyboardctl *kc, Screen *scr)
52 These functions access and control a mouse in a multi-threaded environment.
53 They use the message-passing
55 interface in the threads library
58 programs that wish a more event-driven, single-threaded approach should use
61 The state of the mouse is recorded in a structure,
67 .ta 6n +\w'Rectangle 'u +\w'buttons; 'u
68 typedef struct Mouse Mouse;
71 int buttons; /* bit array: LMR=124 */
80 records the position of the cursor,
82 the state of the buttons (three bits representing, from bit 0 up, the buttons from left to right,
83 0 if the button is released, 1 if it is pressed),
86 a millisecond time stamp.
90 returns a structure through which one may access the mouse:
93 typedef struct Mousectl Mousectl;
97 Channel *c; /* chan(Mouse)[16] */
98 Channel *resizec; /* chan(int)[2] */
101 int mfd; /* to mouse file */
102 int cfd; /* to cursor file */
103 int pid; /* of slave proc */
104 Image* image; /* of associated window/display */
112 naming the device file connected to the mouse and an
116 on which the mouse will be visible.
117 Typically the file is
119 which requests the default
121 and the image is the window in which the program is running, held in the variable
129 mouse motion will be reported by messages of type
134 Typically, a message will be sent every time a read of
136 succeeds, which is every time the state of the mouse changes.
138 When the window is resized, a message is sent on
139 .BR Mousectl.resizec .
140 The actual value sent may be discarded; the receipt of the message
141 tells the program that it should call
145 to reconnect to the window.
150 structure held in the
152 blocking if the state has not changed since the last
154 or message sent on the channel.
159 before blocking, so any buffered graphics requests are displayed.
162 closes the file descriptors associated with the mouse, kills the slave processes,
168 moves the mouse cursor on the display to the position specified by
172 sets the image of the cursor to that specified by
176 is nil, the cursor is set to the default.
177 The format of the cursor data is spelled out in
183 returns the dimensions of a rectangle swept by the user, using the mouse,
188 uses to create a new window.
191 argument specifies which button the user must press to sweep the window;
192 any other button press cancels the action.
193 The returned rectangle is all zeros if the user cancels.
196 uses successive calls to
198 to maintain the red rectangle showing the sweep-in-progress.
199 The rectangle to be drawn is specified by
203 parameter says whether to draw (1) or erase (0) the rectangle.
206 provides a simple menu mechanism.
213 typedef struct Menu Menu;
223 behaves the same as its namesake
230 to access the mouse rather than using the event interface;
232 it creates the menu as a true window on the
237 permitting the menu to be displayed in parallel with other activities on the display.
244 creating backing store for the menu, writing the menu directly on the display, and
245 restoring the display when the menu is removed.
248 is a multithreded version of the
250 function described in
256 argument to create a window. Keyboard input is read from the channel in the