diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-23 16:28:10 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-23 16:28:10 +0100 |
commit | 5e7572dd3b05e5c5e76ab185dd77367f8ae738e5 (patch) | |
tree | f6277283a55ee6c5073fe26c800c9e410a56fcf8 | |
parent | a80c7e0c5a22c303bc24c97f01f61466eb94b03e (diff) | |
download | fbida-5e7572dd3b05e5c5e76ab185dd77367f8ae738e5.tar.gz |
gfx: move over cleanup function
-rw-r--r-- | fbi.c | 2 | ||||
-rw-r--r-- | fbtools.c | 60 | ||||
-rw-r--r-- | fbtools.h | 1 | ||||
-rw-r--r-- | gfx.h | 1 |
4 files changed, 33 insertions, 31 deletions
@@ -1403,7 +1403,7 @@ static void cleanup_and_exit(int code) shadow_fini(); fb_clear_screen(gfx); tty_restore(); - fb_cleanup(); + gfx->cleanup_display(); flist_print_tagged(stdout); exit(code); } @@ -389,6 +389,34 @@ static void fb_restore_display(void) fb_set_palette(); } +static void fb_cleanup_display(void) +{ + /* restore console */ + if (-1 == ioctl(tty,KDSETMODE, kd_mode)) + perror("ioctl KDSETMODE"); + if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar)) + perror("ioctl FBIOPUT_VSCREENINFO"); + if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix)) + perror("ioctl FBIOGET_FSCREENINFO"); + if (fb_ovar.bits_per_pixel == 8 || + fb_fix.visual == FB_VISUAL_DIRECTCOLOR) { + if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap)) + perror("ioctl FBIOPUTCMAP"); + } + close(fb); + + if (-1 == ioctl(tty,VT_SETMODE, &vt_omode)) + perror("ioctl VT_SETMODE"); + if (orig_vt_no && -1 == ioctl(tty, VT_ACTIVATE, orig_vt_no)) + perror("ioctl VT_ACTIVATE"); + if (orig_vt_no && -1 == ioctl(tty, VT_WAITACTIVE, orig_vt_no)) + perror("ioctl VT_WAITACTIVE"); + tcsetattr(tty, TCSANOW, &term); + close(tty); +} + +/* -------------------------------------------------------------------- */ + gfxstate* fb_init(char *device, char *mode, int vt) { char fbdev[16]; @@ -537,42 +565,16 @@ gfxstate* fb_init(char *device, char *mode, int vt) gfx->bits_per_pixel = fb_var.bits_per_pixel; gfx->restore_display = fb_restore_display; + gfx->cleanup_display = fb_cleanup_display; gfx->fb_fd = fb; return gfx; err: - fb_cleanup(); + fb_cleanup_display(); exit(1); } -void -fb_cleanup(void) -{ - /* restore console */ - if (-1 == ioctl(tty,KDSETMODE, kd_mode)) - perror("ioctl KDSETMODE"); - if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar)) - perror("ioctl FBIOPUT_VSCREENINFO"); - if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix)) - perror("ioctl FBIOGET_FSCREENINFO"); - if (fb_ovar.bits_per_pixel == 8 || - fb_fix.visual == FB_VISUAL_DIRECTCOLOR) { - if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap)) - perror("ioctl FBIOPUTCMAP"); - } - close(fb); - - if (-1 == ioctl(tty,VT_SETMODE, &vt_omode)) - perror("ioctl VT_SETMODE"); - if (orig_vt_no && -1 == ioctl(tty, VT_ACTIVATE, orig_vt_no)) - perror("ioctl VT_ACTIVATE"); - if (orig_vt_no && -1 == ioctl(tty, VT_WAITACTIVE, orig_vt_no)) - perror("ioctl VT_WAITACTIVE"); - tcsetattr(tty, TCSANOW, &term); - close(tty); -} - /* -------------------------------------------------------------------- */ /* handle fatal errors */ @@ -608,7 +610,7 @@ fb_catch_exit_signals(void) return; /* cleanup */ - fb_cleanup(); + fb_cleanup_display(); fprintf(stderr,"Oops: %s\n",strsignal(termsig)); exit(42); } @@ -10,7 +10,6 @@ extern int fb_switch_state; /* init + cleanup */ gfxstate *fb_init(char *device, char *mode, int vt); -void fb_cleanup(void); void fb_catch_exit_signals(void); void fb_memset(void *addr, int c, size_t len); @@ -15,6 +15,7 @@ struct gfxstate { /* calls */ void (*restore_display)(void); + void (*cleanup_display)(void); /* FIXME: legacy */ int fb_fd; |