Exemplo n.º 1
0
static void initializeGtk(QLibrary* module = 0)
{
    // Ensures missing Gtk initialization in some versions of Adobe's flash player
    // plugin do not cause crashes. See BR# 40567, 44324, and 44405 for details.  
    if (module) {
        typedef void *(*gtk_init_ptr)(int*, char***);
        gtk_init_ptr gtkInit = (gtk_init_ptr)module->resolve("gtk_init");
        if (gtkInit) {
            // Prevent gtk_init() from replacing the X error handlers, since the Gtk
            // handlers abort when they receive an X error, thus killing the viewer.
#ifdef Q_WS_X11
            int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0);
            int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0);
#endif
            gtkInit(0, 0);
#ifdef Q_WS_X11
            XSetErrorHandler(old_error_handler);
            XSetIOErrorHandler(old_io_error_handler);
#endif
            return;
        }
    }

    QLibrary library("libgtk-x11-2.0.so.0");
    if (library.load()) {
        typedef void *(*gtk_init_check_ptr)(int*, char***);
        gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
        // NOTE: We're using gtk_init_check() since gtk_init() calls exit() on failure.
        if (gtkInitCheck)
            (void) gtkInitCheck(0, 0);
    }
}
Exemplo n.º 2
0
int 
PingServer( void )
{
    int	    (*oldError)();
    SIGVAL  (*oldSig)();
    int	    oldAlarm;

    oldError = XSetIOErrorHandler ((XIOErrorHandler)PingLost);
    oldAlarm = alarm (0);
    oldSig = signal (SIGALRM, PingBlocked);
    alarm (pingTimeout * 60);
    if (!setjmp (pingTime))
    {
	XSync (dpyinfo.dpy, 0);
    }
    else
    {
	if ( serverDead ) {
	    LogError(ReadCatalog(
                                 MC_LOG_SET,MC_LOG_DEADSRV,MC_DEF_LOG_DEADSRV),
		dpyinfo.name);
	    alarm (0);
	    signal (SIGALRM, SIG_DFL);
	    XSetIOErrorHandler (oldError);
	    return 0;
	}
    }
    alarm (0);
    signal (SIGALRM, oldSig);
    alarm (oldAlarm);
    XSetIOErrorHandler (oldError);
    return 1;
}
Exemplo n.º 3
0
int
PingServer (struct display *d, Display *alternateDpy)
{
    int	    (*oldError)(Display *);
    SIGVAL  (*oldSig)(int);
    int	    oldAlarm;
    static Display *aDpy;
    
    aDpy = (alternateDpy != NULL ? alternateDpy : dpy);
    oldError = XSetIOErrorHandler (PingLostIOErr);
    oldAlarm = alarm (0);
    oldSig = Signal (SIGALRM, PingLostSig);
    (void) alarm (d->pingTimeout * 60);
    if (!Setjmp (pingTime))
    {
	Debug ("Ping server\n");
	XSync (aDpy, 0);
    }
    else
    {
	Debug ("Server dead\n");
	(void) alarm (0);
	(void) Signal (SIGALRM, SIG_DFL);
	XSetIOErrorHandler (oldError);
	return 0;
    }
    (void) alarm (0);
    (void) Signal (SIGALRM, oldSig);
    (void) alarm (oldAlarm);
    Debug ("Server alive\n");
    XSetIOErrorHandler (oldError);
    return 1;
}
Exemplo n.º 4
0
void xconn_clean(xconn_t c)
{
	Window dummy, parent;
	Window *children;
	unsigned int nchildren;
	unsigned int i;
	Window Root;

	if(!c) return;

	XSetErrorHandler(CatchErrors);
	XSetIOErrorHandler(CatchIOErrors);

	Root = DefaultRootWindow(c);

	nchildren = 0;
	if(!setjmp(XErrEnv))
		XQueryTree(c, Root, &dummy, &parent, &children, &nchildren);
	else
		goto out;
	for( i = 0; i < nchildren; i++ )
	{
		if(!setjmp(XErrEnv))
		XKillClient(c, children[i]);
	}
	XFree((char *)children);
	if(!setjmp(XErrEnv))
		XSync(c, 0);
out:
	XSetErrorHandler(NULL);
	XSetIOErrorHandler(NULL);
}
Exemplo n.º 5
0
void xconn_close(xconn_t c)
{
	if(!c) return;
	XSetErrorHandler(CatchErrors);
	XSetIOErrorHandler(CatchIOErrors);
	if(!setjmp(XErrEnv))
		XCloseDisplay(c);
	XSetErrorHandler(NULL);
	XSetIOErrorHandler(NULL);
}
Exemplo n.º 6
0
static void x11IOErrorHandlerEnable(int onoff, JNIEnv * env) {
    if(onoff) {
        if(NULL==origIOErrorHandler) {
            setupJVMVars(env);
            origIOErrorHandler = XSetIOErrorHandler(x11IOErrorHandler);
        }
    } else {
        XSetIOErrorHandler(origIOErrorHandler);
        origIOErrorHandler = NULL;
    }
}
Exemplo n.º 7
0
static void x11IOErrorHandlerEnable(int onoff, JNIEnv * env) {
    if(onoff) {
        if(NULL==origIOErrorHandler) {
            x11ErrorHandlerJNIEnv = env;
            origIOErrorHandler = XSetIOErrorHandler(x11IOErrorHandler);
        }
    } else {
        XSetIOErrorHandler(origIOErrorHandler);
        origIOErrorHandler = NULL;
    }
}
Exemplo n.º 8
0
void xorg::testing::XServer::RegisterXIOErrorHandler()
{
  XIOErrorHandler old_handler, def_handler;

  old_handler = XSetIOErrorHandler(NULL);
  def_handler = XSetIOErrorHandler(_x_io_error_handler);

  if (old_handler != def_handler &&
      old_handler != _XDefaultIOError &&
      old_handler != _x_io_error_handler)
    XSetIOErrorHandler(old_handler);
}
Exemplo n.º 9
0
int
WaitForServer (struct display *d)
{
    static int i;

    for (i = 0; i < (d->openRepeat > 0 ? d->openRepeat : 1); i++) {
    	(void) Signal (SIGALRM, abortOpen);
    	(void) alarm ((unsigned) d->openTimeout);
    	if (!Setjmp (openAbort)) {
	    Debug ("Before XOpenDisplay(%s)\n", d->name);
	    errno = 0;
	    (void) XSetIOErrorHandler (openErrorHandler);
	    dpy = XOpenDisplay (d->name);
#ifdef STREAMSCONN
	    {
		/* For some reason, the next XOpenDisplay we do is
		   going to fail, so we might as well get that out
		   of the way.  There is something broken here. */
		Display *bogusDpy = XOpenDisplay (d->name);
		Debug ("bogus XOpenDisplay %s\n",
		       bogusDpy ? "succeeded" : "failed");
		if (bogusDpy) XCloseDisplay(bogusDpy); /* just in case */
	    }
#endif
	    (void) alarm ((unsigned) 0);
	    (void) Signal (SIGALRM, SIG_DFL);
	    (void) XSetIOErrorHandler ((int (*)(Display *)) 0);
	    Debug ("After XOpenDisplay(%s)\n", d->name);
	    if (dpy) {
#ifdef XDMCP
	    	if (d->displayType.location == Foreign)
		    GetRemoteAddress (d, ConnectionNumber (dpy));
#endif
	    	RegisterCloseOnFork (ConnectionNumber (dpy));
		(void) fcntl (ConnectionNumber (dpy), F_SETFD, 0);
	    	return 1;
	    } else {
	    	Debug ("OpenDisplay failed %d (%s) on \"%s\"\n",
		       errno, strerror (errno), d->name);
	    }
	    Debug ("waiting for server to start %d\n", i);
	    sleep ((unsigned) d->openDelay);
    	} else {
	    Debug ("hung in open, aborting\n");
	    LogError ("Hung in XOpenDisplay(%s), aborting\n", d->name);
	    (void) Signal (SIGALRM, SIG_DFL);
	    break;
    	}
    }
    Debug ("giving up on server\n");
    LogError ("server open failed for %s, giving up\n", d->name);
    return 0;
}
Exemplo n.º 10
0
bool X11Helper::OpenXConnection()
{
	DEBUG_ASSERT( Dpy == nullptr && Win == None );
	Dpy = XOpenDisplay(0);
	if( Dpy == nullptr )
		return false;

	XSetIOErrorHandler( FatalCallback );
	XSetErrorHandler( ErrorCallback );
	int event_base, error_base;
	display_supports_dpms_extension= DPMSQueryExtension(Dpy, &event_base, &error_base);
	if(display_supports_dpms_extension)
	{
		LOG->Trace("DPMSQueryExtension returned true.  Stepmania will disable power management, and restore the original state on exit.");
		CARD16 power_level;
		BOOL state;
		if(DPMSInfo(Dpy, &power_level, &state))
		{
			dpms_state_at_startup= state;
			DPMSDisable(Dpy);
		}
		else
		{
			LOG->Trace("DPMSInfo returned false.  Stepmania will not be able to disable power management.");
		}
	}
	else
	{
		LOG->Trace("DPMSQueryExtension returned false, which means this display does not support the DPMS extension.  Stepmania will not be able to disable power management.");
	}
	return true;
}
Exemplo n.º 11
0
void
rxvt_init ()
{
  ptytty::init ();

  if (!ev_default_loop (0))
    rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n");

  rxvt_environ = environ;

  signal (SIGHUP,  SIG_IGN);
  signal (SIGPIPE, SIG_IGN);

  sig_handlers.sw_term.start (SIGTERM); ev_unref ();
  sig_handlers.sw_int.start  (SIGINT);  ev_unref ();

  /* need to trap SIGURG for SVR4 (Unixware) rlogin */
  /* signal (SIGURG, SIG_DFL); */

  old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
  // TODO: handle this with exceptions and tolerate the memory loss
  XSetIOErrorHandler (rxvt_xioerror_handler);

  XrmInitialize ();
}
Exemplo n.º 12
0
/*
main:
   A C main function...
*/
int main (int argc, char *argv[]) {
   int err = 0;
   int screen = 0;
   char *title = NULL;
   Display *dsp = NULL;
   Window root;
   Window res = -1;

   if (argc < 2) {
      printf("(!)Error: Missing command line argument for the window Title!");
      printf("\n\n");
      exit(1);
   }

   title = argv[1];
   printf("(*)Looking for window title: \"%s\"\n", title);

   dsp = XOpenDisplay(NULL);
   XSetIOErrorHandler(_IOErrorHandler);
   XSetErrorHandler(_XErrorHandler);
   screen = XDefaultScreen(dsp);
   root = XRootWindow(dsp, screen);
   res = findFireFoxWindows(dsp, root, title);
   printf("RES: %d\n", res);

   SaveFile(dsp, res);

   return err;

}
Exemplo n.º 13
0
/* signal handlers */
void initialize_signals(void) {
	signal(SIGHUP,  interrupted);
	signal(SIGINT,  interrupted);
	signal(SIGQUIT, interrupted);
	signal(SIGABRT, interrupted);
	signal(SIGTERM, interrupted);
	signal(SIGBUS,  interrupted);
	signal(SIGSEGV, interrupted);
	signal(SIGFPE,  interrupted);

	if (!sigpipe || *sigpipe == '\0' || !strcmp(sigpipe, "skip")) {
		;
	} else if (strstr(sigpipe, "ignore:") == sigpipe) {
		ignore_sigs(sigpipe);
	} else if (strstr(sigpipe, "exit:") == sigpipe) {
		ignore_sigs(sigpipe);
	} else if (!strcmp(sigpipe, "ignore")) {
#ifdef SIG_IGN
		signal(SIGPIPE, SIG_IGN);
#endif
	} else if (!strcmp(sigpipe, "exit")) {
		rfbLog("initialize_signals: will exit on SIGPIPE\n");
		signal(SIGPIPE, interrupted);
	}

#if NO_X11
	return;
#else
	X_LOCK;
	Xerror_def = XSetErrorHandler(Xerror);
	XIOerr_def = XSetIOErrorHandler(XIOerr);
	X_UNLOCK;
#endif	/* NO_X11 */
}
Exemplo n.º 14
0
void
XInterface::FinishConnection() { // not to be confused with the FinnishConnection
	Window root;
	
	dprintf(D_ALWAYS, "Connected to X server: %s\n", _display_name);
	g_connected = true;

	dprintf(D_FULLDEBUG, "Reset timer: %d\n", _daemon_core_timer);
	daemonCore->Reset_Timer( _daemon_core_timer, 5 ,5 );
	
	// See note above the function to see why we need to do this.
	XSetErrorHandler((XErrorHandler) CatchFalseAlarm);
	XSetIOErrorHandler((XIOErrorHandler) CatchIOFalseAlarm);

	//Select the events on each root window of each screen
	for (int s = 0; s < ScreenCount(_display); s++)
	{
		root = RootWindowOfScreen(ScreenOfDisplay(_display, s));
		SelectEvents(root);
	}
	
	// Query pointer stuff
	_pointer_root = DefaultRootWindow(_display);
	_pointer_screen = ScreenOfDisplay(_display, DefaultScreen(_display));
	_pointer_prev_x = -1;
	_pointer_prev_y = -1;
	_pointer_prev_mask = 0;

	// Newly connected display needs to see if it has the extension
	needsCheck = true;
	hasXss = false; 
	
	// unset env needed here?
	set_condor_priv();
}
Exemplo n.º 15
0
WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
{

    const Vector<String>& arguments = GetArguments();

#ifdef ATOMIC_PLATFORM_LINUX
    XSetErrorHandler(XErrorHandlerImpl);
    XSetIOErrorHandler(XIOErrorHandlerImpl);

    // Install a signal handler so we clean up after ourselves.
    signal(SIGINT, TerminationSignalHandler);
    signal(SIGTERM, TerminationSignalHandler);

#endif


    // IMPORTANT: See flags being set in implementation of void WebAppBrowser::OnBeforeCommandLineProcessing
    // these include "--enable-media-stream", "--enable-usermedia-screen-capturing", "--off-screen-rendering-enabled", "--transparent-painting-enabled"

#ifdef ATOMIC_PLATFORM_LINUX
    static const char* _argv[3] = { "AtomicWebView", "--disable-setuid-sandbox" };
    CefMainArgs args(3, (char**) &_argv);
#else
    CefMainArgs args;
#endif

    CefSettings settings;
    settings.windowless_rendering_enabled = 1;

    // default background is white, add a setting
    // settings.background_color = 0;

    if (productVersion_.Length())
    {
        CefString(&settings.product_version).FromASCII(productVersion_.CString());
    }

    if (userAgent_.Length())
    {
        CefString(&settings.user_agent).FromASCII(userAgent_.CString());
    }
    
    settings.remote_debugging_port = debugPort_;

    d_ = new WebBrowserHostPrivate(this);

    // If losing OSX system menu, it means we're calling this
    // before initializing graphics subsystem
    if (!CefInitialize(args, settings, d_->app_, nullptr))
    {
        LOGERROR("CefInitialize - Error");
    }

    RegisterWebSchemeHandlers(this);

    SubscribeToEvent(E_UPDATE, HANDLER(WebBrowserHost, HandleUpdate));

    instance_ = this;

}
Exemplo n.º 16
0
NPError
NP_Initialize(NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *aNPPFuncs)
{
    trace_info_f("[NP] %s aNPNFuncs=%p, aNPPFuncs=%p, browser API version = %u\n", __func__,
                 aNPNFuncs, aNPPFuncs, aNPNFuncs->version);

    // set logging-only error handler.
    // Ignore a previous one, we have no plans to restore it
    (void)XSetErrorHandler(x_error_handler);
    (void)XSetIOErrorHandler(x_io_error_hanlder);

    memset(&npn, 0, sizeof(npn));
    memcpy(&npn, aNPNFuncs, sizeof(npn) < aNPNFuncs->size ? sizeof(npn) : aNPNFuncs->size);

    NPPluginFuncs pf;
    memset(&pf, 0, sizeof(NPPluginFuncs));
    pf.size = MIN(aNPPFuncs->size, sizeof(NPPluginFuncs));

    // browser is supposed to fill .size and .version
    pf.newp =               NPP_New;
    pf.destroy =            NPP_Destroy;
    pf.setwindow =          NPP_SetWindow;
    pf.newstream =          NPP_NewStream;
    pf.destroystream =      NPP_DestroyStream;
    pf.asfile =             NPP_StreamAsFile;
    pf.writeready =         NPP_WriteReady;
    pf.write =              NPP_Write;
    pf.print =              NPP_Print;
    pf.event =              NPP_HandleEvent;
    pf.urlnotify =          NPP_URLNotify;
    pf.getvalue =           NPP_GetValue;
    pf.setvalue =           NPP_SetValue;
    pf.gotfocus =           NPP_GotFocus;
    pf.lostfocus =          NPP_LostFocus;
    pf.urlredirectnotify =  NPP_URLRedirectNotify;
    pf.clearsitedata =      NPP_ClearSiteData;
    pf.getsiteswithdata =   NPP_GetSitesWithData;
    pf.didComposite =       NPP_DidComposite;

    memcpy(aNPPFuncs, &pf, pf.size);

    if (tables_open_display() != 0)
        return NPERR_GENERIC_ERROR;

    if (aNPNFuncs->version < NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) {
        config.quirks.plugin_missing = 1;
        config.quirks.incompatible_npapi_version = 1;
    }

    load_ppp_module();

    int res = call_plugin_init_module();
    if (res != 0) {
        trace_error("%s, PPP_InitializeModule returned %d\n", __func__, res);
        return NPERR_GENERIC_ERROR;
    }

    return NPERR_NO_ERROR;
}
Exemplo n.º 17
0
void
XIOError_Shutdown(ToolsAppCtx *ctx,
                  ToolsPluginData *pdata)
{
   XSetIOErrorHandler(gOrigHandler);
   gCtx = NULL;
   gOrigHandler = NULL;
}
Exemplo n.º 18
0
void
meta_errors_init (void)
{
#if !GTK_CHECK_VERSION (3, 0, 0)
  XSetErrorHandler (x_error_handler);
  XSetIOErrorHandler (x_io_error_handler);
#endif
}
Exemplo n.º 19
0
Arquivo: session.c Projeto: dct/xvnkb
/*----------------------------------------------------------------------------*/
void VKStopXSession()
{
	VKResetMode();
	XSync(display, False);
	XSetIOErrorHandler(old_io_error_handler);
	XSetErrorHandler(old_error_handler);
	XCloseDisplay(display);
}
Exemplo n.º 20
0
static void Init_disp_prop(Display *d, Window win,
			   unsigned w, unsigned h, int x, int y,
			   int flags)
{
    XClassHint		xclh;
    XWMHints		xwmh;
    XSizeHints		xsh;

    xwmh.flags	   = InputHint|StateHint|IconPixmapHint;
    xwmh.input	   = True;
    xwmh.initial_state = NormalState;
    xwmh.icon_pixmap   = XCreateBitmapFromData(d, win,
					       (char *)icon_bits,
					       icon_width, icon_height);

    xsh.flags = (flags|PMinSize|PMaxSize|PBaseSize|PResizeInc);
    xsh.width = w;
    xsh.base_width =
    xsh.min_width = MIN_TOP_WIDTH;
    xsh.max_width = MAX_TOP_WIDTH;
    xsh.width_inc = 1;
    xsh.height = h;
    xsh.base_height =
    xsh.min_height = MIN_TOP_HEIGHT;
    xsh.max_height = MAX_TOP_HEIGHT;
    xsh.height_inc = 1;
    xsh.x = x;
    xsh.y = y;

    xclh.res_name = NULL;	/* NULL: Automatically uses Argv[0], */
    xclh.res_class = myClass; /* stripped of directory prefixes. */

    /*
     * Set the above properties.
     */
    XSetWMProperties(d, win, NULL, NULL, Argv, Argc,
		     &xsh, &xwmh, &xclh);

    /*
     * Now initialize icon and window title name.
     */
    XStoreName(d, win, TITLE);
    XSetIconName(d, win, TITLE);

    if (d != dpy)
	return;

    /*
     * Specify IO error handler and the WM_DELETE_WINDOW atom in
     * an attempt to catch 'nasty' quits.
     */
    ProtocolAtom = XInternAtom(d, "WM_PROTOCOLS", False);
    KillAtom = XInternAtom(d, "WM_DELETE_WINDOW", False);
    XSetWMProtocols(d, win, &KillAtom, 1);
    XSetIOErrorHandler(FatalError);
}
Exemplo n.º 21
0
void App::StopServer() {
    // Stop alars clock and ignore signals
    alarm(0);
    signal(SIGQUIT, SIG_IGN);
    signal(SIGINT, SIG_IGN);
    signal(SIGHUP, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);
    signal(SIGTERM, SIG_DFL);
    signal(SIGKILL, SIG_DFL);
    signal(SIGALRM, SIG_DFL);

    // Catch X error
    XSetIOErrorHandler(IgnoreXIO);
    if(!setjmp(CloseEnv))
        XCloseDisplay(Dpy);

    // Send HUP to process group
    errno = 0;
    if((killpg(getpid(), SIGHUP) != 0) && (errno != ESRCH))
        cerr << APPNAME << ": can't send HUP to process group " << getpid() << endl;

    // Send TERM to server
    if(ServerPID < 0)
        return;
    errno = 0;
    if(killpg(ServerPID, SIGTERM) < 0) {
        if(errno == EPERM) {
            cerr << APPNAME << ": can't kill X server" << endl;
            exit(ERR_EXIT);
        }
        if(errno == ESRCH)
            return;
    }

    // Wait for server to shut down
    if(!ServerTimeout(10, "X server to shut down")) {
        cerr << endl;
        return;
    }

    cerr << endl << APPNAME << ":  X server slow to shut down, sending KILL signal." << endl;

    // Send KILL to server
    errno = 0;
    if(killpg(ServerPID, SIGKILL) < 0) {
        if(errno == ESRCH)
            return;
    }

    // Wait for server to die
    if(ServerTimeout(3, "server to die")) {
        cerr << endl << APPNAME << ": can't kill server" << endl;
        exit(ERR_EXIT);
    }
    cerr << endl;
}
Exemplo n.º 22
0
void
_gdk_windowing_init (void)
{
  _gdk_x11_initialize_locale ();
  
  XSetErrorHandler (gdk_x_error);
  XSetIOErrorHandler (gdk_x_io_error);

  _gdk_selection_property = gdk_atom_intern_static_string ("GDK_SELECTION");
}
Exemplo n.º 23
0
int
WaitForServer (struct display *d)
{
    static int i;

    for (i = 0; i < (d->openRepeat > 0 ? d->openRepeat : 1); i++) {
	(void) Signal (SIGALRM, abortOpen);
	(void) alarm ((unsigned) d->openTimeout);
	if (!Setjmp (openAbort)) {
	    Debug ("Before XOpenDisplay(%s)\n", d->name);
	    errno = 0;
	    (void) XSetIOErrorHandler (openErrorHandler);
	    d->dpy = XOpenDisplay (d->name);
	    (void) alarm ((unsigned) 0);
	    (void) Signal (SIGALRM, SIG_DFL);
	    (void) XSetIOErrorHandler ((int (*)(Display *)) 0);
	    Debug ("After XOpenDisplay(%s)\n", d->name);
	    if (d->dpy) {
#ifdef XDMCP
		if (d->displayType.location == Foreign)
		    GetRemoteAddress (d, ConnectionNumber (d->dpy));
#endif
		RegisterCloseOnFork (ConnectionNumber (d->dpy));
		(void) fcntl (ConnectionNumber (d->dpy), F_SETFD, 0);
		return 1;
	    } else {
		Debug ("OpenDisplay failed %d (%s) on \"%s\"\n",
		       errno, strerror (errno), d->name);
	    }
	    Debug ("waiting for server to start %d\n", i);
	    sleep ((unsigned) d->openDelay);
	} else {
	    Debug ("hung in open, aborting\n");
	    LogError ("Hung in XOpenDisplay(%s), aborting\n", d->name);
	    (void) Signal (SIGALRM, SIG_DFL);
	    break;
	}
    }
    Debug ("giving up on server\n");
    LogError ("server open failed for %s, giving up\n", d->name);
    return 0;
}
Exemplo n.º 24
0
int main(int argc, char *argv[])
{
    GWindow::initX();
    TextEdit *editor = new TextEdit();
    if (argc > 1) { editor->loadFile(argv[1]); }
    editor->createWindow();
    XSetIOErrorHandler(&IOErrorHandler);
    GWindow::messageLoop();
    GWindow::closeX();
    delete editor;
}
Exemplo n.º 25
0
    static void removeXErrorHandlers()
    {
        if (JUCEApplication::isStandaloneApp())
        {
            XSetIOErrorHandler (oldIOErrorHandler);
            oldIOErrorHandler = 0;

            XSetErrorHandler (oldErrorHandler);
            oldErrorHandler = 0;
        }
    }
Exemplo n.º 26
0
  void XApplication::Run(bool runOnce)
  {
    XSetIOErrorHandler(ErrorHandler);
  
    /*
     * This is where you will implement the event loop. The basic
     * logic of the event loop is as follows:
     * - You should service the CS349 Scheme interpreter to ensure it
     *   progresses (executes any scripts, accepts any user keyboard
     *   input) (already done for you)
     * - Check the return code for scheme_interpreter_service. If it
     *   returns a non-zero value, the application should quit
     * - You need to determine whether there are any events pending in
     *   X lib: call CheckForXEvents().
     * - You should call EventQueue's ProcessNextEvent() method to
     *   process events and service the timers. Note, you should call
     *   this *even if there are no events pending*, since it will
     *   service the timers.
     * - You can optionally call XFlush() to flush X's queue of
     *   graphics commands to the X server, but it is likely
     *   unnecessary given calls to other Xlib functions. See the
     *   following for more information:
     *   http://tronche.com/gui/x/xlib/event-handling/XFlush.html
     * - You should sleep if there is nothing left to do (i.e., there
     *   are no events in our event queue or pending in X's event
     *   queue -- check with XPending). Sleeping for a bit will ensure
     *   the CPU is not throttled.
     * - If you sleep, sleep for a very small amount of time, say
     *   1/1000 of a second, to enable interactive typing rates on the
     *   console. (See the usleep function for fine-grained sleep
     *   amounts).
     * - We *will* check to ensure your app doesn't throttle the CPU
     *   when idle, so make sure you sleep when there are no events.
     */
    this->quit = false;
    do {
      int interpreterReturnCode = 0;

      interpreterReturnCode = scheme_interpreter_service();
      if (interpreterReturnCode == 1) {
        this->Quit();
      }

      // LOG_TODO << "TODO CS349: Implement event loop in XApplication::Run (remove when implemented)";
// TODO CS349
      this->CheckForXEvents();
      this->GetEventQueue()->ProcessNextEvent();
      XFlush(this->display);
      if(!XPending(this->display)){
        usleep(1000);
      }
    } while (!this->quit && !runOnce);
  }
Exemplo n.º 27
0
/* To be called right after connecting */
void
meta_xwayland_complete_init (void)
{
  /* We install an X IO error handler in addition to the child watch,
     because after Xlib connects our child watch may not be called soon
     enough, and therefore we won't crash when X exits (and most important
     we won't reset the tty).
  */
  XSetIOErrorHandler (x_io_error);

  meta_xwayland_init_selection ();
}
Exemplo n.º 28
0
static VALUE
gdk_s_set_x_io_error_handler(VALUE self)
{
#ifdef HAVE_XGETERRORTEXT
    rb_x_io_error = rb_block_proc();
    G_RELATIVE(self, rb_x_io_error);
    XSetIOErrorHandler(rbgdk_x_io_error);
#else
    rb_warn("Not supported on this environment.");
#endif
    return self;
}
Exemplo n.º 29
0
void
gdm_xerrors_init (void)
{
        static gboolean initialized = FALSE;

        if (initialized) {
                return;
        }

        XSetErrorHandler (gdm_x_error);
        XSetIOErrorHandler (gdm_x_io_error);
        initialized = TRUE;
}
Exemplo n.º 30
0
void
_gdk_x11_windowing_init (void)
{
  XSetErrorHandler (gdk_x_error);
  XSetIOErrorHandler (gdk_x_io_error);

  gdk_window_add_filter (NULL,
                         _gdk_wm_protocols_filter,
                         NULL);
  gdk_window_add_filter (NULL,
                         _gdk_x11_dnd_filter,
                         NULL);
}