From 1c4ae8a11c820e33da725816d7cccb2668680e51 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 9 Feb 2021 16:14:31 -0800 Subject: UI: Removal of GHOST_CreateDialogWindow Simplification of window creation code to allow greater flexibility. Differential Revision: https://developer.blender.org/D10311 Reviewed by Brecht Van Lommel --- intern/ghost/GHOST_C-api.h | 17 ++++----- intern/ghost/intern/GHOST_C-api.cpp | 21 ++---------- intern/ghost/intern/GHOST_WindowX11.cpp | 61 +++++++-------------------------- intern/ghost/test/gears/GHOST_C-Test.c | 4 +++ intern/ghost/test/multitest/MultiTest.c | 6 ++++ 5 files changed, 31 insertions(+), 78 deletions(-) (limited to 'intern/ghost') diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 2bc73f7eb22..d79111b742f 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -25,6 +25,8 @@ #include "GHOST_Types.h" +#include + #ifdef __cplusplus extern "C" { #endif @@ -160,6 +162,7 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle, * The new window is added to the list of windows managed. * Never explicitly delete the window, use disposeWindow() instead. * \param systemhandle: The handle to the system. + * \param parentWindow: Handle of parent (or owner) window, or NULL * \param title: The name of the window. * (displayed in the title bar of the window if the OS supports it). * \param left: The coordinate of the left edge of the window. @@ -167,31 +170,23 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle, * \param width: The width the window. * \param height: The height the window. * \param state: The state of the window when opened. + * \param is_dialog: Stay on top of parent window, no icon in taskbar, can't be minimized. * \param type: The type of drawing context installed in this window. * \param glSettings: Misc OpenGL options. * \return A handle to the new window ( == NULL if creation failed). */ extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, + GHOST_WindowHandle parent_windowhandle, const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, + bool is_dialog, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings); -extern GHOST_WindowHandle GHOST_CreateDialogWindow(GHOST_SystemHandle systemhandle, - GHOST_WindowHandle parent_windowhandle, - const char *title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - GHOST_GLSettings glSettings); - /** * Create a new offscreen context. * Never explicitly delete the context, use disposeContext() instead. diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index e4bb908fec8..af65e1cd4d2 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -153,34 +153,19 @@ GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle, } GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, + GHOST_WindowHandle parent_windowhandle, const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, + bool is_dialog, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings) { GHOST_ISystem *system = (GHOST_ISystem *)systemhandle; - return (GHOST_WindowHandle)system->createWindow( - title, left, top, width, height, state, type, glSettings, false, false); -} - -GHOST_WindowHandle GHOST_CreateDialogWindow(GHOST_SystemHandle systemhandle, - GHOST_WindowHandle parent_windowhandle, - const char *title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - GHOST_GLSettings glSettings) -{ - GHOST_ISystem *system = (GHOST_ISystem *)systemhandle; - return (GHOST_WindowHandle)system->createWindow(title, left, top, @@ -190,7 +175,7 @@ GHOST_WindowHandle GHOST_CreateDialogWindow(GHOST_SystemHandle systemhandle, type, glSettings, false, - true, + is_dialog, (GHOST_IWindow *)parent_windowhandle); } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 86a7246a284..fc006c62803 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -293,55 +293,18 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system, m_display, RootWindow(m_display, m_visualInfo->screen), m_visualInfo->visual, AllocNone); /* create the window! */ - if ((parentWindow == 0) || is_dialog) { - m_window = XCreateWindow(m_display, - RootWindow(m_display, m_visualInfo->screen), - left, - top, - width, - height, - 0, /* no border. */ - m_visualInfo->depth, - InputOutput, - m_visualInfo->visual, - xattributes_valuemask, - &xattributes); - } - else { - Window root_return; - int x_return, y_return; - unsigned int w_return, h_return, border_w_return, depth_return; - - XGetGeometry(m_display, - parentWindow->m_window, - &root_return, - &x_return, - &y_return, - &w_return, - &h_return, - &border_w_return, - &depth_return); - - left = 0; - top = 0; - width = w_return; - height = h_return; - - m_window = XCreateWindow(m_display, - parentWindow->m_window, /* reparent against embedder */ - left, - top, - width, - height, - 0, /* no border. */ - m_visualInfo->depth, - InputOutput, - m_visualInfo->visual, - xattributes_valuemask, - &xattributes); - - XSelectInput(m_display, parentWindow->m_window, SubstructureNotifyMask); - } + m_window = XCreateWindow(m_display, + RootWindow(m_display, m_visualInfo->screen), + left, + top, + width, + height, + 0, /* no border. */ + m_visualInfo->depth, + InputOutput, + m_visualInfo->visual, + xattributes_valuemask, + &xattributes); #ifdef WITH_XDND /* initialize drop target for newly created window */ diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c index 3419f70dfcf..4283f990cfb 100644 --- a/intern/ghost/test/gears/GHOST_C-Test.c +++ b/intern/ghost/test/gears/GHOST_C-Test.c @@ -440,12 +440,14 @@ int main(int argc, char **argv) if (shSystem) { /* Create the main window */ sMainWindow = GHOST_CreateWindow(shSystem, + NULL, title1, 10, 64, 320, 200, GHOST_kWindowStateNormal, + false, GHOST_kDrawingContextTypeOpenGL, glSettings); if (!sMainWindow) { @@ -455,12 +457,14 @@ int main(int argc, char **argv) /* Create a secondary window */ sSecondaryWindow = GHOST_CreateWindow(shSystem, + NULL, title2, 340, 64, 320, 200, GHOST_kWindowStateNormal, + false, GHOST_kDrawingContextTypeOpenGL, glSettings); if (!sSecondaryWindow) { diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c index b6b83f2a47d..8c8858fc6d8 100644 --- a/intern/ghost/test/multitest/MultiTest.c +++ b/intern/ghost/test/multitest/MultiTest.c @@ -318,12 +318,14 @@ MainWindow *mainwindow_new(MultiTestApp *app) GHOST_GLSettings glSettings = {0}; win = GHOST_CreateWindow(sys, + NULL, "MultiTest:Main", 40, 40, 400, 400, GHOST_kWindowStateNormal, + false, GHOST_kDrawingContextTypeOpenGL, glSettings); @@ -573,12 +575,14 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app) GHOST_GetMainDisplayDimensions(sys, &screensize[0], &screensize[1]); win = GHOST_CreateWindow(sys, + NULL, "MultiTest:Logger", 40, screensize[1] - 432, 800, 300, GHOST_kWindowStateNormal, + false, GHOST_kDrawingContextTypeOpenGL, glSettings); @@ -773,12 +777,14 @@ ExtraWindow *extrawindow_new(MultiTestApp *app) GHOST_WindowHandle win; win = GHOST_CreateWindow(sys, + NULL, "MultiTest:Extra", 500, 40, 400, 400, GHOST_kWindowStateNormal, + false, GHOST_kDrawingContextTypeOpenGL, glSettings); -- cgit v1.2.3