Don't just segfault on failed compositor connections

This commit is contained in:
K. Lange 2018-08-01 09:21:13 +09:00
parent 30e2c8d940
commit eed3926793
6 changed files with 39 additions and 21 deletions

View File

@ -84,6 +84,10 @@ static void init_default(void) {
int main(int argc, char * argv[]) {
int req_center_x, req_center_y;
yctx = yutani_init();
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
return 1;
}
init_decorations();
window = yutani_window_create(yctx, width + decor_width(), height + decor_height());

View File

@ -54,6 +54,10 @@ int main (int argc, char ** argv) {
wallpaper->alpha = 0;
yctx = yutani_init();
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
return 1;
}
/* wallpaper */
wallpaper_window = yutani_window_create(yctx, yctx->display_width, yctx->display_height);

View File

@ -1,24 +1,21 @@
/* This file is part of ToaruOS and is released under the terms
/* vim: ts=4 sw=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2013-2018 K. Lange
*/
/*
* drawlines
*
* Test application to draw lines to a window.
* Yutani demo application that draws lines into a window.
*
*/
#include <stdlib.h>
#include <assert.h>
#include <syscall.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <toaru/yutani.h>
#include <toaru/graphics.h>
#define TRACE_APP_NAME "drawlines"
#include <toaru/trace.h>
static int left, top, width, height;
static yutani_t * yctx;
@ -45,16 +42,16 @@ int main (int argc, char ** argv) {
srand(time(NULL));
TRACE("Starting drawlines.");
yctx = yutani_init();
TRACE("Creating a window.");
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
return 1;
}
wina = yutani_window_create(yctx, width, height);
TRACE("Move.");
yutani_window_move(yctx, wina, left, top);
TRACE("Advertise icon.");
yutani_window_advertise_icon(yctx, wina, "drawlines", "drawlines");
TRACE("Init graphics.");
ctx = init_graphics_yutani(wina);
draw_fill(ctx, rgb(0,0,0));

View File

@ -1,8 +1,8 @@
/* This file is part of ToaruOS and is released under the terms
/* vim: ts=4 sw=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2013-2018 K. Lange
*/
/*
*
* Julia Fractal Generator
*
* This is the updated windowed version of the
@ -242,6 +242,10 @@ int main(int argc, char * argv[]) {
}
yctx = yutani_init();
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
return 1;
}
init_decorations();
window = yutani_window_create(yctx, width + decor_width(), height + decor_height());

View File

@ -1,11 +1,11 @@
/* This file is part of ToaruOS and is released under the terms
/* vim: ts=4 sw=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2013-2018 K. Lange
*/
/*
* test-gfx
*
* Windowed graphical test application.
* Plasma
*
* Draws animated plasma in a decorated window.
*/
#include <stdlib.h>
#include <assert.h>
@ -102,6 +102,10 @@ void resize_finish(int w, int h) {
int main (int argc, char ** argv) {
yctx = yutani_init();
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
return 1;
}
win_width = 300;
win_height = 300;

View File

@ -1925,6 +1925,11 @@ int main(int argc, char ** argv) {
/* Initialize the windowing library */
yctx = yutani_init();
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
return 1;
}
if (_fullscreen) {
window_width = yctx->display_width;
window_height = yctx->display_height;