Adds a way for Cogl to control event_mask of foreign wins
This extends cogl_onscreen_x11_set_foreign_xid to take a callback to a function that details the event mask the Cogl requires the application to select on foreign windows. This is required because Cogl, for example, needs to track size changes of a window and may also in the future want other notifications such as map/unmap. Most applications wont need to use the foreign xwindow apis, but those that do are required to pass a valid callback and update the event mask of their window according to Cogl's requirements.
This commit is contained in:
@ -5,6 +5,24 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
static void
|
||||
update_cogl_x11_event_mask (CoglOnscreen *onscreen,
|
||||
guint32 event_mask,
|
||||
void *user_data)
|
||||
{
|
||||
XDisplay *xdpy = user_data;
|
||||
XSetWindowAttributes attrs;
|
||||
guint32 xwin;
|
||||
|
||||
attrs.event_mask = event_mask;
|
||||
xwin = cogl_onscreen_x11_get_window_xid (onscreen);
|
||||
|
||||
XChangeWindowAttributes (xdpy,
|
||||
(Window)xwin,
|
||||
CWEventMask,
|
||||
&attrs);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -110,7 +128,9 @@ main (int argc, char **argv)
|
||||
|
||||
XFree (xvisinfo);
|
||||
|
||||
cogl_onscreen_x11_set_foreign_window_xid (onscreen, xwin);
|
||||
cogl_onscreen_x11_set_foreign_window_xid (onscreen, xwin,
|
||||
update_cogl_x11_event_mask,
|
||||
xdpy);
|
||||
|
||||
fb = COGL_FRAMEBUFFER (onscreen);
|
||||
/* Eventually there will be an implicit allocate on first use so this
|
||||
|
Reference in New Issue
Block a user