Exemplo n.º 1
0
/*
 * is_x_vt_active
 * --------------
 * This function is the one called from vtlock.c and which tells
 * if the X vt is active or not.
 * If the X vt is active it returns 1 else 0.
 * -1 is returned in case of errno or if cannot stat.
 */
int
is_x_vt_active(int display_nr)
{
    int active_vt = 0;
    char *path = getenv( "PATH" );
    char *envtokenizer =(char *)NULL;
    struct stat stbuf;

    /* The active VT */
    active_vt = get_active_vt();
    if ( xino == (ino_t)-1 )
      if (stat( XPATH, &stbuf ) == -1 ||
          (xino = find_x( XPATH, XNAME, &xdev )) == (ino_t)-1 ) {
          /* No executable at the default location */
          /* Let's try with $PATH */
          if ( !path ) return -1;
          envtokenizer = strtok( path, ":" );
          while ( envtokenizer ) {
              if ( stat( envtokenizer, &stbuf ) != -1 )
                if ( ( xino = find_x( envtokenizer, XNAME, &xdev ) ) != (ino_t)-1 )
                  break;
              envtokenizer = strtok( (char *)NULL, ":" );
          }
          if ( !envtokenizer ) return -1;
      }
    if ((xproc ==(pid_t)-1 ) &&
        (xproc = find_x_proc(display_nr, xdev, xino)) == (pid_t)-1)
      return -1;
    if ((n_ttys == -1) &&
        (n_ttys = find_tty_inodes(ttyinodes))== 0)
      return -1;
    if ( ! xvt && ( xvt = scan_x_fds( ttyinodes, n_ttys, xproc ) ) == 0 ) return -1;
    return(active_vt == xvt);
}
Exemplo n.º 2
0
static void lxsession_set_active(LXSession *s)
{
	if(!s || s->tty<=0) return;
	if(get_active_vt()==s->tty)
		return;
	set_active_vt(s->tty);
}
Exemplo n.º 3
0
void lxdm_get_tty(void)
{
	char *s = g_key_file_get_string(config, "server", "arg", 0);
	int arc;
	char **arg;
	int len;
	int gotvtarg = 0;
	gboolean plymouth;
    
	plymouth=plymouth_is_running();
	if(plymouth)
	{
		g_message("found plymouth running\n");
		plymouth_prepare_transition();
	}

	old_tty=get_active_vt();
	if( !s ) s = g_strdup("/usr/bin/X");
	g_shell_parse_argv(s, &arc, &arg, 0);
	g_free(s);
	for( len = 0; arg && arg[len]; len++ )
	{
		char *p = arg[len];
		if( !strncmp(p, "vt", 2) && isdigit(p[2]) &&
		( !p[3] || (isdigit(p[3]) && !p[4]) ) )
		{
			def_tty = atoi(p + 2);
			gotvtarg = 1;
		}
		else if(!strcmp(p,"-background") || !strcmp(p,"-nr"))
		{
			nr_tty=1;
		}
		else if(p[0]==':' && isdigit(p[1]))
		{
			def_display=atoi(p+1);
		}
	}
	if(!gotvtarg)
	{
		/* support plymouth */
		if(g_key_file_get_integer(config, "server", "active_vt", 0) )
			/* use the active vt */
			def_tty = old_tty;
		if(plymouth)
		{
			nr_tty=1;
			plymouth_quit_with_transition();
		}
	}
	else
	{
		if(plymouth) /* set tty and plymouth running */
			plymouth_quit_without_transition();
	}
	g_strfreev(arg);
}
Exemplo n.º 4
0
bool
ply_terminal_open (ply_terminal_t *terminal)
{
    ply_terminal_open_result_t open_result;

    assert (terminal != NULL);

    if (terminal->is_open) {
        ply_trace ("terminal %s is already open", terminal->name);
        return true;
    }

    ply_trace ("trying to open terminal '%s'", terminal->name);

    open_result = ply_terminal_open_device (terminal);
    if (open_result != PLY_TERMINAL_OPEN_RESULT_SUCCESS) {
        ply_trace ("could not open %s : %m", terminal->name);
        return false;
    }

    ply_terminal_refresh_geometry (terminal);

    ply_terminal_look_up_color_palette (terminal);
    ply_terminal_save_color_palette (terminal);

    ply_event_loop_watch_signal (terminal->loop,
                                 SIGWINCH,
                                 (ply_event_handler_t)
                                 ply_terminal_refresh_geometry,
                                 terminal);

    if (ply_terminal_is_vt (terminal)) {
        ply_terminal_watch_for_vt_changes (terminal);

        if (get_active_vt (terminal) == terminal->vt_number)
            terminal->is_active = true;
        else
            terminal->is_active = false;
    }

    terminal->is_open = true;

    return true;
}
Exemplo n.º 5
0
/*
 * set_x_vt_active
 * ---------------
 * This is the core function. It check if the VT of the X server managing
 * display number <display_nr> is active.
 */
int
set_x_vt_active(int display_nr)
{
    int fd = -1;

    if ( !othervt ) othervt = get_active_vt();
    if ( !xvt ) (void)is_x_vt_active( display_nr );
    fd = open( CONSOLE, O_RDONLY );
    if ( fd == -1 ) return( -1 );
    if ( ioctl( fd, VT_ACTIVATE, xvt ) == -1 ) {
        close( fd );
        return( -1 );
    }
    if ( ioctl( fd, VT_WAITACTIVE, xvt ) == -1 ) {
        close( fd );
        return( -1 );
    }
    close( fd );
    return 0;
}
static int fbsplash_load() {
	fb_fd = -1;
	last_pos = 0;

	/* Kick start our TTF library */
	if (TTF_Init() < 0) {
		printk("Couldn't initialise TTF.\n");
	}

	/* Find out the FB size */
	if (get_fb_settings(0)) {
		printk("Couldn't get fb settings.\n");
		return 1;
	}

	arg_vc = get_active_vt();
	arg_mode = 's';

	/* Read theme config file */
	if (arg_theme == NULL)
		arg_theme = DEFAULT_THEME;
	config_file = get_cfg_file(arg_theme);
	if (!config_file) {
		printk("Couldn't load config file %s.\n", arg_theme);
		return 1;
	} else
		printk("Using configuration file %s.\n", config_file);

	parse_cfg(config_file);

	/* Prime the font cache with glyphs so we don't need to allocate them later */
	TTF_PrimeCache("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -.", global_font, TTF_STYLE_NORMAL);

	boot_message = rendermessage;

	fb_fd = open_fb();
	if (fb_fd == -1) {
		printk("Couldn't open framebuffer device.\n");
		return 1;
	}

	if (fb_fix.visual == FB_VISUAL_DIRECTCOLOR)
		set_directcolor_cmap(fb_fd);

	fbsplash_fd = open(SPLASH_DEV, O_WRONLY); /* Don't worry if it fails */

	do_getpic(FB_SPLASH_IO_ORIG_USER, 1, 'v'); /* Don't worry if it fails */
	if (do_getpic(FB_SPLASH_IO_ORIG_USER, 0, 's') == -1)
		no_silent_image = 1; /* We do care if this fails. */

	/* These next two touch the kernel and are needed even for silent mode, to
	 * get the colours right (even on 32-bit depth displays funnily enough. */
	do_config(FB_SPLASH_IO_ORIG_USER);
	cmd_setstate(1, FB_SPLASH_IO_ORIG_USER);

	/* copy the silent pic to base_image for safe keeping */
	if (!no_silent_image) {
		base_image_size = silent_img.width * silent_img.height * (silent_img.depth >> 3);
		base_image = malloc(base_image_size);
		if (!base_image) {
			printk("Couldn't get enough memory for framebuffer image.\n");
			return 1;
		}
		memcpy(base_image, (void*)silent_img.data, base_image_size);
	}