static Colormap
gst_vaapi_window_glx_create_colormap (GstVaapiWindow * window)
{
  GstVaapiWindowGLXPrivate *const priv =
      GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
  Display *const dpy = GST_VAAPI_WINDOW_NATIVE_DISPLAY (window);
  XWindowAttributes wattr;
  gboolean success = FALSE;

  if (!priv->cmap) {
    if (!window->use_foreign_window) {
      if (!_gst_vaapi_window_glx_ensure_context (window, NULL))
        return None;
      GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
      x11_trap_errors ();
      /* XXX: add a GstVaapiDisplayX11:x11-screen property? */
      priv->cmap = XCreateColormap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
          priv->gl_context->visual->visual, AllocNone);
      success = x11_untrap_errors () == 0;
      GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
    } else {
      GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
      x11_trap_errors ();
      XGetWindowAttributes (dpy, GST_VAAPI_WINDOW_ID (window), &wattr);
      priv->cmap = wattr.colormap;
      success = x11_untrap_errors () == 0;
      GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
    }
    if (!success)
      return None;
  }
  return priv->cmap;
}
Exemple #2
0
/* main() */
int main(int argc, char** argv)
{
	/* Read settings */
	tray_init();
	read_settings(argc, argv);
	/* Register cleanup and signal handlers */
	atexit(cleanup);
#ifndef WIN32
	signal(SIGUSR1, &request_tray_status_on_signal);
    #ifdef ENABLE_GRACEFUL_EXIT_HACK
	signal(SIGINT, &exit_on_signal);
	signal(SIGTERM, &exit_on_signal);
	signal(SIGPIPE, &exit_on_signal);
    #endif
#endif
	/* Open display */
	if ((tray_data.dpy = XOpenDisplay(settings.display_str)) == NULL) 
		DIE(("could not open display\n"));
	else 
		LOG_TRACE(("Opened dpy %p\n", tray_data.dpy));
#ifdef ENABLE_GRACEFUL_EXIT_HACK
	if ((async_dpy = XOpenDisplay(settings.display_str)) == NULL) 
		DIE(("could not open display\n"));
	else 
		LOG_TRACE(("Opened async dpy %p\n", async_dpy));
#endif
	if (settings.xsync)
		XSynchronize(tray_data.dpy, True);
	x11_trap_errors();
	/* Execute proper main() function */
	if (settings.remote_click_name != NULL) 
		return remote_main(argc, argv);
	else
		return tray_main(argc, argv);
}
int
x11_get_geometry(
    Display      *dpy,
    Drawable      drawable,
    int          *px,
    int          *py,
    unsigned int *pwidth,
    unsigned int *pheight
)
{
    Window rootwin;
    int x, y;
    unsigned int width, height, border_width, depth;

    x11_trap_errors();
    XGetGeometry(
        dpy,
        drawable,
        &rootwin,
        &x, &y, &width, &height,
        &border_width,
        &depth
    );
    if (x11_untrap_errors())
        return 0;

    if (px)      *px      = x;
    if (py)      *py      = y;
    if (pwidth)  *pwidth  = width;
    if (pheight) *pheight = height;
    return 1;
}
gboolean
x11_get_geometry(
    Display    *dpy,
    Drawable    drawable,
    gint       *px,
    gint       *py,
    guint      *pwidth,
    guint      *pheight
)
{
    Window rootwin;
    int x, y;
    guint width, height, border_width, depth;

    x11_trap_errors();
    XGetGeometry(
        dpy,
        drawable,
        &rootwin,
        &x, &y, &width, &height,
        &border_width,
        &depth
    );
    if (x11_untrap_errors())
        return FALSE;

    if (px)      *px      = x;
    if (py)      *py      = y;
    if (pwidth)  *pwidth  = width;
    if (pheight) *pheight = height;
    return TRUE;
}
static int 
is_window(Display *dpy, Drawable drawable)
{
    XWindowAttributes wattr;

    x11_trap_errors();
    XGetWindowAttributes(dpy, drawable, &wattr);
    return x11_untrap_errors() == 0;
}