Introduction
Introduction Statistics Contact Development Disclaimer Help
getrect.c - sam - An updated version of the sam text editor.
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
getrect.c (1424B)
---
1 /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
2 #include <u.h>
3 #include <libg.h>
4 #include "libgint.h"
5
6 static void
7 grabcursor(void)
8 {
9 raisewindow();
10
11 /* Grab X server with an limp wrist. */
12 while (XGrabPointer(_dpy, screen.id, False,
13 ButtonPressMask|ButtonReleaseMask|
14 ButtonMotionMask|StructureNotifyMask,
15 GrabModeAsync, GrabModeAsync, None, None, CurrentTime)
16 != GrabSuccess)
17 sleep(2);
18
19 /* Grab the keyboard too */
20 XSetInputFocus(_dpy, screen.id, RevertToParent, CurrentTime);
21 }
22
23 static void
24 ungrabcursor(void)
25 {
26 XUngrabPointer(_dpy, CurrentTime);
27 }
28
29 Rectangle
30 getrect(int but, Mouse *m){
31 Rectangle r, rc;
32
33 but = 1<<(but-1);
34 cursorswitch(SweepCursor);
35 while(m->buttons)
36 *m = emouse();
37 grabcursor();
38 while(!(m->buttons & but)){
39 *m = emouse();
40 if(m->buttons & (7^but))
41 goto Return;
42 }
43 r.min = m->xy;
44 r.max = m->xy;
45 do{
46 rc = rcanon(r);
47 border(&screen, rc, 2, F&~D, _bgpixel);
48 *m = emouse();
49 border(&screen, rc, 2, F&~D, _bgpixel);
50 r.max = m->xy;
51 }while(m->buttons & but);
52
53 Return:
54 cursorswitch(DefaultCursor);
55 if(m->buttons & (7^but)){
56 rc.min.x = rc.max.x = 0;
57 rc.min.y = rc.max.y = 0;
58 while(m->buttons)
59 *m = emouse();
60 }
61 ungrabcursor();
62 return rc;
63 }
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.