From 1d023c49e29cd38740a288bb224878d5d77996ca Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 3 Jul 2018 14:49:12 +0200 Subject: [PATCH] X11: open window on its previous position Signed-off-by: Thomas Bernard --- src/input.c | 9 +++++++++ src/main.c | 2 +- src/x11screen.c | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 451c2e9b..2d3fac3d 100644 --- a/src/input.c +++ b/src/input.c @@ -1368,8 +1368,17 @@ int Get_input(int sleep_time) case ConfigureNotify: if (event.xconfigure.above == 0) { + int x_pos, y_pos; + unsigned int width, height, border_width, depth; + Window root_window; + Resize_width = event.xconfigure.width; Resize_height = event.xconfigure.height; + if (XGetGeometry(X11_display, X11_window, &root_window, &x_pos, &y_pos, &width, &height, &border_width, &depth)) + { + Config.Window_pos_x = event.xconfigure.x - x_pos; + Config.Window_pos_y = event.xconfigure.y - y_pos; + } } break; case ClientMessage: diff --git a/src/main.c b/src/main.c index d89a0cad..fc408df4 100644 --- a/src/main.c +++ b/src/main.c @@ -1092,7 +1092,7 @@ void Program_shutdown(void) } #endif // Config.Window_pos_x / Config.Window_pos_y are set in win32screen.c - #else + #elif !defined(USE_X11) // All other targets: irrelevant dimensions. // Do not attempt to force them back on next program run. Config.Window_pos_x = 9999; diff --git a/src/x11screen.c b/src/x11screen.c index fdc957cb..9039fa86 100644 --- a/src/x11screen.c +++ b/src/x11screen.c @@ -46,6 +46,7 @@ void GFX2_Set_mode(int *width, int *height, int fullscreen) unsigned long white, black; char * winName[] = { "GrafX2" }; Visual * visual; + (void)fullscreen; if (X11_display == NULL) X11_display = XOpenDisplay(NULL);// NULL is equivalent to getenv("DISPLAY") @@ -152,6 +153,8 @@ void GFX2_Set_mode(int *width, int *height, int fullscreen) XSetWMProtocols(X11_display, X11_window, &wmDelete, 1); XMapWindow(X11_display, X11_window); + if (Config.Window_pos_x != 9999 && Config.Window_pos_y != 9999) + XMoveWindow(X11_display, X11_window, Config.Window_pos_x, Config.Window_pos_y); } if (screen == NULL)