mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:37:34 +00:00
Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
This commit is contained in:
parent
689ca370d4
commit
359d6e7b0b
111 changed files with 517 additions and 503 deletions
|
@ -37,10 +37,10 @@ MCTSTree& MCTSTree::select_leaf()
|
|||
MCTSTree* node = nullptr;
|
||||
double max_uct = -double(INFINITY);
|
||||
for (auto& child : m_children) {
|
||||
double uct = child.uct(m_turn);
|
||||
double uct = child->uct(m_turn);
|
||||
if (uct >= max_uct) {
|
||||
max_uct = uct;
|
||||
node = &child;
|
||||
node = child;
|
||||
}
|
||||
}
|
||||
VERIFY(node);
|
||||
|
@ -68,8 +68,8 @@ MCTSTree& MCTSTree::expand()
|
|||
}
|
||||
|
||||
for (auto& child : m_children) {
|
||||
if (child.m_simulations == 0) {
|
||||
return child;
|
||||
if (child->m_simulations == 0) {
|
||||
return *child;
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -133,8 +133,8 @@ void MCTSTree::do_round()
|
|||
Optional<MCTSTree&> MCTSTree::child_with_move(Chess::Move chess_move)
|
||||
{
|
||||
for (auto& node : m_children) {
|
||||
if (node.last_move() == chess_move)
|
||||
return node;
|
||||
if (node->last_move() == chess_move)
|
||||
return *node;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ MCTSTree& MCTSTree::best_node()
|
|||
double best_score = -double(INFINITY);
|
||||
VERIFY(m_children.size());
|
||||
for (auto& node : m_children) {
|
||||
double node_score = node.expected_value() * score_multiplier;
|
||||
double node_score = node->expected_value() * score_multiplier;
|
||||
if (node_score >= best_score) {
|
||||
best_node_ptr = &node;
|
||||
best_node_ptr = node;
|
||||
best_score = node_score;
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ bool MCTSTree::expanded() const
|
|||
return false;
|
||||
|
||||
for (auto& child : m_children) {
|
||||
if (child.m_simulations == 0)
|
||||
if (child->m_simulations == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ private:
|
|||
// FIXME: Optimize simulations enough for use.
|
||||
static constexpr EvalMethod s_eval_method { EvalMethod::Heuristic };
|
||||
|
||||
NonnullOwnPtrVector<MCTSTree> m_children;
|
||||
Vector<NonnullOwnPtr<MCTSTree>> m_children;
|
||||
MCTSTree* m_parent { nullptr };
|
||||
int m_white_points { 0 };
|
||||
int m_simulations { 0 };
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace RequestServer::ConnectionCache {
|
||||
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<Core::TCPSocket, Core::Socket>>>>> g_tcp_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<TLS::TLSv12>>>>> g_tls_connection_cache {};
|
||||
|
||||
void request_did_finish(URL const& url, Core::Socket const* socket)
|
||||
{
|
||||
|
@ -85,10 +85,10 @@ void dump_jobs()
|
|||
for (auto& connection : g_tls_connection_cache) {
|
||||
dbgln(" - {}:{}", connection.key.hostname, connection.key.port);
|
||||
for (auto& entry : *connection.value) {
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry.has_started, entry.socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry.current_url, entry.timer.is_valid() ? entry.timer.elapsed() : 0);
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry->has_started, entry->socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry->current_url, entry->timer.is_valid() ? entry->timer.elapsed() : 0);
|
||||
dbgln(" Request Queue:");
|
||||
for (auto& job : entry.request_queue)
|
||||
for (auto& job : entry->request_queue)
|
||||
dbgln(" - {}", &job);
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +96,10 @@ void dump_jobs()
|
|||
for (auto& connection : g_tcp_connection_cache) {
|
||||
dbgln(" - {}:{}", connection.key.hostname, connection.key.port);
|
||||
for (auto& entry : *connection.value) {
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry.has_started, entry.socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry.current_url, entry.timer.is_valid() ? entry.timer.elapsed() : 0);
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry->has_started, entry->socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry->current_url, entry->timer.is_valid() ? entry->timer.elapsed() : 0);
|
||||
dbgln(" Request Queue:");
|
||||
for (auto& job : entry.request_queue)
|
||||
for (auto& job : entry->request_queue)
|
||||
dbgln(" - {}", &job);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ struct AK::Traits<RequestServer::ConnectionCache::ConnectionKey> : public AK::Ge
|
|||
|
||||
namespace RequestServer::ConnectionCache {
|
||||
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<Core::TCPSocket, Core::Socket>>>>> g_tcp_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<TLS::TLSv12>>>>> g_tls_connection_cache;
|
||||
|
||||
void request_did_finish(URL const&, Core::Socket const*);
|
||||
void dump_jobs();
|
||||
|
@ -178,12 +178,12 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
|
||||
Proxy proxy { proxy_data };
|
||||
|
||||
using ReturnType = decltype(&sockets_for_url[0]);
|
||||
using ReturnType = decltype(sockets_for_url[0].ptr());
|
||||
auto it = sockets_for_url.find_if([](auto& connection) { return connection->request_queue.is_empty(); });
|
||||
auto did_add_new_connection = false;
|
||||
auto failed_to_find_a_socket = it.is_end();
|
||||
if (failed_to_find_a_socket && sockets_for_url.size() < ConnectionCache::MaxConcurrentConnectionsPerURL) {
|
||||
using ConnectionType = RemoveCVReference<decltype(cache.begin()->value->at(0))>;
|
||||
using ConnectionType = RemoveCVReference<decltype(*cache.begin()->value->at(0))>;
|
||||
auto connection_result = proxy.tunnel<typename ConnectionType::SocketType, typename ConnectionType::StorageType>(url);
|
||||
if (connection_result.is_error()) {
|
||||
dbgln("ConnectionCache: Connection to {} failed: {}", url, connection_result.error());
|
||||
|
@ -204,7 +204,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
socket_result.release_value(),
|
||||
typename ConnectionType::QueueType {},
|
||||
Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr).release_value_but_fixme_should_propagate_errors()));
|
||||
sockets_for_url.last().proxy = move(proxy);
|
||||
sockets_for_url.last()->proxy = move(proxy);
|
||||
did_add_new_connection = true;
|
||||
}
|
||||
size_t index;
|
||||
|
@ -216,7 +216,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
index = 0;
|
||||
auto min_queue_size = (size_t)-1;
|
||||
for (auto it = sockets_for_url.begin(); it != sockets_for_url.end(); ++it) {
|
||||
if (auto queue_size = it->request_queue.size(); min_queue_size > queue_size) {
|
||||
if (auto queue_size = (*it)->request_queue.size(); min_queue_size > queue_size) {
|
||||
index = it.index();
|
||||
min_queue_size = queue_size;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
return ReturnType { nullptr };
|
||||
}
|
||||
|
||||
auto& connection = sockets_for_url[index];
|
||||
auto& connection = *sockets_for_url[index];
|
||||
if (!connection.has_started) {
|
||||
if (auto result = recreate_socket_if_needed(connection, url); result.is_error()) {
|
||||
dbgln("ConnectionCache: request failed to start, failed to make a socket: {}", result.error());
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace WebDriver {
|
||||
|
||||
Atomic<unsigned> Client::s_next_session_id;
|
||||
NonnullOwnPtrVector<Session> Client::s_sessions;
|
||||
Vector<NonnullOwnPtr<Session>> Client::s_sessions;
|
||||
|
||||
ErrorOr<NonnullRefPtr<Client>> Client::try_create(NonnullOwnPtr<Core::BufferedTCPSocket> socket, LaunchBrowserCallbacks callbacks, Core::Object* parent)
|
||||
{
|
||||
|
@ -44,8 +44,8 @@ ErrorOr<Session*, Web::WebDriver::Error> Client::find_session_with_id(StringView
|
|||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSessionId, "Invalid session id");
|
||||
|
||||
for (auto& session : Client::s_sessions) {
|
||||
if (session.session_id() == session_id_or_error.value())
|
||||
return &session;
|
||||
if (session->session_id() == session_id_or_error.value())
|
||||
return session;
|
||||
}
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSessionId, "Invalid session id");
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ ErrorOr<NonnullOwnPtr<Session>, Web::WebDriver::Error> Client::take_session_with
|
|||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSessionId, "Invalid session id");
|
||||
|
||||
for (size_t i = 0; i < Client::s_sessions.size(); ++i) {
|
||||
if (Client::s_sessions[i].session_id() == session_id_or_error.value()) {
|
||||
if (Client::s_sessions[i]->session_id() == session_id_or_error.value()) {
|
||||
return Client::s_sessions.take(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
virtual Web::WebDriver::Response take_element_screenshot(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
virtual Web::WebDriver::Response print_page(Web::WebDriver::Parameters parameters, JsonValue payload) override;
|
||||
|
||||
static NonnullOwnPtrVector<Session> s_sessions;
|
||||
static Vector<NonnullOwnPtr<Session>> s_sessions;
|
||||
static Atomic<unsigned> s_next_session_id;
|
||||
|
||||
LaunchBrowserCallbacks m_callbacks;
|
||||
|
|
|
@ -73,14 +73,14 @@ int Menu::content_width() const
|
|||
int widest_text = 0;
|
||||
int widest_shortcut = 0;
|
||||
for (auto& item : m_items) {
|
||||
if (!item.is_visible())
|
||||
if (!item->is_visible())
|
||||
continue;
|
||||
if (item.type() != MenuItem::Text)
|
||||
if (item->type() != MenuItem::Text)
|
||||
continue;
|
||||
auto& use_font = item.is_default() ? font().bold_variant() : font();
|
||||
int text_width = use_font.width(Gfx::parse_ampersand_string(item.text()));
|
||||
if (!item.shortcut_text().is_empty()) {
|
||||
int shortcut_width = use_font.width(item.shortcut_text());
|
||||
auto& use_font = item->is_default() ? font().bold_variant() : font();
|
||||
int text_width = use_font.width(Gfx::parse_ampersand_string(item->text()));
|
||||
if (!item->shortcut_text().is_empty()) {
|
||||
int shortcut_width = use_font.width(item->shortcut_text());
|
||||
widest_shortcut = max(shortcut_width, widest_shortcut);
|
||||
}
|
||||
widest_text = max(widest_text, text_width);
|
||||
|
@ -129,7 +129,7 @@ Window& Menu::ensure_menu_window(Gfx::IntPoint position)
|
|||
auto calculate_window_rect = [&]() -> Gfx::IntRect {
|
||||
int window_height_available = screen.height() - frame_thickness() * 2;
|
||||
int max_window_height = (window_height_available / item_height()) * item_height() + frame_thickness() * 2;
|
||||
int content_height = m_items.is_empty() ? 0 : (m_items.last().rect().bottom() + 1) + frame_thickness();
|
||||
int content_height = m_items.is_empty() ? 0 : (m_items.last()->rect().bottom() + 1) + frame_thickness();
|
||||
int window_height = min(max_window_height, content_height);
|
||||
if (window_height < content_height) {
|
||||
m_scrollable = true;
|
||||
|
@ -140,14 +140,14 @@ Window& Menu::ensure_menu_window(Gfx::IntPoint position)
|
|||
|
||||
Gfx::IntPoint next_item_location(frame_thickness(), frame_thickness());
|
||||
for (auto& item : m_items) {
|
||||
if (!item.is_visible())
|
||||
if (!item->is_visible())
|
||||
continue;
|
||||
int height = 0;
|
||||
if (item.type() == MenuItem::Text)
|
||||
if (item->type() == MenuItem::Text)
|
||||
height = item_height();
|
||||
else if (item.type() == MenuItem::Separator)
|
||||
else if (item->type() == MenuItem::Separator)
|
||||
height = 8;
|
||||
item.set_rect({ next_item_location, { width - frame_thickness() * 2, height } });
|
||||
item->set_rect({ next_item_location, { width - frame_thickness() * 2, height } });
|
||||
next_item_location.translate_by(0, height);
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ void Menu::draw()
|
|||
|
||||
int visible_item_count = this->visible_item_count();
|
||||
for (int i = 0; i < visible_item_count; ++i)
|
||||
draw(m_items.at(m_scroll_offset + i), true);
|
||||
draw(*m_items[m_scroll_offset + i], true);
|
||||
}
|
||||
|
||||
void Menu::draw(MenuItem const& item, bool is_drawing_all)
|
||||
|
@ -407,9 +407,9 @@ void Menu::event(Core::Event& event)
|
|||
// Default to the last enabled, non-separator item on key press if one has not been selected yet
|
||||
for (auto i = static_cast<int>(m_items.size()) - 1; i >= 0; i--) {
|
||||
auto& item = m_items.at(i);
|
||||
if (!item.is_visible())
|
||||
if (!item->is_visible())
|
||||
continue;
|
||||
if (item.type() != MenuItem::Separator && item.is_enabled()) {
|
||||
if (item->type() != MenuItem::Separator && item->is_enabled()) {
|
||||
set_hovered_index(i, key == Key_Right);
|
||||
break;
|
||||
}
|
||||
|
@ -418,9 +418,9 @@ void Menu::event(Core::Event& event)
|
|||
// Default to the first enabled, non-separator item on key press if one has not been selected yet
|
||||
int counter = 0;
|
||||
for (auto const& item : m_items) {
|
||||
if (!item.is_visible())
|
||||
if (!item->is_visible())
|
||||
continue;
|
||||
if (item.type() != MenuItem::Separator && item.is_enabled()) {
|
||||
if (item->type() != MenuItem::Separator && item->is_enabled()) {
|
||||
set_hovered_index(counter, key == Key_Right);
|
||||
break;
|
||||
}
|
||||
|
@ -562,12 +562,12 @@ void Menu::did_activate(MenuItem& item, bool leave_menu_open)
|
|||
bool Menu::activate_default()
|
||||
{
|
||||
for (auto& item : m_items) {
|
||||
if (!item.is_visible())
|
||||
if (!item->is_visible())
|
||||
continue;
|
||||
if (item.type() == MenuItem::Type::Separator)
|
||||
if (item->type() == MenuItem::Type::Separator)
|
||||
continue;
|
||||
if (item.is_enabled() && item.is_default()) {
|
||||
did_activate(item, false);
|
||||
if (item->is_enabled() && item->is_default()) {
|
||||
did_activate(*item, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -577,8 +577,8 @@ bool Menu::activate_default()
|
|||
MenuItem* Menu::item_with_identifier(unsigned identifier)
|
||||
{
|
||||
for (auto& item : m_items) {
|
||||
if (item.identifier() == identifier)
|
||||
return &item;
|
||||
if (item->identifier() == identifier)
|
||||
return item;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -592,9 +592,9 @@ int Menu::item_index_at(Gfx::IntPoint position)
|
|||
{
|
||||
for (int i = 0; i < static_cast<int>(m_items.size()); ++i) {
|
||||
auto const& item = m_items[i];
|
||||
if (!item.is_visible())
|
||||
if (!item->is_visible())
|
||||
continue;
|
||||
if (item.rect().contains(position))
|
||||
if (item->rect().contains(position))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
@ -684,9 +684,9 @@ void Menu::do_popup(Gfx::IntPoint position, bool make_input, bool as_submenu)
|
|||
bool Menu::is_menu_ancestor_of(Menu const& other) const
|
||||
{
|
||||
for (auto& item : m_items) {
|
||||
if (!item.is_submenu())
|
||||
if (!item->is_submenu())
|
||||
continue;
|
||||
auto& submenu = *item.submenu();
|
||||
auto& submenu = *item->submenu();
|
||||
if (&submenu == &other)
|
||||
return true;
|
||||
if (submenu.is_menu_ancestor_of(other))
|
||||
|
@ -711,7 +711,7 @@ void Menu::update_alt_shortcuts_for_items()
|
|||
m_alt_shortcut_character_to_item_indices.clear();
|
||||
int i = 0;
|
||||
for (auto& item : m_items) {
|
||||
if (auto alt_shortcut = find_ampersand_shortcut_character(item.text())) {
|
||||
if (auto alt_shortcut = find_ampersand_shortcut_character(item->text())) {
|
||||
m_alt_shortcut_character_to_item_indices.ensure(to_ascii_lowercase(alt_shortcut)).append(i);
|
||||
}
|
||||
++i;
|
||||
|
|
|
@ -40,8 +40,8 @@ public:
|
|||
|
||||
bool is_empty() const { return m_items.is_empty(); }
|
||||
size_t item_count() const { return m_items.size(); }
|
||||
MenuItem const& item(size_t index) const { return m_items.at(index); }
|
||||
MenuItem& item(size_t index) { return m_items.at(index); }
|
||||
MenuItem const& item(size_t index) const { return *m_items.at(index); }
|
||||
MenuItem& item(size_t index) { return *m_items.at(index); }
|
||||
|
||||
MenuItem* item_by_identifier(unsigned identifier)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
IterationDecision for_each_item(Callback callback)
|
||||
{
|
||||
for (auto& item : m_items) {
|
||||
IterationDecision decision = callback(item);
|
||||
IterationDecision decision = callback(*item);
|
||||
if (decision != IterationDecision::Continue)
|
||||
return decision;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ private:
|
|||
u32 m_alt_shortcut_character { 0 };
|
||||
Gfx::IntRect m_rect_in_window_menubar;
|
||||
Gfx::IntPoint m_unadjusted_position;
|
||||
NonnullOwnPtrVector<MenuItem> m_items;
|
||||
Vector<NonnullOwnPtr<MenuItem>> m_items;
|
||||
RefPtr<Window> m_menu_window;
|
||||
|
||||
WeakPtr<Window> m_window_menu_of;
|
||||
|
|
|
@ -294,7 +294,7 @@ Gfx::WindowTheme::WindowState WindowFrame::window_state_for_theme() const
|
|||
void WindowFrame::paint_notification_frame(Gfx::Painter& painter)
|
||||
{
|
||||
auto palette = WindowManager::the().palette();
|
||||
Gfx::WindowTheme::current().paint_notification_frame(painter, to_theme_window_mode(m_window.mode()), m_window.rect(), palette, m_buttons.last().relative_rect());
|
||||
Gfx::WindowTheme::current().paint_notification_frame(painter, to_theme_window_mode(m_window.mode()), m_window.rect(), palette, m_buttons.last()->relative_rect());
|
||||
}
|
||||
|
||||
void WindowFrame::paint_menubar(Gfx::Painter& painter)
|
||||
|
@ -401,7 +401,7 @@ void WindowFrame::render(Screen& screen, Gfx::Painter& painter)
|
|||
return;
|
||||
|
||||
for (auto& button : m_buttons)
|
||||
button.paint(screen, painter);
|
||||
button->paint(screen, painter);
|
||||
}
|
||||
|
||||
void WindowFrame::theme_changed()
|
||||
|
@ -585,7 +585,7 @@ Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(Gfx::IntRect const&
|
|||
Gfx::IntRect WindowFrame::leftmost_titlebar_button_rect() const
|
||||
{
|
||||
if (!m_buttons.is_empty())
|
||||
return m_buttons.last().relative_rect();
|
||||
return m_buttons.last()->relative_rect();
|
||||
|
||||
auto rect = titlebar_rect();
|
||||
rect.translate_by(rect.width(), 0);
|
||||
|
@ -677,7 +677,7 @@ void WindowFrame::layout_buttons()
|
|||
{
|
||||
auto button_rects = Gfx::WindowTheme::current().layout_buttons(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette(), m_buttons.size());
|
||||
for (size_t i = 0; i < m_buttons.size(); i++)
|
||||
m_buttons[i].set_relative_rect(button_rects[i]);
|
||||
m_buttons[i]->set_relative_rect(button_rects[i]);
|
||||
}
|
||||
|
||||
Optional<HitTestResult> WindowFrame::hit_test(Gfx::IntPoint position)
|
||||
|
@ -795,8 +795,8 @@ void WindowFrame::handle_titlebar_mouse_event(MouseEvent const& event)
|
|||
}
|
||||
|
||||
for (auto& button : m_buttons) {
|
||||
if (button.relative_rect().contains(event.position()))
|
||||
return button.on_mouse_event(event.translated(-button.relative_rect().location()));
|
||||
if (button->relative_rect().contains(event.position()))
|
||||
return button->on_mouse_event(event.translated(-button->relative_rect().location()));
|
||||
}
|
||||
|
||||
if (event.type() == Event::MouseDown) {
|
||||
|
|
|
@ -138,7 +138,7 @@ private:
|
|||
Gfx::IntRect leftmost_titlebar_button_rect() const;
|
||||
|
||||
Window& m_window;
|
||||
NonnullOwnPtrVector<Button> m_buttons;
|
||||
Vector<NonnullOwnPtr<Button>> m_buttons;
|
||||
Button* m_close_button { nullptr };
|
||||
Button* m_maximize_button { nullptr };
|
||||
Button* m_minimize_button { nullptr };
|
||||
|
|
|
@ -44,7 +44,7 @@ WindowManager::WindowManager(Gfx::PaletteImpl& palette)
|
|||
|
||||
{
|
||||
// If we haven't created any window stacks, at least create the stationary/main window stack
|
||||
auto row = adopt_own(*new RemoveReference<decltype(m_window_stacks[0])>());
|
||||
auto row = adopt_own(*new RemoveReference<decltype(*m_window_stacks[0])>());
|
||||
auto main_window_stack = adopt_own(*new WindowStack(0, 0));
|
||||
main_window_stack->set_stationary_window_stack(*main_window_stack);
|
||||
m_current_window_stack = main_window_stack.ptr();
|
||||
|
@ -191,9 +191,9 @@ bool WindowManager::apply_workspace_settings(unsigned rows, unsigned columns, bo
|
|||
|
||||
// While we have too many rows, merge each row too many into the new bottom row
|
||||
while (current_rows > rows) {
|
||||
auto& row = m_window_stacks[rows];
|
||||
auto& row = *m_window_stacks[rows];
|
||||
for (size_t column_index = 0; column_index < row.size(); column_index++) {
|
||||
merge_window_stack(row[column_index], m_window_stacks[rows - 1][column_index]);
|
||||
merge_window_stack(*row[column_index], *(*m_window_stacks[rows - 1])[column_index]);
|
||||
if (rows - 1 == current_stack_row && column_index == current_stack_column)
|
||||
need_rerender = true;
|
||||
}
|
||||
|
@ -203,8 +203,8 @@ bool WindowManager::apply_workspace_settings(unsigned rows, unsigned columns, bo
|
|||
// While we have too many columns, merge each column too many into the new right most column
|
||||
while (current_columns > columns) {
|
||||
for (size_t row_index = 0; row_index < current_rows; row_index++) {
|
||||
auto& row = m_window_stacks[row_index];
|
||||
merge_window_stack(row[columns], row[columns - 1]);
|
||||
auto& row = *m_window_stacks[row_index];
|
||||
merge_window_stack(*row[columns], *row[columns - 1]);
|
||||
if (row_index == current_stack_row && columns - 1 == current_stack_column)
|
||||
need_rerender = true;
|
||||
row.remove(columns);
|
||||
|
@ -213,10 +213,10 @@ bool WindowManager::apply_workspace_settings(unsigned rows, unsigned columns, bo
|
|||
}
|
||||
// Add more rows if necessary
|
||||
while (rows > current_rows) {
|
||||
auto row = adopt_own(*new RemoveReference<decltype(m_window_stacks[0])>());
|
||||
auto row = adopt_own(*new RemoveReference<decltype(*m_window_stacks[0])>());
|
||||
for (size_t column_index = 0; column_index < columns; column_index++) {
|
||||
auto window_stack = adopt_own(*new WindowStack(current_rows, column_index));
|
||||
window_stack->set_stationary_window_stack(m_window_stacks[0][0]);
|
||||
window_stack->set_stationary_window_stack(*(*m_window_stacks[0])[0]);
|
||||
row->append(move(window_stack));
|
||||
}
|
||||
m_window_stacks.append(move(row));
|
||||
|
@ -226,10 +226,10 @@ bool WindowManager::apply_workspace_settings(unsigned rows, unsigned columns, bo
|
|||
while (columns > current_columns) {
|
||||
for (size_t row_index = 0; row_index < current_rows; row_index++) {
|
||||
auto& row = m_window_stacks[row_index];
|
||||
while (row.size() < columns) {
|
||||
auto window_stack = adopt_own(*new WindowStack(row_index, row.size()));
|
||||
window_stack->set_stationary_window_stack(m_window_stacks[0][0]);
|
||||
row.append(move(window_stack));
|
||||
while (row->size() < columns) {
|
||||
auto window_stack = adopt_own(*new WindowStack(row_index, row->size()));
|
||||
window_stack->set_stationary_window_stack(*(*m_window_stacks[0])[0]);
|
||||
row->append(move(window_stack));
|
||||
}
|
||||
}
|
||||
current_columns++;
|
||||
|
@ -237,7 +237,7 @@ bool WindowManager::apply_workspace_settings(unsigned rows, unsigned columns, bo
|
|||
|
||||
if (removing_current_stack) {
|
||||
// If we're on a window stack that was removed, we need to move...
|
||||
m_current_window_stack = &m_window_stacks[new_current_row][new_current_column];
|
||||
m_current_window_stack = (*m_window_stacks[new_current_row])[new_current_column];
|
||||
Compositor::the().set_current_window_stack_no_transition(*m_current_window_stack);
|
||||
need_rerender = false; // The compositor already called invalidate_for_window_stack_merge_or_change for us
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ bool WindowManager::is_natural_scroll() const
|
|||
WindowStack& WindowManager::window_stack_for_window(Window& window)
|
||||
{
|
||||
if (is_stationary_window_type(window.type()))
|
||||
return m_window_stacks[0][0];
|
||||
return *(*m_window_stacks[0])[0];
|
||||
if (auto* parent = window.parent_window(); parent && !is_stationary_window_type(parent->type()))
|
||||
return parent->window_stack();
|
||||
return current_window_stack();
|
||||
|
@ -1657,7 +1657,7 @@ void WindowManager::process_key_event(KeyEvent& event)
|
|||
column--;
|
||||
return true;
|
||||
case Key_Right:
|
||||
if (column + 1 >= m_window_stacks[0].size())
|
||||
if (column + 1 >= m_window_stacks[0]->size())
|
||||
return true;
|
||||
column++;
|
||||
return true;
|
||||
|
@ -1678,7 +1678,7 @@ void WindowManager::process_key_event(KeyEvent& event)
|
|||
if (handle_window_stack_switch_key()) {
|
||||
request_close_fragile_windows();
|
||||
Window* carry_window = nullptr;
|
||||
auto& new_window_stack = m_window_stacks[row][column];
|
||||
auto& new_window_stack = *(*m_window_stacks[row])[column];
|
||||
if (&new_window_stack != ¤t_stack) {
|
||||
if (event.modifiers() == (Mod_Ctrl | Mod_Shift | Mod_Alt))
|
||||
carry_window = this->active_window();
|
||||
|
|
|
@ -259,11 +259,11 @@ public:
|
|||
void switch_to_window_stack(u32 row, u32 col, Window* carry = nullptr, bool show_overlay = true)
|
||||
{
|
||||
if (row < window_stack_rows() && col < window_stack_columns())
|
||||
switch_to_window_stack(m_window_stacks[row][col], carry, show_overlay);
|
||||
switch_to_window_stack(*(*m_window_stacks[row])[col], carry, show_overlay);
|
||||
}
|
||||
|
||||
size_t window_stack_rows() const { return m_window_stacks.size(); }
|
||||
size_t window_stack_columns() const { return m_window_stacks[0].size(); }
|
||||
size_t window_stack_columns() const { return m_window_stacks[0]->size(); }
|
||||
|
||||
bool apply_workspace_settings(unsigned rows, unsigned columns, bool save);
|
||||
|
||||
|
@ -277,8 +277,8 @@ public:
|
|||
IterationDecision for_each_window_stack(F f)
|
||||
{
|
||||
for (auto& row : m_window_stacks) {
|
||||
for (auto& stack : row) {
|
||||
IterationDecision decision = f(stack);
|
||||
for (auto& stack : *row) {
|
||||
IterationDecision decision = f(*stack);
|
||||
if (decision != IterationDecision::Continue)
|
||||
return decision;
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ private:
|
|||
RefPtr<MultiScaleBitmaps> m_overlay_rect_shadow;
|
||||
|
||||
// Setup 2 rows 1 column by default
|
||||
NonnullOwnPtrVector<NonnullOwnPtrVector<WindowStack, default_window_stack_columns>, default_window_stack_rows> m_window_stacks;
|
||||
Vector<NonnullOwnPtr<Vector<NonnullOwnPtr<WindowStack>, default_window_stack_columns>>, default_window_stack_rows> m_window_stacks;
|
||||
WindowStack* m_current_window_stack { nullptr };
|
||||
|
||||
struct DoubleClickInfo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue