/**
 * gst_gl_display_x11_new:
 * @name: (allow-none): a display name
 *
 * Create a new #GstGLDisplayX11 from the x11 display name.  See XOpenDisplay()
 * for details on what is a valid name.
 *
 * Returns: (transfer full): a new #GstGLDisplayX11 or %NULL
 */
GstGLDisplayX11 *
gst_gl_display_x11_new (const gchar * name)
{
  GstGLDisplayX11 *ret;

  GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");

  ret = g_object_new (GST_TYPE_GL_DISPLAY_X11, NULL);
  ret->name = g_strdup (name);
  ret->display = XOpenDisplay (ret->name);

  if (!ret->display) {
    GST_ERROR ("Failed to open X11 display connection with name, \'%s\'", name);
    gst_object_unref (ret);
    return NULL;
  }

  ret->xcb_connection = XGetXCBConnection (ret->display);
  if (!ret->xcb_connection) {
    GST_ERROR ("Failed to open retieve XCB connection from X11 Display");
    gst_object_unref (ret);
    return NULL;
  }

  XSetEventQueueOwner (ret->display, XCBOwnsEventQueue);

  GST_GL_DISPLAY (ret)->event_source = xcb_event_source_new (ret);
  g_source_attach (GST_GL_DISPLAY (ret)->event_source,
      GST_GL_DISPLAY (ret)->main_context);

  return ret;
}
Ejemplo n.º 2
0
void initScreen() {
    /* Open Xlib Display */
    display = XOpenDisplay(0);
    if (!display) printf("Can't open display");

    default_screen = ((_XPrivDisplay)display)->default_screen;
    /* Get the XCB connection from the display */
    connection = XGetXCBConnection(display);
    if (!connection) printf("Can't get xcb connection from display");

    /* Acquire event queue ownership */
    XSetEventQueueOwner(display, XCBOwnsEventQueue);

    /* Find XCB screen */
    screen = 0;
    xcb_screen_iterator_t screen_iter =
            xcb_setup_roots_iterator(xcb_get_setup(connection));
    for (int screen_num = default_screen;
        screen_iter.rem && screen_num > 0;
        --screen_num, xcb_screen_next(&screen_iter));
    screen = screen_iter.data;

/*
  width = screen->width_in_pixels;
  height = screen->height_in_pixels;
*/
  width = 250;
  height = 260;

}
Ejemplo n.º 3
0
Archivo: dri3.c Proyecto: sarnex/wine
BOOL
DRI3Open(Display *dpy, int screen, int *device_fd)
{
    xcb_dri3_open_cookie_t cookie;
    xcb_dri3_open_reply_t *reply;
    xcb_connection_t *xcb_connection = XGetXCBConnection(dpy);
    int fd;
    Window root = RootWindow(dpy, screen);

    cookie = xcb_dri3_open(xcb_connection, root, 0);

    reply = xcb_dri3_open_reply(xcb_connection, cookie, NULL);
    if (!reply)
        return FALSE;

    if (reply->nfd != 1) {
        free(reply);
        return FALSE;
    }

    fd = xcb_dri3_open_reply_fds(xcb_connection, reply)[0];
    fcntl(fd, F_SETFD, FD_CLOEXEC);

    *device_fd = fd;
    free(reply);

    return TRUE;
}
/**
 * Flush the drawing command transport buffer.
 *
 * \param ctx  Context whose transport buffer is to be flushed.
 * \param pc   Pointer to first unused buffer location.
 *
 * \todo
 * Modify this function to use \c ctx->pc instead of the explicit
 * \c pc parameter.
 */
_X_HIDDEN GLubyte *
__glXFlushRenderBuffer(struct glx_context * ctx, GLubyte * pc)
{
   Display *const dpy = ctx->currentDpy;
#ifdef USE_XCB
   xcb_connection_t *c = XGetXCBConnection(dpy);
#else
   xGLXRenderReq *req;
#endif /* USE_XCB */
   const GLint size = pc - ctx->buf;

   if ((dpy != NULL) && (size > 0)) {
#ifdef USE_XCB
      xcb_glx_render(c, ctx->currentContextTag, size,
                     (const uint8_t *) ctx->buf);
#else
      /* Send the entire buffer as an X request */
      LockDisplay(dpy);
      GetReq(GLXRender, req);
      req->reqType = ctx->majorOpcode;
      req->glxCode = X_GLXRender;
      req->contextTag = ctx->currentContextTag;
      req->length += (size + 3) >> 2;
      _XSend(dpy, (char *) ctx->buf, size);
      UnlockDisplay(dpy);
      SyncHandle();
#endif
   }
Ejemplo n.º 5
0
xcb_visualtype_t *
ephyr_glamor_get_visual(void)
{
    xcb_screen_t *xscreen =
        xcb_aux_get_screen(XGetXCBConnection(dpy), DefaultScreen(dpy));
    int attribs[] = {
        GLX_RENDER_TYPE, GLX_RGBA_BIT,
        GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
        GLX_RED_SIZE, 1,
        GLX_GREEN_SIZE, 1,
        GLX_BLUE_SIZE, 1,
        GLX_DOUBLEBUFFER, 1,
        None
    };
    int event_base = 0, error_base = 0, nelements;
    GLXFBConfig *fbconfigs;

    if (!glXQueryExtension (dpy, &error_base, &event_base))
        FatalError("Couldn't find GLX extension\n");

    fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &nelements);
    if (!nelements)
        FatalError("Couldn't choose an FBConfig\n");
    fb_config = fbconfigs[0];
    free(fbconfigs);

    visual_info = glXGetVisualFromFBConfig(dpy, fb_config);
    if (visual_info == NULL)
        FatalError("Couldn't get RGB visual\n");

    return xcb_aux_find_visual_by_id(xscreen, visual_info->visualid);
}
Ejemplo n.º 6
0
XlibBackend::XlibBackend(QObject *parent) :
    TouchpadBackend(parent),
    m_display(XOpenDisplay(0)), m_connection(0)
{
    if (m_display) {
        m_connection = XGetXCBConnection(m_display.data());
    }

    if (!m_connection) {
        m_errorString = i18n("Cannot connect to X server");
        return;
    }

    m_mouseAtom.intern(m_connection, XI_MOUSE);
    m_keyboardAtom.intern(m_connection, XI_KEYBOARD);
    m_touchpadAtom.intern(m_connection, XI_TOUCHPAD);
    m_enabledAtom.intern(m_connection, XI_PROP_ENABLED);

    m_synapticsIdentifierAtom.intern(m_connection, SYNAPTICS_PROP_CAPABILITIES);
    m_libinputIdentifierAtom.intern(m_connection, "libinput Send Events Modes Available");

    m_device.reset(findTouchpad());
    if (!m_device) {
        m_errorString = ("No touchpad found");
    }
}
/**
 * gst_gl_display_x11_new_with_display:
 * @display: an existing, x11 display
 *
 * Creates a new display connection from a X11 Display.
 *
 * Returns: (transfer full): a new #GstGLDisplayX11
 */
GstGLDisplayX11 *
gst_gl_display_x11_new_with_display (Display * display)
{
  GstGLDisplayX11 *ret;

  g_return_val_if_fail (display != NULL, NULL);

  GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");

  ret = g_object_new (GST_TYPE_GL_DISPLAY_X11, NULL);

  ret->name = g_strdup (DisplayString (display));
  ret->display = display;

  ret->xcb_connection = XGetXCBConnection (ret->display);
  if (!ret->xcb_connection) {
    GST_ERROR ("Failed to open retieve XCB connection from X11 Display");
    gst_object_unref (ret);
    return NULL;
  }

  ret->foreign_display = TRUE;

  return ret;
}
Ejemplo n.º 8
0
Archivo: dri3.c Proyecto: sarnex/wine
BOOL
PRESENTCheckExtension(Display *dpy, int major, int minor)
{
    xcb_connection_t *xcb_connection = XGetXCBConnection(dpy);
    xcb_present_query_version_cookie_t present_cookie;
    xcb_present_query_version_reply_t *present_reply;
    xcb_generic_error_t *error;
    const xcb_query_extension_reply_t *extension;

    xcb_prefetch_extension_data(xcb_connection, &xcb_present_id);

    extension = xcb_get_extension_data(xcb_connection, &xcb_present_id);
    if (!(extension && extension->present)) {
        ERR("PRESENT extension is not present\n");
        return FALSE;
    }

    present_cookie = xcb_present_query_version(xcb_connection, major, minor);

    present_reply = xcb_present_query_version_reply(xcb_connection, present_cookie, &error);
    if (!present_reply) {
        free(error);
        ERR("Issue getting requested version of PRESENT: %d,%d\n", major, minor);
        return FALSE;
    }

    TRACE("PRESENT version %d,%d found. %d %d requested\n", major, minor, (int)present_reply->major_version, (int)present_reply->minor_version);
    free(present_reply);

    return TRUE;
}
Ejemplo n.º 9
0
static void
output_get_backlight_limits_xrandr (MetaOutput *output)
{
  Display *xdisplay = xdisplay_from_output (output);
  Atom atom;
  xcb_connection_t *xcb_conn;
  xcb_randr_query_output_property_cookie_t cookie;
  g_autofree xcb_randr_query_output_property_reply_t *reply = NULL;

  atom = XInternAtom (xdisplay, "Backlight", False);

  xcb_conn = XGetXCBConnection (xdisplay);
  cookie = xcb_randr_query_output_property (xcb_conn,
                                            (xcb_randr_output_t) output->winsys_id,
                                            (xcb_atom_t) atom);
  reply = xcb_randr_query_output_property_reply (xcb_conn,
                                                 cookie,
                                                 NULL);

  /* This can happen on systems without backlights. */
  if (reply == NULL)
    return;

  if (!reply->range || reply->length != 2)
    {
      meta_verbose ("backlight %s was not range\n", output->name);
      return;
    }

  int32_t *values = xcb_randr_query_output_property_valid_values (reply);
  output->backlight_min = values[0];
  output->backlight_max = values[1];
}
Ejemplo n.º 10
0
// Ping X in @pingInterval miliseconds.
XServerPinger::XServerPinger(int pingInterval)
{
    Display *dpy;
    sigset_t sigs;

    // Open a separate connection to X.
    dpy = XOpenDisplay(NULL);
    xcb = XGetXCBConnection(dpy);
    connect(new QSocketNotifier(ConnectionNumber(dpy), QSocketNotifier::Read),
            SIGNAL(activated(int)), SLOT(xInput(int)));

    // XGetInputFocus() is our ping request.
    request = xcb_get_input_focus(xcb);
    xcb_flush(xcb);

    timer = new QTimer();
    connect(timer, SIGNAL(timeout()), SLOT(tick()));
    timer->start(pingInterval);

    // die() if we get SIGINT or SIGTERM.
    sigemptyset(&sigs);
    sigaddset(&sigs, SIGINT);
    sigaddset(&sigs, SIGTERM);
    connect(new QSocketNotifier(signalfd(-1, &sigs, 0),
                                QSocketNotifier::Read),
            SIGNAL(activated(int)), SLOT(die(int)));
    sigprocmask(SIG_BLOCK, &sigs, NULL);
}
Ejemplo n.º 11
0
int main(int, char **)
{
    Display *dpy = XOpenDisplay("");
    xcb_connection_t *connection =  XGetXCBConnection(dpy);

    return 0;
}
Ejemplo n.º 12
0
VkSurfaceKHR VKTS_APIENTRY _wsiSurfaceCreate(const VkInstance instance, VKTS_NATIVE_DISPLAY nativeDisplay, VKTS_NATIVE_WINDOW nativeWindow)
{
    if (!instance)
    {
        return VK_NULL_HANDLE;
    }

    //

    VkResult result;

    VkSurfaceKHR surface;

    if (g_hasXcb)
    {
        VkXcbSurfaceCreateInfoKHR xcbSurfaceCreateInfoKHR;

        memset(&xcbSurfaceCreateInfoKHR, 0, sizeof(VkXcbSurfaceCreateInfoKHR));

        xcbSurfaceCreateInfoKHR.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;

        xcbSurfaceCreateInfoKHR.flags = 0;
        xcbSurfaceCreateInfoKHR.connection = XGetXCBConnection(nativeDisplay);
        xcbSurfaceCreateInfoKHR.window = (xcb_window_t)nativeWindow;

        result = vkCreateXcbSurfaceKHR(instance, &xcbSurfaceCreateInfoKHR, nullptr, &surface);

        if (result != VK_SUCCESS)
        {
            return VK_NULL_HANDLE;
        }

        return surface;
    }

    if (g_hasXlib)
    {
    	VkXlibSurfaceCreateInfoKHR xlibSurfaceCreateInfoKHR;

    	memset(&xlibSurfaceCreateInfoKHR, 0, sizeof(VkXlibSurfaceCreateInfoKHR));

    	xlibSurfaceCreateInfoKHR.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;

    	xlibSurfaceCreateInfoKHR.flags = 0;
    	xlibSurfaceCreateInfoKHR.dpy = nativeDisplay;
    	xlibSurfaceCreateInfoKHR.window = nativeWindow;

        result = vkCreateXlibSurfaceKHR(instance, &xlibSurfaceCreateInfoKHR, nullptr, &surface);

        if (result != VK_SUCCESS)
        {
            return VK_NULL_HANDLE;
        }

        return surface;
    }

    return VK_NULL_HANDLE;
}
Ejemplo n.º 13
0
static xcb_connection_t*
x11_surface_get_connection(VkIcdSurfaceBase *icd_surface)
{
   if (icd_surface->platform == VK_ICD_WSI_PLATFORM_XLIB)
      return XGetXCBConnection(((VkIcdSurfaceXlib *)icd_surface)->dpy);
   else
      return ((VkIcdSurfaceXcb *)icd_surface)->connection;
}
Ejemplo n.º 14
0
/**
 * Send a portion of a GLXRenderLarge command to the server.  The advantage of
 * this function over \c __glXSendLargeCommand is that callers can use the
 * data buffer in the GLX context and may be able to avoid allocating an
 * extra buffer.  The disadvantage is the clients will have to do more
 * GLX protocol work (i.e., calculating \c totalRequests, etc.).
 *
 * \sa __glXSendLargeCommand
 *
 * \param gc             GLX context
 * \param requestNumber  Which part of the whole command is this?  The first
 *                       request is 1.
 * \param totalRequests  How many requests will there be?
 * \param data           Command data.
 * \param dataLen        Size, in bytes, of the command data.
 */
_X_HIDDEN void
__glXSendLargeChunk(struct glx_context * gc, GLint requestNumber,
                    GLint totalRequests, const GLvoid * data, GLint dataLen)
{
   Display *dpy = gc->currentDpy;
   xcb_connection_t *c = XGetXCBConnection(dpy);
   xcb_glx_render_large(c, gc->currentContextTag, requestNumber,
                        totalRequests, dataLen, data);
}
Ejemplo n.º 15
0
QTC_EXPORT void
qtcX11InitXlib(Display *disp)
{
    if (qtcUnlikely(qtc_xcb_conn) || !disp) {
        return;
    }
    qtc_disp = disp;
    qtcX11InitXcb(XGetXCBConnection(disp), DefaultScreen(disp));
}
Ejemplo n.º 16
0
struct rutabaga *
window_impl_rtb_alloc(void)
{
    struct xcb_rutabaga *self;
    Display *dpy;

    if (!(self = calloc(1, sizeof(*self))))
        goto err_malloc;

    if (!(self->dpy = dpy = XOpenDisplay(NULL))) {
        ERR("can't open X display\n");
        goto err_dpy;
    }

    if (!(self->xcb_conn = XGetXCBConnection(dpy))) {
        ERR("can't get XCB connection for display\n");
        goto err_get_conn;
    }

    if (xrtb_keyboard_init(self)) {
        ERR("can't initialize keyboard\n");
        goto err_keyboard_init;
    }

    XSetEventQueueOwner(dpy, XCBOwnsEventQueue);

    self->xkb_event = get_xkb_event_id(self->xcb_conn);
    self->xkb_core_kbd_id = get_core_kbd_id(self->xcb_conn);

    if (self->xkb_event >= 0 && self->xkb_core_kbd_id >= 0
            && !receive_xkb_events(self->xcb_conn))
        self->xkb_supported = 1;

    self->running_in_xwayland =
        intern_atom(self->xcb_conn, "WL_SURFACE_ID", 1) != XCB_NONE;

#define INTERN_ATOM(atom, name)												\
	self->atoms.atom = intern_atom(self->xcb_conn, name, 0);

    INTERN_ATOM(wm_protocols, "WM_PROTOCOLS");
    INTERN_ATOM(wm_delete_window, "WM_DELETE_WINDOW");

#undef INTERN_ATOM

    self->empty_cursor = create_empty_cursor(self);

    return (struct rutabaga *) self;

err_keyboard_init:
err_get_conn:
    XCloseDisplay(self->dpy);
err_dpy:
    free(self);
err_malloc:
    return NULL;
}
Ejemplo n.º 17
0
static MetaGroup*
meta_group_new (MetaX11Display *x11_display,
                Window          group_leader)
{
  MetaGroup *group;
#define N_INITIAL_PROPS 3
  Atom initial_props[N_INITIAL_PROPS];
  int i;

  g_assert (N_INITIAL_PROPS == (int) G_N_ELEMENTS (initial_props));

  group = g_new0 (MetaGroup, 1);

  group->x11_display = x11_display;
  group->windows = NULL;
  group->group_leader = group_leader;
  group->refcount = 1; /* owned by caller, hash table has only weak ref */

  xcb_connection_t *xcb_conn = XGetXCBConnection (x11_display->xdisplay);
  xcb_generic_error_t *e;
  g_autofree xcb_get_window_attributes_reply_t *attrs =
    xcb_get_window_attributes_reply (xcb_conn,
                                     xcb_get_window_attributes (xcb_conn, group_leader),
                                     &e);
  if (e)
    return NULL;

  const uint32_t events[] = { attrs->your_event_mask | XCB_EVENT_MASK_PROPERTY_CHANGE };
  xcb_change_window_attributes (xcb_conn, group_leader,
                                XCB_CW_EVENT_MASK, events);

  if (x11_display->groups_by_leader == NULL)
    x11_display->groups_by_leader = g_hash_table_new (meta_unsigned_long_hash,
                                                      meta_unsigned_long_equal);

  g_assert (g_hash_table_lookup (x11_display->groups_by_leader, &group_leader) == NULL);

  g_hash_table_insert (x11_display->groups_by_leader,
                       &group->group_leader,
                       group);

  /* Fill these in the order we want them to be gotten */
  i = 0;
  initial_props[i++] = x11_display->atom_WM_CLIENT_MACHINE;
  initial_props[i++] = x11_display->atom__NET_WM_PID;
  initial_props[i++] = x11_display->atom__NET_STARTUP_ID;
  g_assert (N_INITIAL_PROPS == i);

  meta_group_reload_properties (group, initial_props, N_INITIAL_PROPS);

  meta_topic (META_DEBUG_GROUPS,
              "Created new group with leader 0x%lx\n",
              group->group_leader);

  return group;
}
Ejemplo n.º 18
0
void GlxContext::createSurface(::Window window)
{
    m_display = OpenDisplay();
    m_connection = XGetXCBConnection(m_display);

    // A window already exists, so just use it
    m_window = window;

    updateSettingsFromWindow();
}
Ejemplo n.º 19
0
static void
meta_backend_x11_post_init (MetaBackend *backend)
{
  MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
  MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
  int major, minor;

  priv->xdisplay = clutter_x11_get_default_display ();

  priv->source = x_event_source_new (backend);

  if (!XSyncQueryExtension (priv->xdisplay, &priv->xsync_event_base, &priv->xsync_error_base) ||
      !XSyncInitialize (priv->xdisplay, &major, &minor))
    meta_fatal ("Could not initialize XSync");

  {
    int major = 2, minor = 3;
    gboolean has_xi = FALSE;

    if (XQueryExtension (priv->xdisplay,
                         "XInputExtension",
                         &priv->xinput_opcode,
                         &priv->xinput_error_base,
                         &priv->xinput_event_base))
      {
        if (XIQueryVersion (priv->xdisplay, &major, &minor) == Success)
          {
            int version = (major * 10) + minor;
            if (version >= 22)
              has_xi = TRUE;
          }
      }

    if (!has_xi)
      meta_fatal ("X server doesn't have the XInput extension, version 2.2 or newer\n");
  }

  take_touch_grab (backend);

  priv->xcb = XGetXCBConnection (priv->xdisplay);
  if (!xkb_x11_setup_xkb_extension (priv->xcb,
                                    XKB_X11_MIN_MAJOR_XKB_VERSION,
                                    XKB_X11_MIN_MINOR_XKB_VERSION,
                                    XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS,
                                    NULL, NULL,
                                    &priv->xkb_event_base,
                                    &priv->xkb_error_base))
    meta_fatal ("X server doesn't have the XKB extension, version %d.%d or newer\n",
                XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION);

  g_signal_connect_object (clutter_device_manager_get_default (), "device-added",
                           G_CALLBACK (on_device_added), backend, 0);

  META_BACKEND_CLASS (meta_backend_x11_parent_class)->post_init (backend);
}
Ejemplo n.º 20
0
QXcbConnection::QXcbConnection(const char *displayName)
    : m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
#ifdef XCB_USE_DRI2
    , m_dri2_major(0)
    , m_dri2_minor(0)
    , m_dri2_support_probed(false)
    , m_has_support_for_dri2(false)
#endif
{
    int primaryScreen = 0;

#ifdef XCB_USE_XLIB
    Display *dpy = XOpenDisplay(m_displayName.constData());
    primaryScreen = DefaultScreen(dpy);
    m_connection = XGetXCBConnection(dpy);
    XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
    m_xlib_display = dpy;
#ifdef XCB_USE_EGL
    EGLDisplay eglDisplay = eglGetDisplay(dpy);
    m_egl_display = eglDisplay;
    EGLint major, minor;
    eglBindAPI(EGL_OPENGL_ES_API);
    m_has_egl = eglInitialize(eglDisplay,&major,&minor);
#endif //XCB_USE_EGL
#else
    m_connection = xcb_connect(m_displayName.constData(), &primaryScreen);

#endif //XCB_USE_XLIB
    m_setup = xcb_get_setup(xcb_connection());

    initializeAllAtoms();

    xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup);

    int screenNumber = 0;
    while (it.rem) {
        m_screens << new QXcbScreen(this, it.data, screenNumber++);
        xcb_screen_next(&it);
    }

    m_keyboard = new QXcbKeyboard(this);

#ifdef XCB_USE_DRI2
    initializeDri2();
#endif

    QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
    connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));

    QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(qApp->thread());
    connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));

    sync();
}
Ejemplo n.º 21
0
xcb_connection_t *
ephyr_glamor_connect(void)
{
    dpy = XOpenDisplay(NULL);
    if (!dpy)
        return NULL;

    XSetEventQueueOwner(dpy, XCBOwnsEventQueue);

    return XGetXCBConnection(dpy);
}
Ejemplo n.º 22
0
extern void gl_getclientsize(const struct gs_swap_chain *swap,
			     uint32_t *width, uint32_t *height)
{
	xcb_connection_t *xcb_conn = XGetXCBConnection(swap->device->plat->display);
	xcb_window_t window = swap->wi->window;

	xcb_get_geometry_reply_t *geometry = get_window_geometry(xcb_conn, window);
	*width = geometry->width;
	*height = geometry->height;

	free(geometry);
}
Ejemplo n.º 23
0
	bool AppFrontend::Start()
	{
		if(IsRunning())
			return false;

		SetCurrent();

		#if CE_FRONTEND_USEXLIB
			Display *xDisplay = XOpenDisplay(NULL);
			if(!xDisplay)
			{
				error("[Error] AppFrontend::start - Unable to open Xlib Display.\n");
				XCloseDisplay(xDisplay);
				return false;
			}

			int xDefaultScreen = DefaultScreen(xDisplay);

			#if CE_FRONTEND_USEXCB
				xcb_connection_t *xcbConnection = XGetXCBConnection(xDisplay);
				if(!xcbConnection)
				{
					error("[Error] AppFrontend::start - Unable to get XCB connection from Xlib Display.\n");
					XCloseDisplay(xDisplay);
					return false;
				}
				XSetEventQueueOwner(xDisplay, XCBOwnsEventQueue);

				xcb_intern_atom_cookie_t cookie = xcb_intern_atom(xcbConnection, 0, 16, "WM_DELETE_WINDOW");
				xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(xcbConnection, cookie, 0);
				xcb_atom_t wmDeleteMessage = reply->atom;
			#else
				Atom wmDeleteMessage = XInternAtom(xDisplay, "WM_DELETE_WINDOW", False);
			#endif
		#endif

		#if CE_FRONTEND_USEXLIB
			m_wmDeleteMessage = wmDeleteMessage;
			m_xDefaultScreen = xDefaultScreen;
			m_xDisplay = xDisplay;

			#if CE_FRONTEND_USEXCB
				m_xcbConnection = xcbConnection;
			#endif
		#endif

		#if CE_FRONTEND_USEWIN
			m_hInstance = GetModuleHandle(NULL);
		#endif

		return App::Start();
	}
Ejemplo n.º 24
0
VkBool32 radv_GetPhysicalDeviceXlibPresentationSupportKHR(
    VkPhysicalDevice                            physicalDevice,
    uint32_t                                    queueFamilyIndex,
    Display*                                    dpy,
    VisualID                                    visualID)
{
   RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);

   return wsi_get_physical_device_xcb_presentation_support(
      &device->wsi_device,
      &device->instance->alloc,
      queueFamilyIndex, XGetXCBConnection(dpy), visualID);
}
Ejemplo n.º 25
0
/**
 * sn_display_new:
 * @xdisplay: an X window system display
 * @push_trap_func: function to push an X error trap
 * @pop_trap_func: function to pop an X error trap
 * 
 * Creates a new #SnDisplay object, containing
 * data that libsn associates with an X display.
 *
 * @push_trap_func should be a function that causes X errors to be
 * ignored until @pop_trap_func is called as many times as
 * @push_trap_func has been called. (Nested push/pop pairs must be
 * supported.) The outermost @pop_trap_func in a set of nested pairs
 * must call XSync() to ensure that all errors that will occur have in
 * fact occurred. These functions are used to avoid X errors due to
 * BadWindow and such.
 * 
 * Return value: the new #SnDisplay
 **/
SnDisplay*
sn_display_new (Display                *xdisplay,
                SnDisplayErrorTrapPush  push_trap_func,
                SnDisplayErrorTrapPop   pop_trap_func)
{
  SnDisplay *display = sn_xcb_display_new(XGetXCBConnection(xdisplay),
                                          NULL, NULL);

  display->xdisplay = xdisplay;
  display->push_trap_func = push_trap_func;
  display->pop_trap_func = pop_trap_func;

  return display;
}
/*
** Query the version of the GLX extension.  This procedure works even if
** the client extension is not completely set up.
*/
static Bool
QueryVersion(Display * dpy, int opcode, int *major, int *minor)
{
#ifdef USE_XCB
   xcb_connection_t *c = XGetXCBConnection(dpy);
   xcb_glx_query_version_reply_t *reply = xcb_glx_query_version_reply(c,
                                                                      xcb_glx_query_version
                                                                      (c,
                                                                       GLX_MAJOR_VERSION,
                                                                       GLX_MINOR_VERSION),
                                                                      NULL);

   if (!reply)
     return GL_FALSE;

   if (reply->major_version != GLX_MAJOR_VERSION) {
      free(reply);
      return GL_FALSE;
   }
   *major = reply->major_version;
   *minor = min(reply->minor_version, GLX_MINOR_VERSION);
   free(reply);
   return GL_TRUE;
#else
   xGLXQueryVersionReq *req;
   xGLXQueryVersionReply reply;

   /* Send the glXQueryVersion request */
   LockDisplay(dpy);
   GetReq(GLXQueryVersion, req);
   req->reqType = opcode;
   req->glxCode = X_GLXQueryVersion;
   req->majorVersion = GLX_MAJOR_VERSION;
   req->minorVersion = GLX_MINOR_VERSION;
   _XReply(dpy, (xReply *) & reply, 0, False);
   UnlockDisplay(dpy);
   SyncHandle();

   if (reply.majorVersion != GLX_MAJOR_VERSION) {
      /*
       ** The server does not support the same major release as this
       ** client.
       */
      return GL_FALSE;
   }
   *major = reply.majorVersion;
   *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
   return GL_TRUE;
#endif /* USE_XCB */
}
Ejemplo n.º 27
0
GLboolean
__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures,
                                 GLboolean * residences)
{
   struct glx_context *const gc = __glXGetCurrentContext();
   Display *const dpy = gc->currentDpy;
   GLboolean retval = (GLboolean) 0;
   if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
#ifdef USE_XCB
      xcb_connection_t *c = XGetXCBConnection(dpy);
      (void) __glXFlushRenderBuffer(gc, gc->pc);
      xcb_glx_are_textures_resident_reply_t *reply =
         xcb_glx_are_textures_resident_reply(c,
                                             xcb_glx_are_textures_resident
                                             (c, gc->currentContextTag, n,
                                              textures), NULL);
      (void) memcpy(residences, xcb_glx_are_textures_resident_data(reply),
                    xcb_glx_are_textures_resident_data_length(reply) *
                    sizeof(GLboolean));
      retval = reply->ret_val;
      free(reply);
#else
      const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
      GLubyte const *pc =
         __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen);
      (void) memcpy((void *) (pc + 0), (void *) (&n), 4);
      (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
      if (n & 3) {
         /* n is not a multiple of four.
          * When reply_is_always_array is TRUE, __glXReadReply() will
          * put a multiple of four bytes into the dest buffer.  If the
          * caller's buffer is not a multiple of four in size, we'll write
          * out of bounds.  So use a temporary buffer that's a few bytes
          * larger.
          */
         GLboolean *res4 = malloc((n + 3) & ~3);
         retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
         memcpy(residences, res4, n);
         free(res4);
      }
      else {
         retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
      }
      UnlockDisplay(dpy);
      SyncHandle();
#endif /* USE_XCB */
   }
   return retval;
}
Ejemplo n.º 28
0
void ae3d::Window::Create( int width, int height, WindowCreateFlags flags )
{
    WindowGlobal::display = XOpenDisplay( nullptr );

    if (!WindowGlobal::display)
    {
        std::cerr << "Can't open display" << std::endl;
        return;
    }
    
    int default_screen = DefaultScreen( WindowGlobal::display );

    WindowGlobal::connection = XGetXCBConnection( WindowGlobal::display );
    LoadAtoms();

    if (!WindowGlobal::connection)
    {
        XCloseDisplay( WindowGlobal::display );
        std::cerr << "Can't get xcb connection from display" << std::endl;
        return;
    }
    
    XSetEventQueueOwner( WindowGlobal::display, XCBOwnsEventQueue );

    xcb_screen_t* screen = nullptr;
    xcb_screen_iterator_t screen_iter = xcb_setup_roots_iterator( xcb_get_setup( WindowGlobal::connection ) );
    for (int screen_num = default_screen; screen_iter.rem && screen_num > 0; --screen_num, xcb_screen_next( &screen_iter ));
    screen = screen_iter.data;
    
    WindowGlobal::key_symbols = xcb_key_symbols_alloc( WindowGlobal::connection );
    
    if (CreateWindowAndContext( WindowGlobal::display, WindowGlobal::connection, default_screen, screen, width, height, flags ) == -1)
    {
        return;
    }
    
    GfxDevice::Init( WindowGlobal::windowWidth, WindowGlobal::windowHeight );
    
    const char *title = "Aether3D Game Engine";
    xcb_change_property(WindowGlobal::connection,
                        XCB_PROP_MODE_REPLACE,
                        WindowGlobal::window,
                        XCB_ATOM_WM_NAME,
                        XCB_ATOM_STRING,
                        8,
                        strlen (title),
                        title );
    WindowGlobal::isOpen = true;
}
Ejemplo n.º 29
0
/**
 * Flush the drawing command transport buffer.
 *
 * \param ctx  Context whose transport buffer is to be flushed.
 * \param pc   Pointer to first unused buffer location.
 *
 * \todo
 * Modify this function to use \c ctx->pc instead of the explicit
 * \c pc parameter.
 */
_X_HIDDEN GLubyte *
__glXFlushRenderBuffer(struct glx_context * ctx, GLubyte * pc)
{
   Display *const dpy = ctx->currentDpy;
   xcb_connection_t *c = XGetXCBConnection(dpy);
   const GLint size = pc - ctx->buf;

   if ((dpy != NULL) && (size > 0)) {
      xcb_glx_render(c, ctx->currentContextTag, size,
                     (const uint8_t *) ctx->buf);
   }

   /* Reset pointer and return it */
   ctx->pc = ctx->buf;
   return ctx->pc;
}
Ejemplo n.º 30
0
extern void gl_update(gs_device_t *device)
{
	Display *display = device->plat->display;
	xcb_window_t window = device->cur_swap->wi->window;

	uint32_t values[] = {
		device->cur_swap->info.cx,
		device->cur_swap->info.cy
	};

	xcb_configure_window(
		XGetXCBConnection(display), window,
		XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
		values
	);
}