diff --git a/arch/sim/src/sim/posix/sim_x11framebuffer.c b/arch/sim/src/sim/posix/sim_x11framebuffer.c index dd63e10d0bf..a5d98e91c4a 100644 --- a/arch/sim/src/sim/posix/sim_x11framebuffer.c +++ b/arch/sim/src/sim/posix/sim_x11framebuffer.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -106,8 +107,6 @@ static inline Display *sim_x11createframe(void) XSetWMProperties(display, g_window, &winprop, &iconprop, argv, 1, &hints, NULL, NULL); - XMapWindow(display, g_window); - /* Select window input events */ #if defined(CONFIG_SIM_AJOYSTICK) @@ -372,7 +371,7 @@ int sim_x11initialize(unsigned short width, unsigned short height, display = sim_x11createframe(); if (display == NULL) { - return -1; + return -ENODEV; } /* Determine the supported pixel bpp of the current window */ @@ -403,6 +402,40 @@ int sim_x11initialize(unsigned short width, unsigned short height, return 0; } +/**************************************************************************** + * Name: sim_x11openwindow + ****************************************************************************/ + +int sim_x11openwindow(void) +{ + if (g_display == NULL) + { + return -ENODEV; + } + + XMapWindow(g_display, g_window); + XSync(g_display, 0); + + return 0; +} + +/**************************************************************************** + * Name: sim_x11closewindow + ****************************************************************************/ + +int sim_x11closewindow(void) +{ + if (g_display == NULL) + { + return -ENODEV; + } + + XUnmapWindow(g_display, g_window); + XSync(g_display, 0); + + return 0; +} + /**************************************************************************** * Name: sim_x11cmap ****************************************************************************/ @@ -416,7 +449,7 @@ int sim_x11cmap(unsigned short first, unsigned short len, if (g_display == NULL) { - return -1; + return -ENODEV; } /* Convert each color to X11 scaling */ @@ -455,7 +488,7 @@ int sim_x11update(void) { if (g_display == NULL) { - return -1; + return -ENODEV; } #ifndef CONFIG_SIM_X11NOSHM diff --git a/arch/sim/src/sim/sim_framebuffer.c b/arch/sim/src/sim/sim_framebuffer.c index b0609acc4e4..66c2784164b 100644 --- a/arch/sim/src/sim/sim_framebuffer.c +++ b/arch/sim/src/sim/sim_framebuffer.c @@ -95,6 +95,11 @@ static int sim_setcursor(struct fb_vtable_s *vtable, struct fb_setcursor_s *settings); #endif +/* Open/close window. */ + +static int sim_openwindow(struct fb_vtable_s *vtable); +static int sim_closewindow(struct fb_vtable_s *vtable); + /**************************************************************************** * Private Data ****************************************************************************/ @@ -160,12 +165,47 @@ static struct fb_vtable_s g_fbobject = .getcursor = sim_getcursor, .setcursor = sim_setcursor, #endif + + .open = sim_openwindow, + .close = sim_closewindow, }; /**************************************************************************** * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: sim_openwindow + ****************************************************************************/ + +static int sim_openwindow(struct fb_vtable_s *vtable) +{ + int ret = OK; + ginfo("vtable=%p\n", vtable); + +#ifdef CONFIG_SIM_X11FB + ret = sim_x11openwindow(); +#endif + + return ret; +} + +/**************************************************************************** + * Name: sim_closewindow + ****************************************************************************/ + +static int sim_closewindow(struct fb_vtable_s *vtable) +{ + int ret = OK; + ginfo("vtable=%p\n", vtable); + +#ifdef CONFIG_SIM_X11FB + ret = sim_x11closewindow(); +#endif + + return ret; +} + /**************************************************************************** * Name: sim_getvideoinfo ****************************************************************************/ diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h index 67432a026a8..b858e568d65 100644 --- a/arch/sim/src/sim/sim_internal.h +++ b/arch/sim/src/sim/sim_internal.h @@ -242,6 +242,8 @@ int sim_x11initialize(unsigned short width, unsigned short height, void **fbmem, size_t *fblen, unsigned char *bpp, unsigned short *stride); int sim_x11update(void); +int sim_x11openwindow(void); +int sim_x11closewindow(void); #ifdef CONFIG_FB_CMAP int sim_x11cmap(unsigned short first, unsigned short len, unsigned char *red, unsigned char *green,