Compare commits

...

2 Commits

Author SHA1 Message Date
Juhani Krekelä dea1e15e75 Gracefully handle errors in initialization 2021-11-28 02:00:46 +02:00
Juhani Krekelä 25a52b7327 Handle -mode 2021-11-28 02:00:34 +02:00
1 changed files with 11 additions and 11 deletions

View File

@ -10,7 +10,6 @@
#include <sys/keycodes.h> #include <sys/keycodes.h>
#include <err.h> //debg
#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>
@ -127,17 +126,21 @@ static void sortix_process_events(void *data)
static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *display) static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *display)
{ {
if (param && *param) if (param) {
errx(1, "param %s", param); if (sscanf(param, "%ix%i", &default_window_width, &default_window_height) != 2)
if (display && *display) return stracpy("-mode syntax is WIDTHxHEIGHT\n");
errx(1, "display %s", display); }
(void) display; // Only used by the X11 driver
connection = display_connect_default(); connection = display_connect_default();
if (!connection && errno == ECONNREFUSED) if (!connection && errno == ECONNREFUSED)
return "TODO: display_spawn"; display_spawn(g_argc, g_argv);
if (!connection) if (!connection) {
return "TODO: Proper error reporting"; char err[256];
snprintf(err, sizeof(err), "Error connecting to display: %s\n", strerror(errno));
return stracpy(err);
}
sortix_driver.get_color = get_color_fn(sortix_driver.depth); sortix_driver.get_color = get_color_fn(sortix_driver.depth);
@ -152,9 +155,6 @@ static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *di
static struct graphics_device *sortix_init_device(void) static struct graphics_device *sortix_init_device(void)
{ {
if (current_dev)
errx(1, "Attempting to create second window");
struct graphics_device *dev = mem_calloc(sizeof(struct graphics_device)); struct graphics_device *dev = mem_calloc(sizeof(struct graphics_device));
dev->size.x1 = 0; dev->size.x1 = 0;