3 initmouse, readmouse, closemouse, moveto, cursorswitch, getrect, drawgetrect, menuhit, setcursor \- 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 These functions access and control a mouse in a multi-threaded environment.
48 They use the message-passing
50 interface in the threads library
53 programs that wish a more event-driven, single-threaded approach should use
56 The state of the mouse is recorded in a structure,
62 .ta 6n +\w'Rectangle 'u +\w'buttons; 'u
63 typedef struct Mouse Mouse;
66 int buttons; /* bit array: LMR=124 */
75 records the position of the cursor,
77 the state of the buttons (three bits representing, from bit 0 up, the buttons from left to right,
78 0 if the button is released, 1 if it is pressed),
81 a millisecond time stamp.
85 returns a structure through which one may access the mouse:
88 typedef struct Mousectl Mousectl;
92 Channel *c; /* chan(Mouse)[16] */
93 Channel *resizec; /* chan(int)[2] */
96 int mfd; /* to mouse file */
97 int cfd; /* to cursor file */
98 int pid; /* of slave proc */
99 Image* image; /* of associated window/display */
107 naming the device file connected to the mouse and an
111 on which the mouse will be visible.
112 Typically the file is
114 which requests the default
116 and the image is the window in which the program is running, held in the variable
124 mouse motion will be reported by messages of type
129 Typically, a message will be sent every time a read of
131 succeeds, which is every time the state of the mouse changes.
133 When the window is resized, a message is sent on
134 .BR Mousectl.resizec .
135 The actual value sent may be discarded; the receipt of the message
136 tells the program that it should call
140 to reconnect to the window.
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.