1 /**
2 *
3 * $Id: UniqueEvent.c,v 1.1 2004/08/28 19:22:46 dannybackx Exp $
4 *
5 * Copyright (C) 1995 Free Software Foundation, Inc.
6 * Copyright (C) 1995-2001 LessTif Development Team
7 *
8 * This file is part of the GNU LessTif Library.
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the Free
22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 **/
25
26 static const char rcsid[] = "$Id: UniqueEvent.c,v 1.1 2004/08/28 19:22:46 dannybackx Exp $";
27
28 #include <LTconfig.h>
29
30 #include <string.h>
31
32 #include <XmI/XmI.h>
33 #include <XmI/MacrosI.h>
34
35 #include <Xm/XmP.h>
36 #include <Xm/DisplayP.h>
37
38 #include <XmI/DebugUtil.h>
39
40
41 void
_XmRecordEvent(XEvent * event)42 _XmRecordEvent(XEvent *event)
43 {
44 /* FIX ME: do something compatible here */
45 Widget disp;
46 XtPointer *p;
47
48 if (!event || !event->xany.display)
49 {
50 return;
51 }
52
53 disp = XmGetXmDisplay(event->xany.display);
54
55 if (!disp)
56 {
57 return;
58 }
59
60 p = &(((XmDisplayInfo *) Display_DisplayInfo(disp))->UniqueStamp);
61
62 switch (event->xany.type)
63 {
64 case ButtonPress:
65 case ButtonRelease:
66
67 *p = XtRealloc(*p, sizeof(XButtonEvent));
68 memcpy(*p, event, sizeof(XButtonEvent));
69
70 break;
71 case KeyPress:
72 case KeyRelease:
73
74 *p = XtRealloc(*p, sizeof(XKeyEvent));
75 memcpy(*p, event, sizeof(XKeyEvent));
76
77 break;
78 default:
79 /* FIX ME: which eventtypes does Xt redispatch ? */
80 break;
81 }
82 }
83
84 Boolean
_XmIsEventUnique(XEvent * event)85 _XmIsEventUnique(XEvent *event)
86 {
87 /* FIX ME: compatible? */
88 Widget disp;
89 XtPointer rec_event;
90 Boolean res;
91
92 disp = XmGetXmDisplay(event->xany.display);
93 rec_event = ((XmDisplayInfo *) Display_DisplayInfo(disp))->UniqueStamp;
94
95 if (rec_event == NULL)
96 {
97 return True;
98 }
99
100 switch (event->xany.type)
101 {
102 case ButtonPress:
103 case ButtonRelease:
104 {
105 XButtonEvent *rev = (XButtonEvent *)rec_event;
106 XButtonEvent *ev = (XButtonEvent *)event;
107
108 res = rev->time != ev->time ||
109 rev->window != ev->window ||
110 rev->type != ev->type ||
111 rev->display != ev->display;
112 }
113 break;
114 case KeyPress:
115 case KeyRelease:
116 {
117 XKeyEvent *rev = (XKeyEvent *)rec_event;
118 XKeyEvent *ev = (XKeyEvent *)event;
119
120 res = rev->time != ev->time ||
121 rev->window != ev->window ||
122 rev->type != ev->type ||
123 rev->display != ev->display;
124 }
125 break;
126 default:
127
128 _XmError(NULL, "_XmIsEventUnique got event of wrong type.");
129 res = True;
130 break;
131 }
132
133 return res;
134 }
135