2 * Copyright © 2013 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 #ifdef HAVE_XORG_CONFIG_H
24 #include <xorg-config.h>
27 #include "dri3_priv.h"
29 RESTYPE dri3_event_type
;
32 dri3_free_event(pointer data
, XID id
)
34 dri3_event_ptr dri3_event
= (dri3_event_ptr
) data
;
35 dri3_window_priv_ptr window_priv
= dri3_window_priv(dri3_event
->window
);
36 dri3_event_ptr
*previous
, current
;
38 for (previous
= &window_priv
->events
; (current
= *previous
); previous
= ¤t
->next
) {
39 if (current
== dri3_event
) {
40 *previous
= dri3_event
->next
;
44 free((pointer
) dri3_event
);
50 dri3_free_events(WindowPtr window
)
52 dri3_window_priv_ptr window_priv
= dri3_window_priv(window
);
58 while ((event
= window_priv
->events
))
59 FreeResource(event
->id
, RT_NONE
);
63 dri3_event_swap(xGenericEvent
*from
, xGenericEvent
*to
)
66 swaps(&to
->sequenceNumber
);
69 switch (from
->evtype
) {
70 case DRI3_ConfigureNotify
: {
71 xDRI3ConfigureNotify
*c
= (xDRI3ConfigureNotify
*) to
;
81 swaps(&c
->pixmap_width
);
82 swaps(&c
->pixmap_height
);
83 swapl(&c
->pixmap_flags
);
90 dri3_send_config_notify(WindowPtr window
, int x
, int y
, int w
, int h
, int bw
, WindowPtr sibling
)
92 dri3_window_priv_ptr window_priv
= dri3_window_priv(window
);
95 xDRI3ConfigureNotify cn
= {
97 .extension
= dri3_request
,
98 .length
= (sizeof(xDRI3ConfigureNotify
) - 32) >> 2,
99 .evtype
= DRI3_ConfigureNotify
,
101 .window
= window
->drawable
.id
,
112 dri3_event_ptr event
;
113 dri3_screen_priv_ptr screen_priv
= dri3_screen_priv(window
->drawable
.pScreen
);
115 if (screen_priv
->info
&& screen_priv
->info
->driver_config
)
116 screen_priv
->info
->driver_config(window
, &cn
);
118 for (event
= window_priv
->events
; event
; event
= event
->next
) {
119 if (event
->mask
& (1 << DRI3ConfigureNotify
)) {
121 WriteEventsToClient(event
->client
, 1, (xEvent
*) &cn
);
128 dri3_select_input(ClientPtr client
, XID eid
, WindowPtr window
, CARD32 mask
)
130 dri3_window_priv_ptr window_priv
= dri3_window_priv(window
);
131 dri3_event_ptr event
;
136 event
= calloc (1, sizeof (dri3_event_rec
));
140 event
->client
= client
;
141 event
->window
= window
;
145 event
->next
= window_priv
->events
;
146 window_priv
->events
= event
;
148 if (!AddResource(event
->id
, dri3_event_type
, (pointer
) event
))
155 dri3_event_init(void)
157 dri3_event_type
= CreateNewResourceType(dri3_free_event
, "DRI3Event");
158 if (!dri3_event_type
)
161 GERegisterExtension(dri3_request
, dri3_event_swap
);