Example #1
0
File: gui.c Project: mortehu/bra
static void
x11_connect (void)
{
  char *c;
  int nitems;

  if (x11_connected)
    return;

  XInitThreads ();

  GUI_display = XOpenDisplay (0);

  if (!GUI_display)
    errx (EXIT_FAILURE, "Failed to open GUI_display");

  XSynchronize (GUI_display, True);

  GUI_screenidx = DefaultScreen (GUI_display);
  GUI_screen = DefaultScreenOfDisplay (GUI_display);
  GUI_visual = DefaultVisual (GUI_display, GUI_screenidx);
  GUI_visual_info = XGetVisualInfo (GUI_display, VisualNoMask, &GUI_visual_template, &nitems);

  xa_wm_delete_window = XInternAtom (GUI_display, "WM_DELETE_WINDOW", False);
  xa_clipboard = XInternAtom (GUI_display, "CLIPBOARD", False);
  xa_utf8_string = XInternAtom (GUI_display, "UTF8_STRING", False);
  xa_prop_paste = XInternAtom (GUI_display, "BRA_PASTE", False);

  xim = 0;

  if ((c = XSetLocaleModifiers ("")) && *c)
    xim = XOpenIM (GUI_display, 0, 0, 0);

  if (!xim && (c = XSetLocaleModifiers ("@im=none")) && *c)
    xim = XOpenIM (GUI_display, 0, 0, 0);

  if (!xim)
    errx (EXIT_FAILURE, "Failed to open X Input Method");

  xrenderpictformat = XRenderFindVisualFormat (GUI_display, GUI_visual);

  if (!xrenderpictformat)
    errx (EXIT_FAILURE, "XRenderFindVisualFormat failed");

  argb32pictformat = XRenderFindStandardFormat (GUI_display, PictStandardARGB32);

  a8pictformat = XRenderFindStandardFormat (GUI_display, PictStandardA8);

  if (!a8pictformat)
    errx (EXIT_FAILURE, "XrenderFindStandardFormat failed for PictStandardA8");

  XSynchronize (GUI_display, False);

  x11_connected = 1;
}
Example #2
0
JNIEXPORT jint JNICALL Java_vnmr_ui_VNMRFrame_syncXwin
  (JNIEnv *env, jobject obj, jobject source)
{
        JAWT awt;
        JAWT_DrawingSurface *ds;
        JAWT_DrawingSurfaceInfo *dsi;
        JAWT_X11DrawingSurfaceInfo *dsi_win;
        Display* dpy;
        Drawable xwin;
        GC       gc;
        jint     ret;
	jint lock;

        ret = 0;
	awt.version = JAWT_VERSION_1_4;
	if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
	    printf(" JAVA AWT not found \n");
	    return (ret);
	}

	ds = awt.GetDrawingSurface(env, source);
	if (ds == NULL) {
	    printf(" JAVA Window not found \n");
	    return (ret);
	}

	lock = ds->Lock(ds);
	if ((lock & JAWT_LOCK_ERROR) != 0) {
	    printf(" JAVA Error on locking window \n");
	    awt.FreeDrawingSurface(ds);
	    return (ret);
	}

	dsi = ds->GetDrawingSurfaceInfo(ds);
	if (dsi != NULL) {
	    dsi_win = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
	    if (dsi_win != NULL) {
                xwin = dsi_win->drawable;
                dpy = dsi_win->display;
                XSynchronize(dpy, 1);
                gc = XCreateGC(dpy, xwin, 0, 0);
                XSetForeground(dpy, gc, 2);
                XFreeGC(dpy, gc);
                XSynchronize(dpy, 0);
		ret = 1;
	    }
	    ds->FreeDrawingSurfaceInfo(dsi);
	}
	ds->Unlock(ds);
	awt.FreeDrawingSurface(ds);
	return (ret);
}
Example #3
0
static PyObject *xwrapper_get_root_window(PyObject *self, PyObject *args) {
	Display *d = XOpenDisplay(NULL);
	XSynchronize(d, True);
	Window result = DefaultRootWindow(d);
	XCloseDisplay(d);
	return Py_BuildValue("k", result);
}
Example #4
0
gboolean
_cogl_xlib_renderer_connect (CoglRenderer *renderer, GError **error)
{
  CoglXlibRenderer *xlib_renderer =
    _cogl_xlib_renderer_get_data (renderer);
  CoglX11Renderer *x11_renderer =
    (CoglX11Renderer *) xlib_renderer;
  int damage_error;

  if (!assert_xlib_display (renderer, error))
    return FALSE;

  if (getenv ("COGL_X11_SYNC"))
    XSynchronize (xlib_renderer->xdpy, TRUE);

  /* Check whether damage events are supported on this display */
  if (!XDamageQueryExtension (xlib_renderer->xdpy,
                              &x11_renderer->damage_base,
                              &damage_error))
    x11_renderer->damage_base = -1;

  xlib_renderer->trap_state = NULL;

  xlib_renderer->poll_fd.fd = ConnectionNumber (xlib_renderer->xdpy);
  xlib_renderer->poll_fd.events = COGL_POLL_FD_EVENT_IN;

  register_xlib_renderer (renderer);

  return TRUE;
}
JNIEXPORT void JNICALL SWT_AWT_NATIVE(setDebug)
	(JNIEnv *env, jclass that, jobject frame, jboolean debug)
{
	JAWT awt;
	JAWT_DrawingSurface* ds;
	JAWT_DrawingSurfaceInfo* dsi;
	JAWT_X11DrawingSurfaceInfo* dsi_x11;
	jint lock;

	awt.version = JAWT_VERSION_1_3;
	if (JAWT_GetAWT(env, &awt) != 0) {
		ds = awt.GetDrawingSurface(env, frame);
		if (ds != NULL) {
			lock = ds->Lock(ds);
		 	if ((lock & JAWT_LOCK_ERROR) == 0) {
			 	dsi = ds->GetDrawingSurfaceInfo(ds);
				dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
				XSynchronize(dsi_x11->display, debug);
				ds->FreeDrawingSurfaceInfo(dsi);
				ds->Unlock(ds);
			}
		}
		awt.FreeDrawingSurface(ds);
	}
}
Example #6
0
static void
closedownLogout(Display * display, int screens)
{
	Atom        __SWM_DELETE_WINDOW = None;
	Atom        __SWM_PROTOCOLS = None;
	Atom        __SWM_STATE = None;
	int         j;

#if 0
	/* synchronize -- so I'm aware of errors immediately */
	XSynchronize(display, True);

	/* use my error handler from here on out */
	(void) XSetErrorHandler(err_handler);
#endif

	/* init atoms */
	__SWM_STATE = XInternAtom(display, "__SWM_STATE", False);
	__SWM_PROTOCOLS = XInternAtom(display, "__SWM_PROTOCOLS", False);
	__SWM_DELETE_WINDOW = XInternAtom(display, "__SWM_DELETE_WINDOW", False);

	/* start looking for windows to kill -- be nice on pass 1 */
	for (j = 0; j < screens; j++)
		recurse_tree(display, RootWindow(display, j),
			  __SWM_STATE, __SWM_PROTOCOLS, __SWM_DELETE_WINDOW);

	/* wait for things to clean themselves up */
	(void) sleep(NAP_TIME);

	/* this will forcibly kill anything that's still around --
	   this second pass may or may not be needed... */
	for (j = 0; j < screens; j++)
		kill_tree(display, RootWindow(display, j));
	(void) sleep(NAP_TIME);
}
Example #7
0
int xwindow_create(struct _xwindow *p)
{
	XSetErrorHandler(error_handler);

	Display *display = XOpenDisplay(NULL);
	if (!display)
	{
		log_message(ERROR, "Can't connect to XServer");
		return FALSE;
	}

	Window window = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, 1, 1, 0, 0, 0);
	if (!window)
	{
		log_message(ERROR, "Can't create program window");
		return FALSE;
	}

	p->display	= display;
	p->window	= window;

	set_event_mask(window, MAIN_WINDOW_MASK);

	XSynchronize(display, TRUE);
	XFlush(display);

	return TRUE;
}
Example #8
0
static gboolean
gst_vaapi_display_x11_open_display(GstVaapiDisplay *display)
{
    GstVaapiDisplayX11Private * const priv =
        GST_VAAPI_DISPLAY_X11(display)->priv;

    if (priv->create_display) {
        priv->x11_display = XOpenDisplay(get_display_name(display));
        if (!priv->x11_display)
            return FALSE;
        priv->x11_screen = DefaultScreen(priv->x11_display);
    }
    if (!priv->x11_display)
        return FALSE;

    if (priv->synchronous)
        XSynchronize(priv->x11_display, True);

#ifdef HAVE_XRANDR
    {
        int evt_base, err_base;
        priv->use_xrandr = XRRQueryExtension(
            priv->x11_display, &evt_base, &err_base);
    }
#endif
    return TRUE;
}
Example #9
0
static PyObject *xwrapper_get_string(PyObject *self, PyObject *args) {
	Window w;
	char *propname;

	if(!PyArg_ParseTuple(args, "ks", &w, &propname))
		return NULL;

	Display *d = XOpenDisplay(NULL);
	XSynchronize(d, True);

	Atom prop = XInternAtom(d, propname, True);
	Atom type;
	unsigned int format;
	unsigned long nitems;
	unsigned long after;
	unsigned int *result;
	if(prop)
		XGetWindowProperty(d, w, prop, 0, 128, False, AnyPropertyType, /* 4096 chars should be enough for everything */
							&type, &format, &nitems, &after,
							(unsigned char **) &result);
	XCloseDisplay(d);

	if(!nitems || !prop)
		Py_RETURN_NONE;

	return Py_BuildValue("s", result);
}
Example #10
0
static PyObject *xwrapper_get_cardinal(PyObject *self, PyObject *args) {
	Window w;
	char *propname;
	unsigned int offset;

	if(!PyArg_ParseTuple(args, "kks", &w, &offset, &propname))
		return NULL;

	Display *d = XOpenDisplay(NULL);
	XSynchronize(d, True);

	Atom prop = XInternAtom(d, propname, True);
	Atom type;
	unsigned int format;
	unsigned long nitems;
	unsigned long after;
	unsigned int *result;
	if(prop)
		XGetWindowProperty(d, w, prop, offset, 1, False, AnyPropertyType,
							&type, &format, &nitems, &after,
							(unsigned char **) &result);
	XCloseDisplay(d);

	if(!nitems || !prop)
		Py_RETURN_NONE;

	return Py_BuildValue("k", *result);
}
Example #11
0
Display* InitXInput(void)
{
	Display* pDisp;
	int nMajor, nFEV, nFER;

	pDisp = XOpenDisplay(NULL);
	if (!pDisp)
	{
		fprintf(stderr,"Failed to connect to X server.\n");
		return NULL;
	}

	XSetErrorHandler(ErrorHandler);

	XSynchronize(pDisp,1 /*sync on*/);
	
	if (!XQueryExtension(pDisp,INAME,&nMajor,&nFEV,&nFER))
	{
		fprintf(stderr,"Server does not support XInput extension.\n");
		XCloseDisplay(pDisp);
		return NULL;
	}

	return pDisp;
}
Example #12
0
static void add_hot_key(const char* keyname, const char* command) {
    char* copy = strdup(keyname);
    char* unmodified = strrchr(copy, '-');
    unsigned int modifiers = 0;
    if (unmodified == NULL) {
        unmodified = copy;
    } else {
        *unmodified = 0;
        ++ unmodified;
        modifiers = parse_modifiers(copy, keyname);
    }
    
    HotKey* new_key = new HotKey;
    new_key->keysym = XStringToKeysym(unmodified);
    new_key->modifiers = modifiers;
    new_key->command = strdup(command);
    new_key->next = hotkeys;
    hotkeys = new_key;
    
    XSynchronize(dpy, True);
    attempting_to_grab = keyname;
    XSetErrorHandler(report_key_grab_error);
    for (int screen = 0; screen < screen_count; ++screen) {
        Window root = RootWindow(dpy, screen);
        XGrabKey(dpy, XKeysymToKeycode(dpy, new_key->keysym), modifiers, root, False, GrabModeAsync, GrabModeAsync);
    }
    XSetErrorHandler(NULL);
    
    free(copy);
}
Example #13
0
static PyObject *xwrapper_send_event(PyObject *self, PyObject *args) {
	XEvent xev;
	char *atname;

	if(!PyArg_ParseTuple(args, "kskkkkk", (unsigned int *) &xev.xclient.window, &atname,
							&xev.xclient.data.l[0], &xev.xclient.data.l[1],
							&xev.xclient.data.l[2], &xev.xclient.data.l[3],
							&xev.xclient.data.l[4]))
		return NULL;

	Display *d = XOpenDisplay(NULL);
	XSynchronize(d, True);

	xev.xclient.type = ClientMessage;
	xev.xclient.serial = 0;
	xev.xclient.send_event = True;
	xev.xclient.message_type = XInternAtom(d, atname, False);
	xev.xclient.format = 32;

	XSendEvent(d, DefaultRootWindow(d), True,
				SubstructureNotifyMask | SubstructureRedirectMask,
				&xev);

	XCloseDisplay(d);

	Py_RETURN_NONE;
}
Example #14
0
static cairo_surface_t *
_cairo_boilerplate_qt_create_surface (const char		*name,
				      cairo_content_t		 content,
				      double			 width,
				      double			 height,
				      double			 max_width,
				      double			 max_height,
				      cairo_boilerplate_mode_t	 mode,
				      void		       **closure)
{
    qt_closure_t *qtc;

    qtc = (qt_closure_t *) xcalloc (1, sizeof (qt_closure_t));
    qtc->dpy = XOpenDisplay (NULL);
    if (qtc->dpy == NULL) {
	free (qtc);
	return NULL;
    }

    if (mode == CAIRO_BOILERPLATE_MODE_TEST)
	XSynchronize (qtc->dpy, True);

    qtc->app = new QApplication (qtc->dpy);
    *closure = qtc;
    return cairo_qt_surface_create_with_qpixmap (content, width, height);
}
Example #15
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);
}
Example #16
0
/* After parsing the command line and the resource database, use the
   information. */
static bool
use_options(void)
{
#ifdef HAVE_X11
    int x, y, w, h;
    int gflgs = XParseGeometry(geom_str, &x, &y, &w, &h);

    if(!(gflgs & WidthValue))
	w = -1;
    if(!(gflgs & HeightValue))
	h = -1;
    /* TODO: need to use -ve values properly */
    if(!(gflgs & XValue))
	x = -1;
    if(!(gflgs & YValue))
	y = -1;

    set_default_geometry (x, y, w, h);
#endif

#ifdef HAVE_X11
    if (opt_sync)
	XSynchronize (gdk_display, True);
#endif

    return true;
}
Example #17
0
void wsMainLoop(void)
{
    int delay = 20;

    mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] init threads: %d\n", XInitThreads());
    XSynchronize(wsDisplay, False);
    XLockDisplay(wsDisplay);
// XIfEvent( wsDisplay,&wsEvent,wsEvents );

    while (wsTrue) {
        // handle pending events
        while (XPending(wsDisplay)) {
            XNextEvent(wsDisplay, &wsEvent);
            wsEvents(wsDisplay, &wsEvent);
            delay = 0;
        }

        usleep(delay * 1000); // FIXME!

        if (delay < 10 * 20)
            delay += 20;               // pump up delay up to 0.2 sec (low activity)
    }

    XUnlockDisplay(wsDisplay);
}
::Display* XITServerTest::Display() {
    ::Display *dpy = xorg::testing::Test::Display();
    if (!synchronized) {
        XSynchronize(dpy, True);
        synchronized = true;
    }
    return dpy;
}
Example #19
0
File: glc.c Project: cout/mglc
/* Create a new GLC context and return its ID */
GLint glcGenContext() {
	GLCcontext *c;
	int i, j;

	/* If this is the first call, initialize our data */
	if(numGlcContexts==0) {
		memset(glcContextList, 0, sizeof(glcContextList));
		memset(glcContexts, 0, sizeof(glcContexts));
	}
	isFirstCall = FALSE;

	/* Find context that is not in use */
	for(j = 1; j < MAX_GLC_CONTEXTS; j++)
		if(!glcContexts[j].isContext) break;
	if(j == MAX_GLC_CONTEXTS) return 0;

	/* Add this context to the list */
	glcContextList[numGlcContexts++] = j;
	glcContextList[numGlcContexts] = 0;

	/* Initialize this context */
	c = &glcContexts[j];
	c->isContext = TRUE;
	c->display = (Display*)glXGetCurrentDisplay();
	c->bitmap_matrix[0] = 1.0;
	c->bitmap_matrix[1] = 0.0;
	c->bitmap_matrix[2] = 0.0;
	c->bitmap_matrix[3] = 1.0;
	c->bitmap_scale[0] = 1.0;
	c->bitmap_scale[1] = 1.0;
	last_error = GLC_NONE;
	c->data_pointer = 0;
	c->num_fonts = 0;
	c->list_base = glGenLists(256);
	c->reload_font = TRUE;
	c->scale_change = TRUE;
	memcpy(c->bitmap_matrix, identity_matrix_2_by_2, sizeof(c->bitmap_matrix));

	/* Turn on synchronization.  This does not affear to affect performance,
	 * and seems to keep my X server from crashing.  Still, this should
	 * not be necessary, and an alternative solution would probably be
	 * preferable.
	 */
	XSynchronize(c->display, TRUE);

	/* Load a default font */
	memset(c->font_list, 0, sizeof(c->font_list));
	c->fonts[0][GLC_STYLE_NORMAL].xfontinfo = XLoadQueryFont(c->display, "variable");
	c->fonts[0][GLC_STYLE_NORMAL].xfont = c->fonts[0][GLC_STYLE_NORMAL].xfontinfo->fid;
	c->fonts[0][GLC_STYLE_NORMAL].name = strdup("base");
	c->fonts[0][GLC_STYLE_NORMAL].xfontprefix =
	c->fonts[0][GLC_STYLE_NORMAL].xfontsuffix = strdup("");
	c->fonts[0][GLC_STYLE_NORMAL].isFont = TRUE;
	glXUseXFont(c->fonts[0][GLC_STYLE_NORMAL].xfont, 0, 256, c->list_base);
	for(i = 1; i < NUM_GLC_STYLES; i++) c->fonts[0][i].isFont = FALSE;

	return j;
}
Example #20
0
Blackbox::Blackbox(char **m_argv, const char *dpy_name,
                   const std::string& rc, bool multi_head)
  : bt::Application(m_argv[0], dpy_name, multi_head),
    grab_count(0u), _resource(rc)
{
  if (! XSupportsLocale())
    fprintf(stderr, _("X server does not support locale\n"));

  if (XSetLocaleModifiers("") == NULL)
    fprintf(stderr, _("cannot set locale modifiers\n"));

  argv = m_argv;

  active_screen = 0;
  focused_window = (BlackboxWindow *) 0;
  _ewmh = (bt::EWMH*) 0;

  init_icccm();

  if (! multi_head || display().screenCount() == 1)
    screen_list_count = 1;
  else
    screen_list_count = display().screenCount();

  _resource.load(*this);

  screen_list = new BScreen*[screen_list_count];
  unsigned int managed = 0;
  for (unsigned int i = 0; i < screen_list_count; ++i) {
    BScreen *screen = new BScreen(this, i);

    if (! screen->isScreenManaged()) {
      delete screen;
      continue;
    }

    screen_list[i] = screen;
    ++managed;
  }

  if (managed == 0) {
    fprintf(stderr, _("%s: no manageable screens found, exiting...\n"),
            applicationName().c_str());
    ::exit(3);
  }

  screen_list_count = managed;

  // start with the first managed screen as the active screen
  setActiveScreen(screen_list[0]);

  XSynchronize(XDisplay(), false);
  XSync(XDisplay(), false);

  timer = new bt::Timer(this, this);
  timer->setTimeout(0l);
}
Example #21
0
void x_sync_off()
{
	Disp_Obj *dop;

	dop = curr_dop();
	if( dop == NO_DISP_OBJ ) return;

	XSynchronize(dop->do_dpy,False);
}
Example #22
0
static void
gst_vdp_sink_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  VdpSink *vdp_sink;

  g_return_if_fail (GST_IS_VDP_SINK (object));

  vdp_sink = GST_VDP_SINK (object);

  switch (prop_id) {
    case PROP_DISPLAY:
      vdp_sink->display_name = g_strdup (g_value_get_string (value));
      break;
    case PROP_SYNCHRONOUS:
      vdp_sink->synchronous = g_value_get_boolean (value);
      if (vdp_sink->device) {
        GST_DEBUG_OBJECT (vdp_sink, "XSynchronize called with %s",
            vdp_sink->synchronous ? "TRUE" : "FALSE");
        g_mutex_lock (vdp_sink->x_lock);
        XSynchronize (vdp_sink->device->display, vdp_sink->synchronous);
        g_mutex_unlock (vdp_sink->x_lock);
      }
      break;
    case PROP_PIXEL_ASPECT_RATIO:
    {
      GValue *tmp;

      tmp = g_new0 (GValue, 1);
      g_value_init (tmp, GST_TYPE_FRACTION);

      if (!g_value_transform (value, tmp)) {
        GST_WARNING_OBJECT (vdp_sink,
            "Could not transform string to aspect ratio");
        g_free (tmp);
      } else {
        GST_DEBUG_OBJECT (vdp_sink, "set PAR to %d/%d",
            gst_value_get_fraction_numerator (tmp),
            gst_value_get_fraction_denominator (tmp));
        g_free (vdp_sink->par);
        vdp_sink->par = tmp;
      }
    }
      break;
    case PROP_HANDLE_EVENTS:
      gst_vdp_sink_set_event_handling (GST_X_OVERLAY (vdp_sink),
          g_value_get_boolean (value));
      break;
    case PROP_HANDLE_EXPOSE:
      vdp_sink->handle_expose = g_value_get_boolean (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Example #23
0
Display *xwin_init(const char *display_name, const char *prgname, const char *classname, int argc, char **argv, int *pscreen, unsigned int *pw, unsigned int *ph)
{
  XWindowAttributes xwa;

/*
  FILE *f;
  f = fopen("bee.raw", "rb");
  fread(leftarrow_bits, 1, 32, f);
  fclose(f);
  f = fopen("beemask.raw", "rb");
  fread(rightarrow_bits, 1, 32, f);
  fclose(f);
  frickelfix(leftarrow_bits);
  frickelfix(rightarrow_bits);
*/

  if ((_wndh_gl.display = XOpenDisplay(display_name)) == NULL)
  {
    fprintf(stderr, "failed to connect to X server %s\n", XDisplayName(display_name));
    exit (EXIT_FAILURE);
  }
  XSynchronize(_wndh_gl.display, True);
  _wndh_gl.default_screen = DefaultScreen(_wndh_gl.display);
  _wndh_gl.width = DisplayWidth(_wndh_gl.display, _wndh_gl.default_screen);
  _wndh_gl.height = DisplayHeight(_wndh_gl.display, _wndh_gl.default_screen);
  _wndh_gl.black = BlackPixel(_wndh_gl.display, _wndh_gl.default_screen); 
  _wndh_gl.white = WhitePixel(_wndh_gl.display, _wndh_gl.default_screen);
  _wndh_gl.root_window = RootWindow(_wndh_gl.display, _wndh_gl.default_screen);
  XGetWindowAttributes(_wndh_gl.display, _wndh_gl.root_window, &xwa);
  _wndh_gl.depth = xwa.depth;
  _wndh_gl.uparr_pix = XCreatePixmapFromBitmapData(_wndh_gl.display, _wndh_gl.root_window,
	  uparrow_bits, uparrow_width, uparrow_height, _wndh_gl.black, _wndh_gl.white, _wndh_gl.depth);
  _wndh_gl.dnarr_pix = XCreatePixmapFromBitmapData(_wndh_gl.display, _wndh_gl.root_window,
	  downarrow_bits, downarrow_width, downarrow_height, _wndh_gl.black, _wndh_gl.white, _wndh_gl.depth);
  _wndh_gl.lfarr_pix = XCreatePixmapFromBitmapData(_wndh_gl.display, _wndh_gl.root_window,
	  leftarrow_bits, leftarrow_width, leftarrow_height, _wndh_gl.black, _wndh_gl.white, _wndh_gl.depth);
  _wndh_gl.rtarr_pix = XCreatePixmapFromBitmapData(_wndh_gl.display, _wndh_gl.root_window,
	  rightarrow_bits, rightarrow_width, rightarrow_height, _wndh_gl.black, _wndh_gl.white, _wndh_gl.depth);
  _wndh_gl.sizer_pix = XCreatePixmapFromBitmapData(_wndh_gl.display, _wndh_gl.root_window,
	  sizer_bits, sizer_width, sizer_height, _wndh_gl.black, _wndh_gl.white, _wndh_gl.depth);
  _wndh_gl.wm_del_atom = XInternAtom(_wndh_gl.display, "WM_DELETE_WINDOW", True);
  strncpy(_wndh_gl.prgname, prgname, WH_MAX_NAMELENGTH);
  strncpy(_wndh_gl.classname, classname, WH_MAX_NAMELENGTH);
  _wndh_gl.argc = argc;
  _wndh_gl.argv = argv;
  *pscreen = _wndh_gl.default_screen;
  *pw = _wndh_gl.width;
  *ph = _wndh_gl.height;

#ifdef DEBUG
  printf("connected to X server %s\n", XDisplayName(display_name));
#endif

  return (_wndh_gl.display);
}
Example #24
0
gboolean
_cogl_xlib_renderer_connect (CoglRenderer *renderer, CoglError **error)
{
  CoglXlibRenderer *xlib_renderer =
    _cogl_xlib_renderer_get_data (renderer);
  CoglX11Renderer *x11_renderer =
    (CoglX11Renderer *) xlib_renderer;
  int damage_error;
  int randr_error;

  if (!assert_xlib_display (renderer, error))
    return FALSE;

  if (getenv ("COGL_X11_SYNC"))
    XSynchronize (xlib_renderer->xdpy, TRUE);

  /* Check whether damage events are supported on this display */
  if (!XDamageQueryExtension (xlib_renderer->xdpy,
                              &x11_renderer->damage_base,
                              &damage_error))
    x11_renderer->damage_base = -1;

  /* Check whether randr is supported on this display */
  if (!XRRQueryExtension (xlib_renderer->xdpy,
                          &x11_renderer->randr_base,
                          &randr_error))
    x11_renderer->randr_base = -1;

  xlib_renderer->trap_state = NULL;

  if (renderer->xlib_enable_event_retrieval)
    {
      _cogl_poll_renderer_add_fd (renderer,
                                  ConnectionNumber (xlib_renderer->xdpy),
                                  COGL_POLL_FD_EVENT_IN,
                                  prepare_xlib_events_timeout,
                                  dispatch_xlib_events,
                                  renderer);
    }

  XRRSelectInput(xlib_renderer->xdpy,
                 DefaultRootWindow (xlib_renderer->xdpy),
                 RRScreenChangeNotifyMask
                 | RRCrtcChangeNotifyMask
                 | RROutputPropertyNotifyMask);
  update_outputs (renderer, FALSE);

  register_xlib_renderer (renderer);

  cogl_xlib_renderer_add_filter (renderer,
                                 randr_filter,
                                 renderer);

  return TRUE;
}
Example #25
0
/* ------------------------------------------------------------------ */ 
int initWindow()
{
  wW = 2*OFFX + 14*DX + 13*GAPX;
  wH = MYZERO + MY + 2*OFFY + 4*DY + 3*GAPY;

  XSynchronize(theDisplay, 1);

  xswa.background_pixmap = None;
  xswa.background_pixel  = theBlack.pixel;
  xswa.border_pixmap     = CopyFromParent;
  xswa.border_pixel      = theBlack.pixel;
  xswa.bit_gravity       = ForgetGravity;
  xswa.win_gravity       = NorthWestGravity;
  xswa.backing_store     = Always;
  xswa.backing_planes    = 0xffffffff;       /* default*/
  xswa.backing_pixel     = 0x00000000;       /* default*/
  xswa.save_under        = FALSE;
  xswa.event_mask        = 
                           ButtonPressMask |
                           ButtonReleaseMask | 
                           ExposureMask |
                           /* ResizeRedirectMask |*/
                         0 ;
  xswa.do_not_propagate_mask = 
                           KeyPressMask |
                           KeyReleaseMask |
                           PointerMotionMask |
                           ButtonMotionMask |
                           /* ResizeRedirectMask |*/
                         0 ;
  xswa.override_redirect = FALSE;
  xswa.colormap          = theCmap;
  flag = 
         /* CWBackPixmap |*/
         CWBackPixel |
         /* CWBorderPixmap |*/
         /* CWBorderPixel |*/
         /* CWBitGravity |*/
         /* CWWinGravity |*/
         CWBackingStore |
         /* CWBackingPlanes |*/ 
         /* CWBackingPixel | */
         CWOverrideRedirect | 
         CWSaveUnder | 
         CWEventMask  | 
         CWDontPropagate | 
         CWColormap ;

  theWindow = XCreateWindow(theDisplay, rootW, 0, 0, wW, wH, 0, theDepth,
         InputOutput, theVisual, flag, &xswa);
  XMapWindow(theDisplay, theWindow);

  /* printf("Window done \n"); */
  return 0;
}
Example #26
0
static Display* InitDisplay()
{
    Display* dpy = XOpenDisplay(0);
    if(!dpy)
    {
        perror("Couldn't connect to X server\n");
        return 0;
    }
    XSynchronize(dpy, 1);//this slows down but makes synch calls. REMOVE in release
    return dpy;
}
Example #27
0
Display *setup_display(void)
{
	Display *dpy;
	dpy = XOpenDisplay(NULL);
	if (!dpy) {
		perror("XOpenDisplay");
		exit(255);
	}
	XSynchronize(dpy,True);
	return dpy;
}
void
InstallX11ErrorHandler()
{
  XSetErrorHandler(X11Error);

  Display *display = mozilla::DefaultXDisplay();
  NS_ASSERTION(display, "No X display");
  if (PR_GetEnv("MOZ_X_SYNC")) {
    XSynchronize(display, True);
  }
}
Example #29
0
void
InstallGdkErrorHandler()
{
  g_log_set_handler("Gdk",
                    (GLogLevelFlags)(G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
                    GdkErrorHandler,
                    nullptr);
  if (PR_GetEnv("MOZ_X_SYNC")) {
    XSynchronize(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), True);
  }
}
static void
set_synchronous(GstVaapiDisplayX11 *display, gboolean synchronous)
{
    GstVaapiDisplayX11Private * const priv = display->priv;

    if (priv->synchronous != synchronous) {
        priv->synchronous = synchronous;
        if (priv->x11_display)
            XSynchronize(priv->x11_display, synchronous);
    }
}