mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #99843 from KoBeWi/easy_windows
Add helper method to get Window from ID
This commit is contained in:
commit
16ee94a953
4 changed files with 15 additions and 23 deletions
|
@ -1601,18 +1601,12 @@ void ColorPicker::_pick_button_pressed_legacy() {
|
||||||
// Add the Texture of each Window to the Image.
|
// Add the Texture of each Window to the Image.
|
||||||
Vector<DisplayServer::WindowID> wl = ds->get_window_list();
|
Vector<DisplayServer::WindowID> wl = ds->get_window_list();
|
||||||
// FIXME: sort windows by visibility.
|
// FIXME: sort windows by visibility.
|
||||||
for (int index = 0; index < wl.size(); index++) {
|
for (const DisplayServer::WindowID &window_id : wl) {
|
||||||
DisplayServer::WindowID wid = wl[index];
|
Window *w = Window::get_from_id(window_id);
|
||||||
if (wid == DisplayServer::INVALID_WINDOW_ID) {
|
if (!w) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectID woid = DisplayServer::get_singleton()->window_get_attached_instance_id(wid);
|
|
||||||
if (woid == ObjectID()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window *w = Object::cast_to<Window>(ObjectDB::get_instance(woid));
|
|
||||||
Ref<Image> img = w->get_texture()->get_image();
|
Ref<Image> img = w->get_texture()->get_image();
|
||||||
if (!img.is_valid() || img->is_empty()) {
|
if (!img.is_valid() || img->is_empty()) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -3772,19 +3772,9 @@ void Viewport::set_embedding_subwindows(bool p_embed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow_change) {
|
if (allow_change) {
|
||||||
Vector<int> wl = DisplayServer::get_singleton()->get_window_list();
|
Vector<DisplayServer::WindowID> wl = DisplayServer::get_singleton()->get_window_list();
|
||||||
for (int index = 0; index < wl.size(); index++) {
|
for (const DisplayServer::WindowID &window_id : wl) {
|
||||||
DisplayServer::WindowID wid = wl[index];
|
const Window *w = Window::get_from_id(window_id);
|
||||||
if (wid == DisplayServer::INVALID_WINDOW_ID) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectID woid = DisplayServer::get_singleton()->window_get_attached_instance_id(wid);
|
|
||||||
if (woid.is_null()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window *w = Object::cast_to<Window>(ObjectDB::get_instance(woid));
|
|
||||||
if (w && is_ancestor_of(w)) {
|
if (w && is_ancestor_of(w)) {
|
||||||
// Prevent change when this viewport has child windows that are displayed as native windows.
|
// Prevent change when this viewport has child windows that are displayed as native windows.
|
||||||
allow_change = false;
|
allow_change = false;
|
||||||
|
|
|
@ -270,6 +270,13 @@ void Window::_validate_property(PropertyInfo &p_property) const {
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
Window *Window::get_from_id(DisplayServer::WindowID p_window_id) {
|
||||||
|
if (p_window_id == DisplayServer::INVALID_WINDOW_ID) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return Object::cast_to<Window>(ObjectDB::get_instance(DisplayServer::get_singleton()->window_get_attached_instance_id(p_window_id)));
|
||||||
|
}
|
||||||
|
|
||||||
void Window::set_title(const String &p_title) {
|
void Window::set_title(const String &p_title) {
|
||||||
ERR_MAIN_THREAD_GUARD;
|
ERR_MAIN_THREAD_GUARD;
|
||||||
|
|
||||||
|
@ -912,7 +919,7 @@ void Window::_make_transient() {
|
||||||
if (!is_embedded() && transient_to_focused) {
|
if (!is_embedded() && transient_to_focused) {
|
||||||
DisplayServer::WindowID focused_window_id = DisplayServer::get_singleton()->get_focused_window();
|
DisplayServer::WindowID focused_window_id = DisplayServer::get_singleton()->get_focused_window();
|
||||||
if (focused_window_id != DisplayServer::INVALID_WINDOW_ID) {
|
if (focused_window_id != DisplayServer::INVALID_WINDOW_ID) {
|
||||||
window = Object::cast_to<Window>(ObjectDB::get_instance(DisplayServer::get_singleton()->window_get_attached_instance_id(focused_window_id)));
|
window = Window::get_from_id(focused_window_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,6 +271,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_root_layout_direction(int p_root_dir);
|
static void set_root_layout_direction(int p_root_dir);
|
||||||
|
static Window *get_from_id(DisplayServer::WindowID p_window_id);
|
||||||
|
|
||||||
void set_title(const String &p_title);
|
void set_title(const String &p_title);
|
||||||
String get_title() const;
|
String get_title() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue