diff options
-rw-r--r-- | fbi.c | 4 | ||||
-rw-r--r-- | fbiconfig.c | 6 | ||||
-rw-r--r-- | fbiconfig.h | 2 | ||||
-rw-r--r-- | fbpdf.c | 4 | ||||
-rw-r--r-- | fbtools.c | 6 | ||||
-rw-r--r-- | fbtools.h | 2 | ||||
-rw-r--r-- | vt.c | 44 | ||||
-rw-r--r-- | vt.h | 2 |
8 files changed, 16 insertions, 54 deletions
@@ -1420,14 +1420,14 @@ int main(int argc, char *argv[]) gfx = drm_init(device, output, mode, false); } else { framebuffer = true; - gfx = fb_init(device, mode, GET_VT()); + gfx = fb_init(device, mode); } } else { /* try drm first, failing that fb */ gfx = drm_init(NULL, output, mode, false); if (!gfx) { framebuffer = true; - gfx = fb_init(NULL, mode, GET_VT()); + gfx = fb_init(NULL, mode); } } if (!gfx) { diff --git a/fbiconfig.c b/fbiconfig.c index 48c0fca..a986c3b 100644 --- a/fbiconfig.c +++ b/fbiconfig.c @@ -130,12 +130,6 @@ struct cfg_cmdline fbi_cfg[] = { .needsarg = 1, .desc = "image blend time in miliseconds", },{ - .letter = 'T', - .cmdline = "vt", - .option = { O_VT }, - .needsarg = 1, - .desc = "start on virtual console <arg>", - },{ .letter = 's', .cmdline = "scroll", .option = { O_SCROLL }, diff --git a/fbiconfig.h b/fbiconfig.h index 3fdc2f0..67003b2 100644 --- a/fbiconfig.h +++ b/fbiconfig.h @@ -26,7 +26,6 @@ #define O_CACHE_MEM O_OPTIONS, "cache-mem" #define O_BLEND_MSECS O_OPTIONS, "blend-msecs" -#define O_VT O_OPTIONS, "vt" #define O_SCROLL O_OPTIONS, "scroll" #define O_TIMEOUT O_OPTIONS, "timeout" #define O_PCD_RES O_OPTIONS, "photocd-res" @@ -61,7 +60,6 @@ #define GET_CACHE_MEM() cfg_get_int(O_CACHE_MEM, 256) #define GET_BLEND_MSECS() cfg_get_int(O_BLEND_MSECS, 0) -#define GET_VT() cfg_get_int(O_VT, 0) #define GET_SCROLL() cfg_get_int(O_SCROLL, 50) #define GET_TIMEOUT() cfg_get_int(O_TIMEOUT, 0) #define GET_PCD_RES() cfg_get_int(O_PCD_RES, 3) @@ -303,14 +303,14 @@ int main(int argc, char *argv[]) gfx = drm_init(device, output, mode, pageflip); } else { framebuffer = true; - gfx = fb_init(device, mode, GET_VT()); + gfx = fb_init(device, mode); } } else { /* try drm first, failing that fb */ gfx = drm_init(NULL, output, mode, pageflip); if (!gfx) { framebuffer = true; - gfx = fb_init(NULL, mode, GET_VT()); + gfx = fb_init(NULL, mode); } } if (!gfx) { @@ -215,21 +215,17 @@ static void fb_cleanup_display(void) } close(fb); - console_restore_vt(); tcsetattr(STDIN_FILENO, TCSANOW, &term); } /* -------------------------------------------------------------------- */ -gfxstate* fb_init(const char *device, char *mode, int vt) +gfxstate* fb_init(const char *device, char *mode) { unsigned long page_mask; struct stat st; gfxstate *gfx; - if (vt != 0) - console_set_vt(vt); - if (NULL == device) { device = getenv("FRAMEBUFFER"); if (NULL == device) { @@ -1,3 +1,3 @@ #include "gfx.h" -gfxstate *fb_init(const char *device, char *mode, int vt); +gfxstate *fb_init(const char *device, char *mode); @@ -31,7 +31,7 @@ static bool console_switching_active; static int kd_mode; static struct vt_mode vt_mode; static struct vt_mode vt_omode; -static int orig_vt_no = 0; +static int orig_vt_no = -1; static void (*console_redraw)(void); static void console_switch_signal(int signal) @@ -148,43 +148,16 @@ int check_console_switch(void) return 1; } -void console_set_vt(int vtno) +int console_aquire_vt(void) { struct vt_stat vts; - char vtname[12]; + int vtno = -1; - if (vtno < 0) { - if (-1 == ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) || vtno == -1) { - perror("ioctl VT_OPENQRY"); - exit(1); - } - } - - vtno &= 0xff; - sprintf(vtname, "/dev/tty%d", vtno); - chown(vtname, getuid(), getgid()); - if (-1 == access(vtname, R_OK | W_OK)) { - fprintf(stderr,"access %s: %s\n",vtname,strerror(errno)); - exit(1); - } - - /* switch controlling tty */ - switch (fork()) { - case 0: - break; - case -1: - perror("fork"); - exit(1); - default: - exit(0); + if (-1 == ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) || vtno == -1) { + perror("ioctl VT_OPENQRY"); + return -1; } - close(0); - close(1); - close(2); - setsid(); - open(vtname,O_RDWR); - dup(0); - dup(0); + fprintf(stderr, "using vt %d\n", vtno); if (-1 == ioctl(STDIN_FILENO,VT_GETSTATE, &vts)) { perror("ioctl VT_GETSTATE"); @@ -199,11 +172,12 @@ void console_set_vt(int vtno) perror("ioctl VT_WAITACTIVE"); exit(1); } + return 0; } void console_restore_vt(void) { - if (!orig_vt_no) + if (orig_vt_no < 0) return; if (ioctl(STDIN_FILENO, VT_ACTIVATE, orig_vt_no) < 0) @@ -4,6 +4,6 @@ int console_switch_init(void (*redraw)(void)); void console_switch_cleanup(void); int check_console_switch(void); -void console_set_vt(int vtno); +int console_aquire_vt(void); void console_restore_vt(void); int console_activate_current(void); |