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
This commit is contained in:
Harley Acheson 2021-02-09 16:14:31 -08:00
parent 5bddfde217
commit 1c4ae8a11c
Notes: blender-bot 2023-02-14 01:52:41 +01:00
Referenced by issue #85562, No keyboard input after enable "Emulate 3 button mouse"
Referenced by issue #85526, Regression: SCREEN_OT_area_dupli from ActionZone Not Working Correctly
7 changed files with 44 additions and 110 deletions

View File

@ -25,6 +25,8 @@
#include "GHOST_Types.h"
#include <stdbool.h>
#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.

View File

@ -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);
}

View File

@ -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 */

View File

@ -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) {

View File

@ -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);

View File

@ -1097,6 +1097,7 @@ static void playanim_window_open(const char *title, int posx, int posy, int size
posy = (scr_h - posy - sizey);
g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system,
NULL,
title,
posx,
posy,
@ -1104,6 +1105,7 @@ static void playanim_window_open(const char *title, int posx, int posy, int size
sizey,
/* could optionally start fullscreen */
GHOST_kWindowStateNormal,
false,
GHOST_kDrawingContextTypeOpenGL,
glsettings);
}

View File

@ -560,14 +560,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wmWindow *win,
bool is_dialog)
{
/* On Windows, if there is a parent window then force is_dialog. Otherwise the parent
handle is not used in window creation and they do not stay on top of parents. */
#ifdef WIN32
if (win->parent) {
is_dialog = true;
}
#endif
/* a new window is created when pageflip mode is required for a window */
GHOST_GLSettings glSettings = {0};
if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
@ -586,30 +578,17 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wmWindow *prev_windrawable = wm->windrawable;
wm_window_clear_drawable(wm);
GHOST_WindowHandle ghostwin;
if (is_dialog && win->parent) {
ghostwin = GHOST_CreateDialogWindow(g_system,
win->parent->ghostwin,
title,
win->posx,
posy,
win->sizex,
win->sizey,
(GHOST_TWindowState)win->windowstate,
GHOST_kDrawingContextTypeOpenGL,
glSettings);
}
else {
ghostwin = GHOST_CreateWindow(g_system,
title,
win->posx,
posy,
win->sizex,
win->sizey,
(GHOST_TWindowState)win->windowstate,
GHOST_kDrawingContextTypeOpenGL,
glSettings);
}
GHOST_WindowHandle ghostwin = GHOST_CreateWindow(g_system,
(win->parent) ? win->parent->ghostwin : NULL,
title,
win->posx,
posy,
win->sizex,
win->sizey,
(GHOST_TWindowState)win->windowstate,
is_dialog,
GHOST_kDrawingContextTypeOpenGL,
glSettings);
if (ghostwin) {
win->gpuctx = GPU_context_create(ghostwin);