Initial dockapps git repo
[dockapps.git] / wmweather+-2.12 / wmgeneral / mouse_regions.c
blob26509457f78e2b8f8814cb7d37fec70a5acfc3ed
1 #include "../config.h"
3 /*
4 Best viewed with vim5, using ts=4
6 wmgeneral was taken from wmppp.
8 It has a lot of routines which most of the wm* programs use.
10 ------------------------------------------------------------
12 Author: Martijn Pieterse (pieterse@xs4all.nl)
14 ---
15 CHANGES:
16 ---
17 11/08/2002 (Brad Jorsch, anomie@users.sourceforge.net)
18 * Moved all the mouse region related stuff to mouse_regions.[ch]
20 28/08/2001 (Brad Jorsch, anomie@users.sourceforge.net)
21 * Added EnableMouseRegion and DisableMouseRegion
22 * Got annoyed with the 81-character lines. Fixed it. If you don't like
23 it, find a different copy of wmgeneral.c ;)
24 * GraphicsExpose events are enabled here.
25 * GetXPM is exported. It optionally takes an XpmColorSymbol array.
26 * GetColor is exported.
28 30/09/2000 (Brad Jorsch, anomie@users.sourceforge.net)
29 * You know, wmgen.mask sounds like a much nicer place to store the
30 mask... why don't we do that?
32 21/09/1999 (Brad Jorsch, anomie@users.sourceforge.net)
33 * Changed openXwindow to use only the filename, sans path,
34 as the name and class properties of the app.
36 14/09/1998 (Dave Clark, clarkd@skyia.com)
37 * Updated createXBMfromXPM routine
38 * Now supports >256 colors
39 11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
40 * Removed a bug from parse_rcfile. You could
41 not use "start" in a command if a label was
42 also start.
43 * Changed the needed geometry string.
44 We don't use window size, and don't support
45 negative positions.
46 03/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
47 * Added parse_rcfile2
48 02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
49 * Added -geometry support (untested)
50 28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
51 * Added createXBMfromXPM routine
52 * Saves a lot of work with changing xpm's.
53 02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
54 * changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon
55 * debugged the parse_rc file.
56 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
57 * Ripped similar code from all the wm* programs,
58 and put them in a single file.
62 #include "mouse_regions.h"
64 /*****************/
65 /* Mouse Regions */
66 /*****************/
68 typedef struct {
69 int enable;
70 int top;
71 int bottom;
72 int left;
73 int right;
74 } MOUSE_REGION;
76 MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
78 /******************************************************************************\
79 |* AddMouseRegion *|
80 \******************************************************************************/
82 void AddMouseRegion(int index, int left, int top, int right, int bottom) {
84 if (index < MAX_MOUSE_REGION) {
85 mouse_region[index].enable = 1;
86 mouse_region[index].top = top;
87 mouse_region[index].left = left;
88 mouse_region[index].bottom = bottom;
89 mouse_region[index].right = right;
93 /******************************************************************************\
94 |* CheckMouseRegion *|
95 \******************************************************************************/
97 int CheckMouseRegion(int x, int y) {
98 int i;
99 int found;
101 found = 0;
103 for (i=0; i<MAX_MOUSE_REGION && !found; i++) {
104 if (mouse_region[i].enable==1 &&
105 x <= mouse_region[i].right &&
106 x >= mouse_region[i].left &&
107 y <= mouse_region[i].bottom &&
108 y >= mouse_region[i].top)
109 found = 1;
111 if (!found) return -1;
112 return (i-1);
115 /******************************************************************************\
116 |* EnableMouseRegion *|
117 \******************************************************************************/
119 void EnableMouseRegion(int i) {
120 if(i<MAX_MOUSE_REGION && mouse_region[i].enable==2)
121 mouse_region[i].enable=1;
124 /******************************************************************************\
125 |* DisableMouseRegion *|
126 \******************************************************************************/
128 void DisableMouseRegion(int i) {
129 if(i<MAX_MOUSE_REGION && mouse_region[i].enable==1)
130 mouse_region[i].enable=2;