Blender V4.5
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
8
12
14#include "GHOST_Debug.hh"
15#include "GHOST_Window.hh"
16#include <algorithm>
17
19
20/* m_windows is freed by GHOST_System::disposeWindow */
22
24{
26 if (window) {
27 if (!getWindowFound(window)) {
28 /* Store the pointer to the window. */
29 m_windows.push_back(window);
30 success = GHOST_kSuccess;
31 }
32 }
33 return success;
34}
35
37{
39 if (window) {
40 std::vector<GHOST_IWindow *>::iterator result = find(
41 m_windows.begin(), m_windows.end(), window);
42 if (result != m_windows.end()) {
43 setWindowInactive(window);
44 m_windows.erase(result);
45 success = GHOST_kSuccess;
46 }
47 }
48 return success;
49}
50
52{
53 bool found = false;
54 if (window) {
55 std::vector<GHOST_IWindow *>::const_iterator result = find(
56 m_windows.begin(), m_windows.end(), window);
57 if (result != m_windows.end()) {
58 found = true;
59 }
60 }
61 return found;
62}
63
65{
67 if (window != m_activeWindow) {
68 if (getWindowFound(window)) {
69 m_activeWindow = window;
70 }
71 else {
72 success = GHOST_kFailure;
73 }
74 }
75 return success;
76}
77
82
84{
85 if (window == m_activeWindow) {
86 m_activeWindow = nullptr;
87 }
88}
89
90const std::vector<GHOST_IWindow *> &GHOST_WindowManager::getWindows() const
91{
92 return m_windows;
93}
94
96{
97 std::vector<GHOST_IWindow *>::iterator iter;
98
99 for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
100 if ((*iter)->getOSWindow() == osWindow) {
101 return *iter;
102 }
103 }
104 return nullptr;
105}
GHOST_TSuccess
Definition GHOST_Types.h:80
@ GHOST_kFailure
Definition GHOST_Types.h:80
@ GHOST_kSuccess
Definition GHOST_Types.h:80
GHOST_TSuccess addWindow(GHOST_IWindow *window)
GHOST_IWindow * getWindowAssociatedWithOSWindow(const void *osWindow)
std::vector< GHOST_IWindow * > m_windows
GHOST_TSuccess removeWindow(const GHOST_IWindow *window)
const std::vector< GHOST_IWindow * > & getWindows() const
GHOST_IWindow * getActiveWindow() const
GHOST_IWindow * m_activeWindow
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window)
bool getWindowFound(const GHOST_IWindow *window) const
void setWindowInactive(const GHOST_IWindow *window)