ui/ncurses: in lockdown ensure system reboot in ncurses menu exit
[petitboot] / ui / twin / pbt-scr.c
index 79f6792e346d33d1ff6c786fffd11a400aa9cd0e..c360047cb5879ca7bce16e4629f46da7031f0cad 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
-#define _GNU_SOURCE
+#endif
+
 #include <assert.h>
 
 #include <string.h>
@@ -136,7 +138,7 @@ twin_pixmap_t *pbt_background_load(twin_screen_t *tscreen,
        raw_background = twin_jpeg_to_pixmap(filename, TWIN_ARGB32);
 
        if (!raw_background) {
-               pb_log("%s: loading image '%s' failed\n", __func__, filename);
+               pb_log_fn("loading image '%s' failed\n", filename);
 
                /* Fallback to a default pattern */
 
@@ -156,7 +158,7 @@ twin_pixmap_t *pbt_background_load(twin_screen_t *tscreen,
                                tscreen->width,
                                tscreen->height);
        if (!scaled_background) {
-               pb_log("%s: scale '%s' failed\n", __func__, filename);
+               pb_log_fn("scale '%s' failed\n", filename);
                twin_pixmap_destroy(raw_background);
                return twin_make_pattern();
        }
@@ -222,7 +224,7 @@ retry:
        new.icon = twin_png_to_pixmap(filename, TWIN_ARGB32);
 
        if (!new.icon) {
-               pb_log("%s: loading image '%s' failed\n", __func__, filename);
+               pb_log_fn("loading image '%s' failed\n", filename);
 
                if (filename == default_icon_file)
                        return NULL;
@@ -382,7 +384,7 @@ struct pbt_scr *pbt_scr_init(void *talloc_ctx,
        assert(backend && backend < 3);
 
        if (!scr) {
-               pb_log("%s: alloc pbt_scr failed.\n", __func__);
+               pb_log_fn("alloc pbt_scr failed.\n");
                goto fail_alloc;
        }
 
@@ -393,18 +395,18 @@ struct pbt_scr *pbt_scr_init(void *talloc_ctx,
        scr->twin_ctx.backend = backend;
 
        if (backend == pbt_twin_x11) {
-               pb_log("%s: using twin x11 backend.\n", __func__);
+               pb_log_fn("using twin x11 backend.\n");
                assert(width > 100);
                assert(height > 100);
 
 #if !defined(HAVE_LIBTWIN_TWIN_X11_H)
                assert(0);
 #else
-               scr->twin_ctx.x11 = twin_x11_create_ext(XOpenDisplay(0), width,
-                       height, 0);
+               scr->twin_ctx.x11 = twin_x11_create_ext(XOpenDisplay(NULL),
+                       width, height, 0);
 
                if (!scr->twin_ctx.x11) {
-                       pb_log("%s: twin_x11_create_ext failed.\n", __func__);
+                       pb_log_fn("twin_x11_create_ext failed.\n");
                        perror("failed to create twin x11 context\n");
                        goto fail_ctx_create;
                }
@@ -416,14 +418,14 @@ struct pbt_scr *pbt_scr_init(void *talloc_ctx,
                waiter_fd = ConnectionNumber(scr->twin_ctx.x11->dpy);
 #endif
        } else if (backend == pbt_twin_fbdev) {
-               pb_log("%s: using twin fbdev backend.\n", __func__);
+               pb_log_fn("using twin fbdev backend.\n");
 #if !defined(HAVE_LIBTWIN_TWIN_FBDEV_H)
                assert(0);
 #else
                scr->twin_ctx.fbdev = twin_fbdev_create_ext(-1, SIGUSR1, 0);
 
                if (!scr->twin_ctx.fbdev) {
-                       pb_log("%s: twin_fbdev_create_ext failed.\n", __func__);
+                       pb_log_fn("twin_fbdev_create_ext failed.\n");
                        perror("failed to create twin fbdev context\n");
                        goto fail_ctx_create;
                }