aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-01-31 12:43:39 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-01-31 12:43:39 +0100
commit920879c30814c1460ef6d0ea4004bcbfaf8efd9f (patch)
treee09618f89758756936a8ad3d5724f7625e81ff1a
parent976759719b02bd7b34e9b43d202ea6fd0e24dcde (diff)
downloadfbida-920879c30814c1460ef6d0ea4004bcbfaf8efd9f.tar.gz
fbdev support, console switching
-rw-r--r--fbcon.c37
-rw-r--r--fbtools.c2
-rw-r--r--meson.build2
3 files changed, 32 insertions, 9 deletions
diff --git a/fbcon.c b/fbcon.c
index 8c738b3..071fcbd 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -29,6 +29,7 @@
#include "fbtools.h"
#include "drmtools.h"
+#include "vt.h"
#include "tmt.h"
/* ---------------------------------------------------------------------- */
@@ -45,7 +46,7 @@ static cairo_t *context2;
cairo_font_extents_t extents;
static TMT *vt;
-static int dirty, pty;
+static int clear, dirty, pty;
static struct udev *udev;
static struct libinput *kbd;
@@ -60,6 +61,8 @@ static struct xkb_rule_names layout = {
.options = NULL,
};
+int debug = 0;
+
/* ---------------------------------------------------------------------- */
static jmp_buf fb_fatal_cleanup;
@@ -93,6 +96,7 @@ static void exit_signals_init(void)
/* cleanup */
gfx->cleanup_display();
+ console_switch_cleanup();
fprintf(stderr,"Oops: %s\n",strsignal(termsig));
exit(42);
}
@@ -100,9 +104,23 @@ static void exit_signals_init(void)
static void cleanup_and_exit(int code)
{
gfx->cleanup_display();
+ console_switch_cleanup();
exit(code);
}
+static void console_switch_suspend(void)
+{
+ libinput_suspend(kbd);
+}
+
+static void console_switch_resume(void)
+{
+ gfx->restore_display();
+ libinput_resume(kbd);
+ clear++;
+ dirty++;
+}
+
/* ---------------------------------------------------------------------- */
static int open_restricted(const char *path, int flags, void *user_data)
@@ -256,10 +274,10 @@ static void render(void)
tx = (gfx->hdisplay - (extents.max_x_advance * s->ncol)) / 2;
ty = (gfx->vdisplay - (extents.height * s->nline)) / 2;
-#if 0
- cairo_set_source_rgb(context, 0, 0, 0);
- cairo_paint(context);
-#endif
+ if (clear) {
+ cairo_set_source_rgb(context, 0, 0, 0);
+ cairo_paint(context);
+ }
for (line = 0; line < s->nline; line++) {
for (col = 0; col < s->ncol; col++) {
@@ -356,17 +374,19 @@ int main(int argc, char *argv[])
if (!gfx)
fprintf(stderr, "%s: init failed\n", drm_node);
}
-#if 0
if (!gfx && fb_node) {
- gfx = fb_init(fb_node, NULL, 0);
+ gfx = fb_init(fb_node, NULL);
if (!gfx)
fprintf(stderr, "%s: init failed\n", fb_node);
}
-#endif
if (!gfx)
exit(1);
exit_signals_init();
signal(SIGTSTP,SIG_IGN);
+ if (console_switch_init(console_switch_suspend,
+ console_switch_resume) < 0) {
+ fprintf(stderr, "NOTICE: No vt switching available on terminal.\n");
+ }
/* init cairo */
surface1 = cairo_image_surface_create_for_data(gfx->mem,
@@ -434,6 +454,7 @@ int main(int argc, char *argv[])
}
/* parent */
+ clear++;
dirty++;
for (;;) {
fd_set set;
diff --git a/fbtools.c b/fbtools.c
index ec66b67..e7dc30a 100644
--- a/fbtools.c
+++ b/fbtools.c
@@ -285,7 +285,9 @@ gfxstate* fb_init(const char *device, char *mode)
goto err;
}
}
+#if 0
console_activate_current();
+#endif
/* cls */
fb_memset(fb_mem+fb_mem_offset, 0, fb_fix.line_length * fb_var.yres);
diff --git a/meson.build b/meson.build
index 0586ec2..f287b77 100644
--- a/meson.build
+++ b/meson.build
@@ -130,7 +130,7 @@ executable('fbpdf',
install : true)
# build fbcon
-fbcon_srcs = [ 'fbcon.c', 'drmtools.c', 'tmt.c' ]
+fbcon_srcs = [ 'fbcon.c', 'drmtools.c', 'fbtools.c', 'vt.c', 'tmt.c' ]
fbcon_deps = [ drm_dep, cairo_dep, util_dep, udev_dep, input_dep, xkb_dep ]
executable('fbcon',