3 initmouse, readmouse, closemouse, moveto, getrect, drawgetrect, menuhit, setcursor, enter \- mouse control
20 Mousectl *initmouse(char *file, Image *i)
23 int readmouse(Mousectl *mc)
26 void closemouse(Mousectl *mc)
29 void moveto(Mousectl *mc, Point pt)
32 void setcursor(Mousectl *mc, Cursor *c)
35 Rectangle getrect(int but, Mousectl *mc)
38 void drawgetrect(Rectangle r, int up)
41 int menuhit(int but, Mousectl *mc, Menu *menu, Screen *scr)
44 int enter(char *ask, char *buf, int len,
46 Mousectl *mc, Keyboardctl *kc, Screen *scr)
49 These functions access and control a mouse in a multi-threaded environment.
50 They use the message-passing
52 interface in the threads library
55 programs that wish a more event-driven, single-threaded approach should use
58 The state of the mouse is recorded in a structure,
64 .ta 6n +\w'Rectangle 'u +\w'buttons; 'u
65 typedef struct Mouse Mouse;
68 int buttons; /* bit array: LMR=124 */
77 records the position of the cursor,
79 the state of the buttons (three bits representing, from bit 0 up, the buttons from left to right,
80 0 if the button is released, 1 if it is pressed),
83 a millisecond time stamp.
87 returns a structure through which one may access the mouse:
90 typedef struct Mousectl Mousectl;
94 Channel *c; /* chan(Mouse)[16] */
95 Channel *resizec; /* chan(int)[2] */
98 int mfd; /* to mouse file */
99 int cfd; /* to cursor file */
100 int pid; /* of slave proc */
101 Image* image; /* of associated window/display */
109 naming the device file connected to the mouse and an
113 on which the mouse will be visible.
114 Typically the file is
116 which requests the default
118 and the image is the window in which the program is running, held in the variable
126 mouse motion will be reported by messages of type
131 Typically, a message will be sent every time a read of
133 succeeds, which is every time the state of the mouse changes.
135 When the window is resized, a message is sent on
136 .BR Mousectl.resizec .
137 The actual value sent may be discarded; the receipt of the message
138 tells the program that it should call
142 to reconnect to the window.
147 structure held in the
149 blocking if the state has not changed since the last
151 or message sent on the channel.
156 before blocking, so any buffered graphics requests are displayed.
159 closes the file descriptors associated with the mouse, kills the slave processes,
165 moves the mouse cursor on the display to the position specified by
169 sets the image of the cursor to that specified by
173 is nil, the cursor is set to the default.
174 The format of the cursor data is spelled out in
180 returns the dimensions of a rectangle swept by the user, using the mouse,
185 uses to create a new window.
188 argument specifies which button the user must press to sweep the window;
189 any other button press cancels the action.
190 The returned rectangle is all zeros if the user cancels.
193 uses successive calls to
195 to maintain the red rectangle showing the sweep-in-progress.
196 The rectangle to be drawn is specified by
200 parameter says whether to draw (1) or erase (0) the rectangle.
203 provides a simple menu mechanism.
210 typedef struct Menu Menu;
220 behaves the same as its namesake
227 to access the mouse rather than using the event interface;
229 it creates the menu as a true window on the
234 permitting the menu to be displayed in parallel with other activities on the display.
241 creating backing store for the menu, writing the menu directly on the display, and
242 restoring the display when the menu is removed.
245 is a multithreded version of the
247 function described in
253 argument to create a window. Keyboard input is read from the channel in the