Blender V5.0
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/* windows_ is freed by GHOST_System::disposeWindow */
22
24{
26 if (window) {
27 if (!getWindowFound(window)) {
28 /* Store the pointer to the window. */
29 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(windows_.begin(), windows_.end(), window);
41 if (result != windows_.end()) {
42 setWindowInactive(window);
43 windows_.erase(result);
44 success = GHOST_kSuccess;
45 }
46 }
47 return success;
48}
49
51{
52 bool found = false;
53 if (window) {
54 std::vector<GHOST_IWindow *>::const_iterator result = find(
55 windows_.begin(), windows_.end(), window);
56 if (result != windows_.end()) {
57 found = true;
58 }
59 }
60 return found;
61}
62
64{
66 if (window != active_window_) {
67 if (getWindowFound(window)) {
68 active_window_ = window;
69 }
70 else {
71 success = GHOST_kFailure;
72 }
73 }
74 return success;
75}
76
81
83{
84 if (window == active_window_) {
85 active_window_ = nullptr;
86 }
87}
88
89const std::vector<GHOST_IWindow *> &GHOST_WindowManager::getWindows() const
90{
91 return windows_;
92}
93
95{
96 std::vector<GHOST_IWindow *>::iterator iter;
97
98 for (iter = windows_.begin(); iter != windows_.end(); ++iter) {
99 if ((*iter)->getOSWindow() == osWindow) {
100 return *iter;
101 }
102 }
103 return nullptr;
104}
GHOST_TSuccess
Definition GHOST_Types.h:57
@ GHOST_kFailure
Definition GHOST_Types.h:57
@ GHOST_kSuccess
Definition GHOST_Types.h:57
GHOST_IWindow * active_window_
GHOST_TSuccess addWindow(GHOST_IWindow *window)
GHOST_IWindow * getWindowAssociatedWithOSWindow(const void *osWindow)
GHOST_TSuccess removeWindow(const GHOST_IWindow *window)
const std::vector< GHOST_IWindow * > & getWindows() const
GHOST_IWindow * getActiveWindow() const
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window)
bool getWindowFound(const GHOST_IWindow *window) const
std::vector< GHOST_IWindow * > windows_
void setWindowInactive(const GHOST_IWindow *window)