1
0
Fork 0

cogl: Remove unused cogl_x11_onscreen_set_foreign_window_xid

https://gitlab.gnome.org/GNOME/mutter/merge_requests/885
This commit is contained in:
Adam Jackson 2019-10-24 16:24:17 -04:00
parent 683f18639e
commit ed7afd9e80
5 changed files with 21 additions and 196 deletions

View file

@ -59,12 +59,6 @@ struct _CoglOnscreen
{
CoglFramebuffer _parent;
#ifdef COGL_HAS_X11_SUPPORT
uint32_t foreign_xid;
CoglOnscreenX11MaskCallback foreign_update_mask_callback;
void *foreign_update_mask_data;
#endif
CoglList frame_closures;
gboolean resizable;

View file

@ -411,37 +411,16 @@ cogl_onscreen_get_buffer_age (CoglOnscreen *onscreen)
}
#ifdef COGL_HAS_X11_SUPPORT
void
cogl_x11_onscreen_set_foreign_window_xid (CoglOnscreen *onscreen,
uint32_t xid,
CoglOnscreenX11MaskCallback update,
void *user_data)
{
/* We don't wan't applications to get away with being lazy here and not
* passing an update callback... */
g_return_if_fail (update);
onscreen->foreign_xid = xid;
onscreen->foreign_update_mask_callback = update;
onscreen->foreign_update_mask_data = user_data;
}
uint32_t
cogl_x11_onscreen_get_window_xid (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
if (onscreen->foreign_xid)
return onscreen->foreign_xid;
else
{
const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
/* This should only be called for x11 onscreens */
g_return_val_if_fail (winsys->onscreen_x11_get_window_xid != NULL, 0);
/* This should only be called for x11 onscreens */
g_return_val_if_fail (winsys->onscreen_x11_get_window_xid != NULL, 0);
return winsys->onscreen_x11_get_window_xid (onscreen);
}
return winsys->onscreen_x11_get_window_xid (onscreen);
}
#endif /* COGL_HAS_X11_SUPPORT */

View file

@ -75,67 +75,6 @@ CoglOnscreen *
cogl_onscreen_new (CoglContext *context, int width, int height);
#ifdef COGL_HAS_X11
typedef void (*CoglOnscreenX11MaskCallback) (CoglOnscreen *onscreen,
uint32_t event_mask,
void *user_data);
/**
* cogl_x11_onscreen_set_foreign_window_xid:
* @onscreen: The unallocated framebuffer to associated with an X
* window.
* @xid: The XID of an existing X window
* @update: (scope async): A callback that notifies of updates to what Cogl
* requires to be in the core X protocol event mask.
* @user_data: user data passed to @update
*
* Ideally we would recommend that you let Cogl be responsible for
* creating any X window required to back an onscreen framebuffer but
* if you really need to target a window created manually this
* function can be called before @onscreen has been allocated to set a
* foreign XID for your existing X window.
*
* Since Cogl needs, for example, to track changes to the size of an X
* window it requires that certain events be selected for via the core
* X protocol. This requirement may also be changed asynchronously so
* you must pass in an @update callback to inform you of Cogl's
* required event mask.
*
* For example if you are using Xlib you could use this API roughly
* as follows:
* [{
* static void
* my_update_cogl_x11_event_mask (CoglOnscreen *onscreen,
* uint32_t event_mask,
* void *user_data)
* {
* XSetWindowAttributes attrs;
* MyData *data = user_data;
* attrs.event_mask = event_mask | data->my_event_mask;
* XChangeWindowAttributes (data->xdpy,
* data->xwin,
* CWEventMask,
* &attrs);
* }
*
* {
* *snip*
* cogl_x11_onscreen_set_foreign_window_xid (onscreen,
* data->xwin,
* my_update_cogl_x11_event_mask,
* data);
* *snip*
* }
* }]
*
* Since: 2.0
* Stability: Unstable
*/
void
cogl_x11_onscreen_set_foreign_window_xid (CoglOnscreen *onscreen,
uint32_t xid,
CoglOnscreenX11MaskCallback update,
void *user_data);
/**
* cogl_x11_onscreen_get_window_xid:
* @onscreen: A #CoglOnscreen framebuffer

View file

@ -60,7 +60,6 @@ typedef struct _CoglDisplayXlib
typedef struct _CoglOnscreenXlib
{
Window xwin;
gboolean is_foreign_xwin;
} CoglOnscreenXlib;
#ifdef EGL_KHR_image_pixmap
@ -425,51 +424,10 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
Window xwin;
/* FIXME: We need to explicitly Select for ConfigureNotify events.
* For foreign windows we need to be careful not to mess up any
* existing event mask.
* We need to document that for windows we create then toolkits
* must be careful not to clear event mask bits that we select.
*/
/* XXX: Note we ignore the user's original width/height when
* given a foreign X window. */
if (onscreen->foreign_xid)
{
Status status;
CoglXlibTrapState state;
XWindowAttributes attr;
int xerror;
xwin = onscreen->foreign_xid;
_cogl_xlib_renderer_trap_errors (display->renderer, &state);
status = XGetWindowAttributes (xlib_renderer->xdpy, xwin, &attr);
xerror = _cogl_xlib_renderer_untrap_errors (display->renderer,
&state);
if (status == 0 || xerror)
{
char message[1000];
XGetErrorText (xlib_renderer->xdpy, xerror,
message, sizeof (message));
g_set_error (error, COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
"Unable to query geometry of foreign "
"xid 0x%08lX: %s",
xwin, message);
return FALSE;
}
_cogl_framebuffer_winsys_update_size (framebuffer,
attr.width, attr.height);
/* Make sure the app selects for the events we require... */
onscreen->foreign_update_mask_callback (onscreen,
COGL_ONSCREEN_X11_EVENT_MASK,
onscreen->
foreign_update_mask_data);
}
else
{
int width;
int height;
@ -541,7 +499,6 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
egl_onscreen->platform = xlib_onscreen;
xlib_onscreen->xwin = xwin;
xlib_onscreen->is_foreign_xwin = onscreen->foreign_xid ? TRUE : FALSE;
egl_onscreen->egl_surface =
eglCreateWindowSurface (egl_renderer->edpy,
@ -566,7 +523,7 @@ _cogl_winsys_egl_onscreen_deinit (CoglOnscreen *onscreen)
_cogl_xlib_renderer_trap_errors (renderer, &old_state);
if (!xlib_onscreen->is_foreign_xwin && xlib_onscreen->xwin != None)
if (xlib_onscreen->xwin != None)
{
XDestroyWindow (xlib_renderer->xdpy, xlib_onscreen->xwin);
xlib_onscreen->xwin = None;

View file

@ -88,7 +88,6 @@ typedef struct _CoglOnscreenXlib
{
Window xwin;
int x, y;
gboolean is_foreign_xwin;
CoglOutput *output;
} CoglOnscreenXlib;
@ -524,7 +523,6 @@ notify_resize (CoglContext *context,
glx_onscreen->pending_resize_notify++;
if (!xlib_onscreen->is_foreign_xwin)
{
int x, y;
@ -1345,48 +1343,9 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
}
/* FIXME: We need to explicitly Select for ConfigureNotify events.
* For foreign windows we need to be careful not to mess up any
* existing event mask.
* We need to document that for windows we create then toolkits
* must be careful not to clear event mask bits that we select.
*/
/* XXX: Note we ignore the user's original width/height when
* given a foreign X window. */
if (onscreen->foreign_xid)
{
Status status;
CoglXlibTrapState state;
XWindowAttributes attr;
int xerror;
xwin = onscreen->foreign_xid;
_cogl_xlib_renderer_trap_errors (display->renderer, &state);
status = XGetWindowAttributes (xlib_renderer->xdpy, xwin, &attr);
XSync (xlib_renderer->xdpy, False);
xerror = _cogl_xlib_renderer_untrap_errors (display->renderer, &state);
if (status == 0 || xerror)
{
char message[1000];
XGetErrorText (xlib_renderer->xdpy, xerror, message, sizeof(message));
g_set_error (error, COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
"Unable to query geometry of foreign xid 0x%08lX: %s",
xwin, message);
return FALSE;
}
_cogl_framebuffer_winsys_update_size (framebuffer,
attr.width, attr.height);
/* Make sure the app selects for the events we require... */
onscreen->foreign_update_mask_callback (onscreen,
COGL_ONSCREEN_X11_EVENT_MASK,
onscreen->foreign_update_mask_data);
}
else
{
int width;
int height;
@ -1457,7 +1416,6 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
glx_onscreen = onscreen->winsys;
xlib_onscreen->xwin = xwin;
xlib_onscreen->is_foreign_xwin = onscreen->foreign_xid ? TRUE : FALSE;
/* Try and create a GLXWindow to use with extensions dependent on
* GLX versions >= 1.3 that don't accept regular X Windows as GLX
@ -1546,7 +1504,7 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
glx_onscreen->glxwin = None;
}
if (!xlib_onscreen->is_foreign_xwin && xlib_onscreen->xwin != None)
if (xlib_onscreen->xwin != None)
{
XDestroyWindow (xlib_renderer->xdpy, xlib_onscreen->xwin);
xlib_onscreen->xwin = None;
@ -1585,10 +1543,9 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
_cogl_xlib_renderer_trap_errors (context->display->renderer, &old_state);
COGL_NOTE (WINSYS,
"MakeContextCurrent dpy: %p, window: 0x%x (%s), context: %p",
"MakeContextCurrent dpy: %p, window: 0x%x, context: %p",
xlib_renderer->xdpy,
(unsigned int) drawable,
xlib_onscreen->is_foreign_xwin ? "foreign" : "native",
glx_display->glx_context);
glx_renderer->glXMakeContextCurrent (xlib_renderer->xdpy,
@ -1917,24 +1874,23 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
if (have_counter)
glx_onscreen->last_swap_vsync_counter = end_frame_vsync_counter;
if (!xlib_onscreen->is_foreign_xwin)
{
CoglOutput *output;
{
CoglOutput *output;
x_min = CLAMP (x_min, 0, framebuffer_width);
x_max = CLAMP (x_max, 0, framebuffer_width);
y_min = CLAMP (y_min, 0, framebuffer_width);
y_max = CLAMP (y_max, 0, framebuffer_height);
x_min = CLAMP (x_min, 0, framebuffer_width);
x_max = CLAMP (x_max, 0, framebuffer_width);
y_min = CLAMP (y_min, 0, framebuffer_width);
y_max = CLAMP (y_max, 0, framebuffer_height);
output =
_cogl_xlib_renderer_output_for_rectangle (context->display->renderer,
xlib_onscreen->x + x_min,
xlib_onscreen->y + y_min,
x_max - x_min,
y_max - y_min);
output =
_cogl_xlib_renderer_output_for_rectangle (context->display->renderer,
xlib_onscreen->x + x_min,
xlib_onscreen->y + y_min,
x_max - x_min,
y_max - y_min);
set_frame_info_output (onscreen, output);
}
set_frame_info_output (onscreen, output);
}
/* XXX: we don't get SwapComplete events based on how we implement
* the _swap_region() API but if cogl-onscreen.c knows we are