Blender V4.3
GHOST_WindowManager.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14#include "GHOST_Debug.hh"
15#include "GHOST_Window.hh"
16#include <algorithm>
17
19 : m_fullScreenWindow(nullptr), m_activeWindow(nullptr), m_activeWindowBeforeFullScreen(nullptr)
20{
21}
22
24{
25 /* m_windows is freed by GHOST_System::disposeWindow */
26}
27
29{
31 if (window) {
32 if (!getWindowFound(window)) {
33 /* Store the pointer to the window. */
34 m_windows.push_back(window);
35 success = GHOST_kSuccess;
36 }
37 }
38 return success;
39}
40
42{
44 if (window) {
45 if (window == m_fullScreenWindow) {
47 }
48 else {
49 std::vector<GHOST_IWindow *>::iterator result = find(
50 m_windows.begin(), m_windows.end(), window);
51 if (result != m_windows.end()) {
52 setWindowInactive(window);
53 m_windows.erase(result);
54 success = GHOST_kSuccess;
55 }
56 }
57 }
58 return success;
59}
60
62{
63 bool found = false;
64 if (window) {
65 if (getFullScreen() && (window == m_fullScreenWindow)) {
66 found = true;
67 }
68 else {
69 std::vector<GHOST_IWindow *>::const_iterator result = find(
70 m_windows.begin(), m_windows.end(), window);
71 if (result != m_windows.end()) {
72 found = true;
73 }
74 }
75 }
76 return found;
77}
78
80{
81 return m_fullScreenWindow != nullptr;
82}
83
88
90{
92 GHOST_ASSERT(window, "GHOST_WindowManager::beginFullScreen(): invalid window");
93 GHOST_ASSERT(window->getValid(), "GHOST_WindowManager::beginFullScreen(): invalid window");
94 if (!getFullScreen()) {
95 m_fullScreenWindow = window;
99 success = GHOST_kSuccess;
100 }
101 return success;
102}
103
105{
107 if (getFullScreen()) {
108 if (m_fullScreenWindow != nullptr) {
109 // GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n");
112 delete m_fullScreenWindow;
113 // GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n");
114 m_fullScreenWindow = nullptr;
117 }
118 }
119 success = GHOST_kSuccess;
120 }
121 return success;
122}
123
125{
127 if (window != m_activeWindow) {
128 if (getWindowFound(window)) {
129 m_activeWindow = window;
130 }
131 else {
132 success = GHOST_kFailure;
133 }
134 }
135 return success;
136}
137
142
144{
145 if (window == m_activeWindow) {
146 m_activeWindow = nullptr;
147 }
148}
149
150const std::vector<GHOST_IWindow *> &GHOST_WindowManager::getWindows() const
151{
152 return m_windows;
153}
154
156{
157 std::vector<GHOST_IWindow *>::iterator iter;
158
159 for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
160 if ((*iter)->getOSWindow() == osWindow) {
161 return *iter;
162 }
163 }
164 return nullptr;
165}
#define GHOST_ASSERT(x, info)
GHOST_TSuccess
Definition GHOST_Types.h:87
@ GHOST_kFailure
Definition GHOST_Types.h:87
@ GHOST_kSuccess
Definition GHOST_Types.h:87
virtual GHOST_TSuccess beginFullScreen() const =0
virtual bool getValid() const =0
virtual GHOST_TSuccess endFullScreen() const =0
GHOST_TSuccess addWindow(GHOST_IWindow *window)
GHOST_TSuccess endFullScreen()
GHOST_IWindow * getWindowAssociatedWithOSWindow(const void *osWindow)
std::vector< GHOST_IWindow * > m_windows
GHOST_TSuccess removeWindow(const GHOST_IWindow *window)
GHOST_IWindow * m_activeWindowBeforeFullScreen
const std::vector< GHOST_IWindow * > & getWindows() const
GHOST_IWindow * getActiveWindow() const
GHOST_IWindow * m_activeWindow
GHOST_TSuccess beginFullScreen(GHOST_IWindow *window, const bool stereoVisual)
GHOST_IWindow * getFullScreenWindow() const
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window)
GHOST_IWindow * m_fullScreenWindow
bool getWindowFound(const GHOST_IWindow *window) const
void setWindowInactive(const GHOST_IWindow *window)