Make AddMouseRegion's index unsigned
[dockapps.git] / wmthrottle / src / mouse_regions.c
blob5c5ffeebd8a6cd82fe2ea197b8c2dd0731ad0dce
1 #include "../config.h"
2 #include <stdio.h>
4 /*
6 * My thanks for this handly little piece of code below - saved me
7 * a lot of hassle with the buttons
9 * Anthony Peacock
11 Best viewed with vim5, using ts=4
13 wmgeneral was taken from wmppp.
15 It has a lot of routines which most of the wm* programs use.
17 ------------------------------------------------------------
19 Author: Martijn Pieterse (pieterse@xs4all.nl)
21 ---
22 CHANGES:
23 ---
24 11/08/2002 (Brad Jorsch, anomie@users.sourceforge.net)
25 * Moved all the mouse region related stuff to mouse_regions.[ch]
27 28/08/2001 (Brad Jorsch, anomie@users.sourceforge.net)
28 * Added EnableMouseRegion and DisableMouseRegion
29 * Got annoyed with the 81-character lines. Fixed it. If you don't like
30 it, find a different copy of wmgeneral.c ;)
31 * GraphicsExpose events are enabled here.
32 * GetXPM is exported. It optionally takes an XpmColorSymbol array.
33 * GetColor is exported.
35 30/09/2000 (Brad Jorsch, anomie@users.sourceforge.net)
36 * You know, wmgen.mask sounds like a much nicer place to store the
37 mask... why don't we do that?
39 21/09/1999 (Brad Jorsch, anomie@users.sourceforge.net)
40 * Changed openXwindow to use only the filename, sans path,
41 as the name and class properties of the app.
43 14/09/1998 (Dave Clark, clarkd@skyia.com)
44 * Updated createXBMfromXPM routine
45 * Now supports >256 colors
46 11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
47 * Removed a bug from parse_rcfile. You could
48 not use "start" in a command if a label was
49 also start.
50 * Changed the needed geometry string.
51 We don't use window size, and don't support
52 negative positions.
53 03/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
54 * Added parse_rcfile2
55 02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
56 * Added -geometry support (untested)
57 28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
58 * Added createXBMfromXPM routine
59 * Saves a lot of work with changing xpm's.
60 02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
61 * changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon
62 * debugged the parse_rc file.
63 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
64 * Ripped similar code from all the wm* programs,
65 and put them in a single file.
69 #include "mouse_regions.h"
71 /*****************/
72 /* Mouse Regions */
73 /*****************/
75 typedef struct {
76 int enable;
77 int top;
78 int bottom;
79 int left;
80 int right;
81 } MOUSE_REGION;
83 MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
85 /******************************************************************************\
86 |* AddMouseRegion *|
87 \******************************************************************************/
89 void AddMouseRegion(unsigned index, int left, int top, int right, int bottom) {
91 if (index < MAX_MOUSE_REGION) {
92 mouse_region[index].enable = 1;
93 mouse_region[index].top = top;
94 mouse_region[index].left = left;
95 mouse_region[index].bottom = bottom;
96 mouse_region[index].right = right;
100 /******************************************************************************\
101 |* CheckMouseRegion *|
102 \******************************************************************************/
104 int CheckMouseRegion(int x, int y) {
105 int i;
106 int found;
108 found = 0;
110 for (i=0; i<MAX_MOUSE_REGION && !found; i++) {
111 if (mouse_region[i].enable==1 &&
112 x <= mouse_region[i].right &&
113 x >= mouse_region[i].left &&
114 y <= mouse_region[i].bottom &&
115 y >= mouse_region[i].top)
116 found = 1;
118 if (!found) return -1;
119 return (i-1);
122 /******************************************************************************\
123 |* EnableMouseRegion *|
124 \******************************************************************************/
126 void EnableMouseRegion(int i) {
127 if(i<MAX_MOUSE_REGION && mouse_region[i].enable==2)
128 mouse_region[i].enable=1;
131 /******************************************************************************\
132 |* DisableMouseRegion *|
133 \******************************************************************************/
135 void DisableMouseRegion(int i) {
136 if(i<MAX_MOUSE_REGION && mouse_region[i].enable==1)
137 mouse_region[i].enable=2;