1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:27:45 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -18,7 +18,7 @@ void ChessEngine::handle_uci()
send_command(UCIOkCommand());
}
void ChessEngine::handle_position(const PositionCommand& command)
void ChessEngine::handle_position(PositionCommand const& command)
{
// FIXME: Implement fen board position.
VERIFY(!command.fen().has_value());
@ -28,7 +28,7 @@ void ChessEngine::handle_position(const PositionCommand& command)
}
}
void ChessEngine::handle_go(const GoCommand& command)
void ChessEngine::handle_go(GoCommand const& command)
{
// FIXME: A better algorithm than naive mcts.
// FIXME: Add different ways to terminate search.

View file

@ -15,8 +15,8 @@ public:
virtual ~ChessEngine() override = default;
virtual void handle_uci() override;
virtual void handle_position(const Chess::UCI::PositionCommand&) override;
virtual void handle_go(const Chess::UCI::GoCommand&) override;
virtual void handle_position(Chess::UCI::PositionCommand const&) override;
virtual void handle_go(Chess::UCI::GoCommand const&) override;
private:
ChessEngine() = default;

View file

@ -8,7 +8,7 @@
#include <AK/String.h>
#include <stdlib.h>
MCTSTree::MCTSTree(const Chess::Board& board, MCTSTree* parent)
MCTSTree::MCTSTree(Chess::Board const& board, MCTSTree* parent)
: m_parent(parent)
, m_board(make<Chess::Board>(board))
, m_last_move(board.last_move())

View file

@ -19,7 +19,7 @@ public:
Heuristic,
};
MCTSTree(const Chess::Board& board, MCTSTree* parent = nullptr);
MCTSTree(Chess::Board const& board, MCTSTree* parent = nullptr);
MCTSTree& select_leaf();
MCTSTree& expand();

View file

@ -14,7 +14,7 @@ Storage& Storage::the()
return s_the;
}
void Storage::set_data(Core::AnonymousBuffer data, const String& mime_type, const HashMap<String, String>& metadata)
void Storage::set_data(Core::AnonymousBuffer data, String const& mime_type, HashMap<String, String> const& metadata)
{
m_buffer = move(data);
m_data_size = data.size();

View file

@ -20,10 +20,10 @@ public:
bool has_data() const { return m_buffer.is_valid(); }
const String& mime_type() const { return m_mime_type; }
const HashMap<String, String>& metadata() const { return m_metadata; }
String const& mime_type() const { return m_mime_type; }
HashMap<String, String> const& metadata() const { return m_metadata; }
const u8* data() const
u8 const* data() const
{
if (!has_data())
return nullptr;
@ -37,11 +37,11 @@ public:
return 0;
}
void set_data(Core::AnonymousBuffer, const String& mime_type, const HashMap<String, String>& metadata);
void set_data(Core::AnonymousBuffer, String const& mime_type, HashMap<String, String> const& metadata);
Function<void()> on_content_change;
const Core::AnonymousBuffer& buffer() const { return m_buffer; }
Core::AnonymousBuffer const& buffer() const { return m_buffer; }
private:
Storage() = default;

View file

@ -16,7 +16,7 @@
#include <time.h>
#include <unistd.h>
static void wait_until_coredump_is_ready(const String& coredump_path)
static void wait_until_coredump_is_ready(String const& coredump_path)
{
while (true) {
struct stat statbuf;
@ -31,10 +31,10 @@ static void wait_until_coredump_is_ready(const String& coredump_path)
}
}
static void launch_crash_reporter(const String& coredump_path, bool unlink_on_exit)
static void launch_crash_reporter(String const& coredump_path, bool unlink_on_exit)
{
pid_t child;
const char* argv[4] = { "CrashReporter" };
char const* argv[4] = { "CrashReporter" };
if (unlink_on_exit) {
argv[1] = "--unlink";
argv[2] = coredump_path.characters();

View file

@ -11,7 +11,7 @@ ParsedDHCPv4Options DHCPv4Packet::parse_options() const
{
ParsedDHCPv4Options options;
for (size_t index = 4; index < DHCPV4_OPTION_FIELD_MAX_LENGTH; ++index) {
auto opt_name = *(const DHCPOption*)&m_options[index];
auto opt_name = *(DHCPOption const*)&m_options[index];
switch (opt_name) {
case DHCPOption::Pad:
continue;

View file

@ -159,7 +159,7 @@ struct ParsedDHCPv4Options {
for (auto& opt : options) {
builder.appendff("\toption {} ({} bytes):", (u8)opt.key, (u8)opt.value.length);
for (auto i = 0; i < opt.value.length; ++i)
builder.appendff(" {} ", ((const u8*)opt.value.value)[i]);
builder.appendff(" {} ", ((u8 const*)opt.value.value)[i]);
builder.append('\n');
}
return builder.build();
@ -167,7 +167,7 @@ struct ParsedDHCPv4Options {
struct DHCPOptionValue {
u8 length;
const void* value;
void const* value;
};
HashMap<DHCPOption, DHCPOptionValue> options;
@ -198,10 +198,10 @@ public:
u16 flags() const { return m_flags; }
void set_flags(DHCPv4Flags flags) { m_flags = (u16)flags; }
const IPv4Address& ciaddr() const { return m_ciaddr; }
const IPv4Address& yiaddr() const { return m_yiaddr; }
const IPv4Address& siaddr() const { return m_siaddr; }
const IPv4Address& giaddr() const { return m_giaddr; }
IPv4Address const& ciaddr() const { return m_ciaddr; }
IPv4Address const& yiaddr() const { return m_yiaddr; }
IPv4Address const& siaddr() const { return m_siaddr; }
IPv4Address const& giaddr() const { return m_giaddr; }
IPv4Address& ciaddr() { return m_ciaddr; }
IPv4Address& yiaddr() { return m_yiaddr; }
@ -211,11 +211,11 @@ public:
u8* options() { return m_options; }
ParsedDHCPv4Options parse_options() const;
const MACAddress& chaddr() const { return *(const MACAddress*)&m_chaddr[0]; }
void set_chaddr(const MACAddress& mac) { *(MACAddress*)&m_chaddr[0] = mac; }
MACAddress const& chaddr() const { return *(MACAddress const*)&m_chaddr[0]; }
void set_chaddr(MACAddress const& mac) { *(MACAddress*)&m_chaddr[0] = mac; }
StringView sname() const { return { (const char*)&m_sname[0] }; }
StringView file() const { return { (const char*)&m_file[0] }; }
StringView sname() const { return { (char const*)&m_sname[0] }; }
StringView file() const { return { (char const*)&m_file[0] }; }
private:
NetworkOrdered<u8> m_op;
@ -247,7 +247,7 @@ public:
options[3] = 99;
}
void add_option(DHCPOption option, u8 length, const void* data)
void add_option(DHCPOption option, u8 length, void const* data)
{
VERIFY(m_can_add);
// we need enough space to fit the option value, its length, and its data

View file

@ -15,14 +15,14 @@
#include <LibCore/Timer.h>
#include <stdio.h>
static u8 mac_part(const Vector<String>& parts, size_t index)
static u8 mac_part(Vector<String> const& parts, size_t index)
{
auto result = AK::StringUtils::convert_to_uint_from_hex(parts.at(index));
VERIFY(result.has_value());
return result.value();
}
static MACAddress mac_from_string(const String& str)
static MACAddress mac_from_string(String const& str)
{
auto chunks = str.split(':');
VERIFY(chunks.size() == 6); // should we...worry about this?
@ -32,7 +32,7 @@ static MACAddress mac_from_string(const String& str)
};
}
static bool send(const InterfaceDescriptor& iface, const DHCPv4Packet& packet, Core::Object*)
static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, Core::Object*)
{
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) {
@ -63,7 +63,7 @@ static bool send(const InterfaceDescriptor& iface, const DHCPv4Packet& packet, C
return true;
}
static void set_params(const InterfaceDescriptor& iface, const IPv4Address& ipv4_addr, const IPv4Address& netmask, const IPv4Address& gateway)
static void set_params(InterfaceDescriptor const& iface, IPv4Address const& ipv4_addr, IPv4Address const& netmask, IPv4Address const& gateway)
{
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (fd < 0) {
@ -201,7 +201,7 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
};
}
void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
{
dbgln("We were offered {} for {}", packet.yiaddr().to_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0));
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
@ -221,7 +221,7 @@ void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Op
dhcp_request(*transaction, packet);
}
void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
{
if constexpr (DHCPV4CLIENT_DEBUG) {
dbgln("The DHCP server handed us {}", packet.yiaddr().to_string());
@ -250,7 +250,7 @@ void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Opti
set_params(transaction->interface, new_ip, options.get<IPv4Address>(DHCPOption::SubnetMask).value(), options.get_many<IPv4Address>(DHCPOption::Router, 1).first());
}
void DHCPv4Client::handle_nak(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
{
dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_string());
dbgln("Here are the options: {}", options.to_string());
@ -271,7 +271,7 @@ void DHCPv4Client::handle_nak(const DHCPv4Packet& packet, const ParsedDHCPv4Opti
this);
}
void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
void DHCPv4Client::process_incoming(DHCPv4Packet const& packet)
{
auto options = packet.parse_options();
@ -307,7 +307,7 @@ void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
}
}
void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface)
void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface)
{
auto transaction_id = get_random<u32>();
@ -339,7 +339,7 @@ void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface)
m_ongoing_transactions.set(transaction_id, make<DHCPv4Transaction>(iface));
}
void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, const DHCPv4Packet& offer)
void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& offer)
{
auto& iface = transaction.interface;
dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_string(), iface.ifname);

View file

@ -42,10 +42,10 @@ class DHCPv4Client final : public Core::Object {
public:
virtual ~DHCPv4Client() override = default;
void dhcp_discover(const InterfaceDescriptor& ifname);
void dhcp_request(DHCPv4Transaction& transaction, const DHCPv4Packet& packet);
void dhcp_discover(InterfaceDescriptor const& ifname);
void dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& packet);
void process_incoming(const DHCPv4Packet& packet);
void process_incoming(DHCPv4Packet const& packet);
bool id_is_registered(u32 id) { return m_ongoing_transactions.contains(id); }
@ -65,7 +65,7 @@ private:
RefPtr<Core::Timer> m_check_timer;
int m_max_timer_backoff_interval { 600000 }; // 10 minutes
void handle_offer(const DHCPv4Packet&, const ParsedDHCPv4Options&);
void handle_ack(const DHCPv4Packet&, const ParsedDHCPv4Options&);
void handle_nak(const DHCPv4Packet&, const ParsedDHCPv4Options&);
void handle_offer(DHCPv4Packet const&, ParsedDHCPv4Options const&);
void handle_ack(DHCPv4Packet const&, ParsedDHCPv4Options const&);
void handle_nak(DHCPv4Packet const&, ParsedDHCPv4Options const&);
};

View file

@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
exit(1);
pid_t child_pid;
const char* argv[] = { "/bin/keymap", "-m", keymaps_vector.first().characters(), nullptr };
char const* argv[] = { "/bin/keymap", "-m", keymaps_vector.first().characters(), nullptr };
if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
exit(1);

View file

@ -23,7 +23,7 @@
namespace LaunchServer {
static Launcher* s_the;
static bool spawn(String executable, const Vector<String>& arguments);
static bool spawn(String executable, Vector<String> const& arguments);
String Handler::name_from_executable(StringView executable)
{
@ -35,7 +35,7 @@ String Handler::name_from_executable(StringView executable)
return executable;
}
void Handler::from_executable(Type handler_type, const String& executable)
void Handler::from_executable(Type handler_type, String const& executable)
{
this->handler_type = handler_type;
this->name = name_from_executable(executable);
@ -77,7 +77,7 @@ Launcher& Launcher::the()
return *s_the;
}
void Launcher::load_handlers(const String& af_dir)
void Launcher::load_handlers(String const& af_dir)
{
Desktop::AppFile::for_each([&](auto af) {
auto app_name = af->name();
@ -94,7 +94,7 @@ void Launcher::load_handlers(const String& af_dir)
af_dir);
}
void Launcher::load_config(const Core::ConfigFile& cfg)
void Launcher::load_config(Core::ConfigFile const& cfg)
{
for (auto key : cfg.keys("FileType")) {
auto handler = cfg.read_entry("FileType", key).trim_whitespace();
@ -124,7 +124,7 @@ Vector<String> Launcher::handlers_for_url(const URL& url)
return true;
});
} else {
for_each_handler(url.protocol(), m_protocol_handlers, [&](const auto& handler) -> bool {
for_each_handler(url.protocol(), m_protocol_handlers, [&](auto const& handler) -> bool {
if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.protocol())) {
handlers.append(handler.executable);
return true;
@ -144,7 +144,7 @@ Vector<String> Launcher::handlers_with_details_for_url(const URL& url)
return true;
});
} else {
for_each_handler(url.protocol(), m_protocol_handlers, [&](const auto& handler) -> bool {
for_each_handler(url.protocol(), m_protocol_handlers, [&](auto const& handler) -> bool {
if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.protocol())) {
handlers.append(handler.to_details_str());
return true;
@ -155,7 +155,7 @@ Vector<String> Launcher::handlers_with_details_for_url(const URL& url)
return handlers;
}
bool Launcher::open_url(const URL& url, const String& handler_name)
bool Launcher::open_url(const URL& url, String const& handler_name)
{
if (!handler_name.is_null())
return open_with_handler_name(url, handler_name);
@ -166,7 +166,7 @@ bool Launcher::open_url(const URL& url, const String& handler_name)
return open_with_user_preferences(m_protocol_handlers, url.protocol(), { url.to_string() });
}
bool Launcher::open_with_handler_name(const URL& url, const String& handler_name)
bool Launcher::open_with_handler_name(const URL& url, String const& handler_name)
{
auto handler_optional = m_handlers.get(handler_name);
if (!handler_optional.has_value())
@ -181,9 +181,9 @@ bool Launcher::open_with_handler_name(const URL& url, const String& handler_name
return spawn(handler.executable, { argument });
}
bool spawn(String executable, const Vector<String>& arguments)
bool spawn(String executable, Vector<String> const& arguments)
{
Vector<const char*> argv { executable.characters() };
Vector<char const*> argv { executable.characters() };
for (auto& arg : arguments)
argv.append(arg.characters());
argv.append(nullptr);
@ -199,7 +199,7 @@ bool spawn(String executable, const Vector<String>& arguments)
return true;
}
Handler Launcher::get_handler_for_executable(Handler::Type handler_type, const String& executable) const
Handler Launcher::get_handler_for_executable(Handler::Type handler_type, String const& executable) const
{
Handler handler;
auto existing_handler = m_handlers.get(executable);
@ -212,7 +212,7 @@ Handler Launcher::get_handler_for_executable(Handler::Type handler_type, const S
return handler;
}
bool Launcher::open_with_user_preferences(const HashMap<String, String>& user_preferences, const String& key, const Vector<String>& arguments, const String& default_program)
bool Launcher::open_with_user_preferences(HashMap<String, String> const& user_preferences, String const& key, Vector<String> const& arguments, String const& default_program)
{
auto program_path = user_preferences.get(key);
if (program_path.has_value())
@ -230,7 +230,7 @@ bool Launcher::open_with_user_preferences(const HashMap<String, String>& user_pr
return false;
}
void Launcher::for_each_handler(const String& key, HashMap<String, String>& user_preference, Function<bool(const Handler&)> f)
void Launcher::for_each_handler(String const& key, HashMap<String, String>& user_preference, Function<bool(Handler const&)> f)
{
auto user_preferred = user_preference.get(key);
if (user_preferred.has_value())
@ -250,7 +250,7 @@ void Launcher::for_each_handler(const String& key, HashMap<String, String>& user
f(get_handler_for_executable(Handler::Type::UserDefault, user_default.value()));
}
void Launcher::for_each_handler_for_path(const String& path, Function<bool(const Handler&)> f)
void Launcher::for_each_handler_for_path(String const& path, Function<bool(Handler const&)> f)
{
struct stat st;
if (lstat(path.characters(), &st) < 0) {
@ -278,7 +278,7 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const
auto link_target = LexicalPath { link_target_or_error.release_value() };
LexicalPath absolute_link_target = link_target.is_absolute() ? link_target : LexicalPath::join(LexicalPath::dirname(path), link_target.string());
auto real_path = Core::File::real_path_for(absolute_link_target.string());
return for_each_handler_for_path(real_path, [&](const auto& handler) -> bool {
return for_each_handler_for_path(real_path, [&](auto const& handler) -> bool {
return f(handler);
});
}
@ -288,7 +288,7 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const
auto extension = LexicalPath::extension(path).to_lowercase();
for_each_handler(extension, m_file_handlers, [&](const auto& handler) -> bool {
for_each_handler(extension, m_file_handlers, [&](auto const& handler) -> bool {
if (handler.handler_type != Handler::Type::Default || handler.file_types.contains(extension))
return f(handler);
return false;

View file

@ -28,7 +28,7 @@ struct Handler {
HashTable<String> protocols {};
static String name_from_executable(StringView);
void from_executable(Type, const String&);
void from_executable(Type, String const&);
String to_details_str() const;
};
@ -37,9 +37,9 @@ public:
Launcher();
static Launcher& the();
void load_handlers(const String& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY);
void load_config(const Core::ConfigFile&);
bool open_url(const URL&, const String& handler_name);
void load_handlers(String const& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY);
void load_config(Core::ConfigFile const&);
bool open_url(const URL&, String const& handler_name);
Vector<String> handlers_for_url(const URL&);
Vector<String> handlers_with_details_for_url(const URL&);
@ -48,11 +48,11 @@ private:
HashMap<String, String> m_protocol_handlers;
HashMap<String, String> m_file_handlers;
Handler get_handler_for_executable(Handler::Type, const String&) const;
void for_each_handler(const String& key, HashMap<String, String>& user_preferences, Function<bool(const Handler&)> f);
void for_each_handler_for_path(const String&, Function<bool(const Handler&)> f);
Handler get_handler_for_executable(Handler::Type, String const&) const;
void for_each_handler(String const& key, HashMap<String, String>& user_preferences, Function<bool(Handler const&)> f);
void for_each_handler_for_path(String const&, Function<bool(Handler const&)> f);
bool open_file_url(const URL&);
bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String& key, const Vector<String>& arguments, const String& default_program = {});
bool open_with_handler_name(const URL&, const String& handler_name);
bool open_with_user_preferences(HashMap<String, String> const& user_preferences, String const& key, Vector<String> const& arguments, String const& default_program = {});
bool open_with_handler_name(const URL&, String const& handler_name);
};
}

View file

@ -44,7 +44,7 @@ Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_addre
{
if (address.length() != 4)
return { 1, String() };
IPv4Address ip_address { (const u8*)address.characters() };
IPv4Address ip_address { (u8 const*)address.characters() };
auto name = String::formatted("{}.{}.{}.{}.in-addr.arpa",
ip_address[3],
ip_address[2],

View file

@ -10,7 +10,7 @@
namespace LookupServer {
DNSAnswer::DNSAnswer(const DNSName& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, const String& record_data, bool mdns_cache_flush)
DNSAnswer::DNSAnswer(DNSName const& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, String const& record_data, bool mdns_cache_flush)
: m_name(name)
, m_type(type)
, m_class_code(class_code)

View file

@ -33,15 +33,15 @@ enum class DNSRecordClass : u16 {
class DNSAnswer {
public:
DNSAnswer(const DNSName& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, const String& record_data, bool mdns_cache_flush);
DNSAnswer(DNSName const& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, String const& record_data, bool mdns_cache_flush);
const DNSName& name() const { return m_name; }
DNSName const& name() const { return m_name; }
DNSRecordType type() const { return m_type; }
DNSRecordClass class_code() const { return m_class_code; }
u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_cache_flush ? MDNS_CACHE_FLUSH : 0); }
u32 ttl() const { return m_ttl; }
time_t received_time() const { return m_received_time; }
const String& record_data() const { return m_record_data; }
String const& record_data() const { return m_record_data; }
bool mdns_cache_flush() const { return m_mdns_cache_flush; }
bool has_expired() const;

View file

@ -12,7 +12,7 @@
namespace LookupServer {
DNSName::DNSName(const String& name)
DNSName::DNSName(String const& name)
{
if (name.ends_with('.'))
m_name = name.substring(0, name.length() - 1);
@ -20,7 +20,7 @@ DNSName::DNSName(const String& name)
m_name = name;
}
DNSName DNSName::parse(const u8* data, size_t& offset, size_t max_offset, size_t recursion_level)
DNSName DNSName::parse(u8 const* data, size_t& offset, size_t max_offset, size_t recursion_level)
{
if (recursion_level > 4)
return DNSName({});
@ -45,7 +45,7 @@ DNSName DNSName::parse(const u8* data, size_t& offset, size_t max_offset, size_t
// This is the length of a part.
if (offset + b >= max_offset)
return DNSName({});
builder.append((const char*)&data[offset], (size_t)b);
builder.append((char const*)&data[offset], (size_t)b);
builder.append('.');
offset += b;
}
@ -75,7 +75,7 @@ void DNSName::randomize_case()
m_name = builder.to_string();
}
OutputStream& operator<<(OutputStream& stream, const DNSName& name)
OutputStream& operator<<(OutputStream& stream, DNSName const& name)
{
auto parts = name.as_string().split_view('.');
for (auto& part : parts) {
@ -86,12 +86,12 @@ OutputStream& operator<<(OutputStream& stream, const DNSName& name)
return stream;
}
unsigned DNSName::Traits::hash(const DNSName& name)
unsigned DNSName::Traits::hash(DNSName const& name)
{
return CaseInsensitiveStringTraits::hash(name.as_string());
}
bool DNSName::Traits::equals(const DNSName& a, const DNSName& b)
bool DNSName::Traits::equals(DNSName const& a, DNSName const& b)
{
return CaseInsensitiveStringTraits::equals(a.as_string(), b.as_string());
}

View file

@ -14,28 +14,28 @@ namespace LookupServer {
class DNSName {
public:
DNSName(const String&);
DNSName(String const&);
static DNSName parse(const u8* data, size_t& offset, size_t max_offset, size_t recursion_level = 0);
static DNSName parse(u8 const* data, size_t& offset, size_t max_offset, size_t recursion_level = 0);
size_t serialized_size() const;
const String& as_string() const { return m_name; }
String const& as_string() const { return m_name; }
void randomize_case();
bool operator==(const DNSName& other) const { return Traits::equals(*this, other); }
bool operator==(DNSName const& other) const { return Traits::equals(*this, other); }
class Traits : public AK::Traits<DNSName> {
public:
static unsigned hash(const DNSName& name);
static bool equals(const DNSName&, const DNSName&);
static unsigned hash(DNSName const& name);
static bool equals(DNSName const&, DNSName const&);
};
private:
String m_name;
};
OutputStream& operator<<(OutputStream& stream, const DNSName&);
OutputStream& operator<<(OutputStream& stream, DNSName const&);
}

View file

@ -16,14 +16,14 @@
namespace LookupServer {
void DNSPacket::add_question(const DNSQuestion& question)
void DNSPacket::add_question(DNSQuestion const& question)
{
m_questions.empend(question);
VERIFY(m_questions.size() <= UINT16_MAX);
}
void DNSPacket::add_answer(const DNSAnswer& answer)
void DNSPacket::add_answer(DNSAnswer const& answer)
{
m_answers.empend(answer);
@ -85,7 +85,7 @@ public:
u16 data_length() const { return m_data_length; }
void* data() { return this + 1; }
const void* data() const { return this + 1; }
void const* data() const { return this + 1; }
private:
NetworkOrdered<u16> m_type;
@ -96,14 +96,14 @@ private:
static_assert(sizeof(DNSRecordWithoutName) == 10);
Optional<DNSPacket> DNSPacket::from_raw_packet(const u8* raw_data, size_t raw_size)
Optional<DNSPacket> DNSPacket::from_raw_packet(u8 const* raw_data, size_t raw_size)
{
if (raw_size < sizeof(DNSPacketHeader)) {
dbgln("DNS response not large enough ({} out of {}) to be a DNS packet.", raw_size, sizeof(DNSPacketHeader));
return {};
}
auto& header = *(const DNSPacketHeader*)(raw_data);
auto& header = *(DNSPacketHeader const*)(raw_data);
dbgln_if(LOOKUPSERVER_DEBUG, "Got packet (ID: {})", header.id());
dbgln_if(LOOKUPSERVER_DEBUG, " Question count: {}", header.question_count());
dbgln_if(LOOKUPSERVER_DEBUG, " Answer count: {}", header.answer_count());
@ -127,7 +127,7 @@ Optional<DNSPacket> DNSPacket::from_raw_packet(const u8* raw_data, size_t raw_si
NetworkOrdered<u16> record_type;
NetworkOrdered<u16> class_code;
};
auto& record_and_class = *(const RawDNSAnswerQuestion*)&raw_data[offset];
auto& record_and_class = *(RawDNSAnswerQuestion const*)&raw_data[offset];
u16 class_code = record_and_class.class_code & ~MDNS_WANTS_UNICAST_RESPONSE;
bool mdns_wants_unicast_response = record_and_class.class_code & MDNS_WANTS_UNICAST_RESPONSE;
packet.m_questions.empend(name, (DNSRecordType)(u16)record_and_class.record_type, (DNSRecordClass)class_code, mdns_wants_unicast_response);
@ -139,7 +139,7 @@ Optional<DNSPacket> DNSPacket::from_raw_packet(const u8* raw_data, size_t raw_si
for (u16 i = 0; i < header.answer_count(); ++i) {
auto name = DNSName::parse(raw_data, offset, raw_size);
auto& record = *(const DNSRecordWithoutName*)(&raw_data[offset]);
auto& record = *(DNSRecordWithoutName const*)(&raw_data[offset]);
String data;

View file

@ -24,7 +24,7 @@ class DNSPacket {
public:
DNSPacket() = default;
static Optional<DNSPacket> from_raw_packet(const u8*, size_t);
static Optional<DNSPacket> from_raw_packet(u8 const*, size_t);
ByteBuffer to_byte_buffer() const;
bool is_query() const { return !m_query_or_response; }
@ -41,8 +41,8 @@ public:
u16 id() const { return m_id; }
void set_id(u16 id) { m_id = id; }
const Vector<DNSQuestion>& questions() const { return m_questions; }
const Vector<DNSAnswer>& answers() const { return m_answers; }
Vector<DNSQuestion> const& questions() const { return m_questions; }
Vector<DNSAnswer> const& answers() const { return m_answers; }
u16 question_count() const
{
@ -56,8 +56,8 @@ public:
return m_answers.size();
}
void add_question(const DNSQuestion&);
void add_answer(const DNSAnswer&);
void add_question(DNSQuestion const&);
void add_answer(DNSAnswer const&);
enum class Code : u8 {
NOERROR = 0,

View file

@ -72,7 +72,7 @@ public:
void set_additional_count(u16 w) { m_additional_count = w; }
void* payload() { return this + 1; }
const void* payload() const { return this + 1; }
void const* payload() const { return this + 1; }
private:
NetworkOrdered<u16> m_id;

View file

@ -15,7 +15,7 @@ namespace LookupServer {
class DNSQuestion {
public:
DNSQuestion(const DNSName& name, DNSRecordType record_type, DNSRecordClass class_code, bool mdns_wants_unicast_response)
DNSQuestion(DNSName const& name, DNSRecordType record_type, DNSRecordClass class_code, bool mdns_wants_unicast_response)
: m_name(name)
, m_record_type(record_type)
, m_class_code(class_code)
@ -26,7 +26,7 @@ public:
DNSRecordType record_type() const { return m_record_type; }
DNSRecordClass class_code() const { return m_class_code; }
u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_wants_unicast_response ? MDNS_WANTS_UNICAST_RESPONSE : 0); }
const DNSName& name() const { return m_name; }
DNSName const& name() const { return m_name; }
bool mdns_wants_unicast_response() const { return m_mdns_wants_unicast_response; }
private:

View file

@ -78,7 +78,7 @@ LookupServer::LookupServer()
void LookupServer::load_etc_hosts()
{
m_etc_hosts.clear();
auto add_answer = [this](const DNSName& name, DNSRecordType record_type, String data) {
auto add_answer = [this](DNSName const& name, DNSRecordType record_type, String data) {
m_etc_hosts.ensure(name).empend(name, record_type, DNSRecordClass::IN, s_static_ttl, move(data), false);
};
@ -115,7 +115,7 @@ void LookupServer::load_etc_hosts()
auto raw_addr = maybe_address->to_in_addr_t();
DNSName name { fields[1] };
add_answer(name, DNSRecordType::A, String { (const char*)&raw_addr, sizeof(raw_addr) });
add_answer(name, DNSRecordType::A, String { (char const*)&raw_addr, sizeof(raw_addr) });
StringBuilder builder;
builder.append(maybe_address->to_string_reversed());
@ -131,12 +131,12 @@ static String get_hostname()
return buffer;
}
ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, DNSRecordType record_type)
ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(DNSName const& name, DNSRecordType record_type)
{
dbgln_if(LOOKUPSERVER_DEBUG, "Got request for '{}'", name.as_string());
Vector<DNSAnswer> answers;
auto add_answer = [&](const DNSAnswer& answer) {
auto add_answer = [&](DNSAnswer const& answer) {
DNSAnswer answer_with_original_case {
name,
answer.type(),
@ -163,7 +163,7 @@ ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, DNSRecordTy
if (record_type == DNSRecordType::A && get_hostname() == name) {
IPv4Address address = { 127, 0, 0, 1 };
auto raw_address = address.to_in_addr_t();
DNSAnswer answer { name, DNSRecordType::A, DNSRecordClass::IN, s_static_ttl, String { (const char*)&raw_address, sizeof(raw_address) }, false };
DNSAnswer answer { name, DNSRecordType::A, DNSRecordClass::IN, s_static_ttl, String { (char const*)&raw_address, sizeof(raw_address) }, false };
answers.append(move(answer));
return answers;
}
@ -221,7 +221,7 @@ ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, DNSRecordTy
return answers;
}
ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, const String& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase should_randomize_case)
ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(DNSName const& name, String const& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase should_randomize_case)
{
DNSPacket request;
request.set_is_query();
@ -300,7 +300,7 @@ ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, const Strin
return answers;
}
void LookupServer::put_in_cache(const DNSAnswer& answer)
void LookupServer::put_in_cache(DNSAnswer const& answer)
{
if (answer.has_expired())
return;

View file

@ -24,15 +24,15 @@ class LookupServer final : public Core::Object {
public:
static LookupServer& the();
ErrorOr<Vector<DNSAnswer>> lookup(const DNSName& name, DNSRecordType record_type);
ErrorOr<Vector<DNSAnswer>> lookup(DNSName const& name, DNSRecordType record_type);
private:
LookupServer();
void load_etc_hosts();
void put_in_cache(const DNSAnswer&);
void put_in_cache(DNSAnswer const&);
ErrorOr<Vector<DNSAnswer>> lookup(const DNSName& hostname, const String& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
ErrorOr<Vector<DNSAnswer>> lookup(DNSName const& hostname, String const& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
OwnPtr<IPC::MultiServer<ConnectionFromClient>> m_server;
RefPtr<DNSServer> m_dns_server;

View file

@ -64,7 +64,7 @@ void MulticastDNS::handle_packet()
handle_query(packet);
}
void MulticastDNS::handle_query(const DNSPacket& packet)
void MulticastDNS::handle_query(DNSPacket const& packet)
{
bool should_reply = false;
@ -94,7 +94,7 @@ void MulticastDNS::announce()
DNSRecordType::A,
DNSRecordClass::IN,
120,
String { (const char*)&raw_addr, sizeof(raw_addr) },
String { (char const*)&raw_addr, sizeof(raw_addr) },
true,
};
response.add_answer(answer);
@ -104,7 +104,7 @@ void MulticastDNS::announce()
perror("Failed to emit response packet");
}
ErrorOr<size_t> MulticastDNS::emit_packet(const DNSPacket& packet, const sockaddr_in* destination)
ErrorOr<size_t> MulticastDNS::emit_packet(DNSPacket const& packet, sockaddr_in const* destination)
{
auto buffer = packet.to_byte_buffer();
if (!destination)
@ -142,7 +142,7 @@ Vector<IPv4Address> MulticastDNS::local_addresses() const
return addresses;
}
Vector<DNSAnswer> MulticastDNS::lookup(const DNSName& name, DNSRecordType record_type)
Vector<DNSAnswer> MulticastDNS::lookup(DNSName const& name, DNSRecordType record_type)
{
DNSPacket request;
request.set_is_query();

View file

@ -18,16 +18,16 @@ namespace LookupServer {
class MulticastDNS : public Core::UDPServer {
C_OBJECT(MulticastDNS)
public:
Vector<DNSAnswer> lookup(const DNSName&, DNSRecordType record_type);
Vector<DNSAnswer> lookup(DNSName const&, DNSRecordType record_type);
private:
explicit MulticastDNS(Object* parent = nullptr);
void announce();
ErrorOr<size_t> emit_packet(const DNSPacket&, const sockaddr_in* destination = nullptr);
ErrorOr<size_t> emit_packet(DNSPacket const&, sockaddr_in const* destination = nullptr);
void handle_packet();
void handle_query(const DNSPacket&);
void handle_query(DNSPacket const&);
Vector<IPv4Address> local_addresses() const;

View file

@ -19,7 +19,7 @@ namespace NotificationServer {
static HashMap<u32, RefPtr<NotificationWindow>> s_windows;
static void update_notification_window_locations(const Gfx::IntRect& screen_rect)
static void update_notification_window_locations(Gfx::IntRect const& screen_rect)
{
Gfx::IntRect last_window_rect;
for (auto& window_entry : s_windows) {
@ -37,7 +37,7 @@ static void update_notification_window_locations(const Gfx::IntRect& screen_rect
}
}
NotificationWindow::NotificationWindow(i32 client_id, const String& text, const String& title, const Gfx::ShareableBitmap& icon)
NotificationWindow::NotificationWindow(i32 client_id, String const& text, String const& title, Gfx::ShareableBitmap const& icon)
{
m_id = client_id;
s_windows.set(m_id, this);

View file

@ -18,9 +18,9 @@ public:
virtual ~NotificationWindow() override = default;
void set_original_rect(Gfx::IntRect original_rect) { m_original_rect = original_rect; };
void set_text(const String&);
void set_title(const String&);
void set_image(const Gfx::ShareableBitmap&);
void set_text(String const&);
void set_title(String const&);
void set_image(Gfx::ShareableBitmap const&);
static RefPtr<NotificationWindow> get_window_by_id(i32 id);
@ -29,7 +29,7 @@ protected:
virtual void leave_event(Core::Event&) override;
private:
NotificationWindow(i32 client_id, const String& text, const String& title, const Gfx::ShareableBitmap&);
NotificationWindow(i32 client_id, String const& text, String const& title, Gfx::ShareableBitmap const&);
virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override;

View file

@ -17,7 +17,7 @@ GeminiProtocol::GeminiProtocol()
{
}
OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, const String&, const URL& url, const HashMap<String, String>&, ReadonlyBytes)
OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, String const&, const URL& url, HashMap<String, String> const&, ReadonlyBytes)
{
Gemini::GeminiRequest request;
request.set_url(url);

View file

@ -15,7 +15,7 @@ public:
GeminiProtocol();
virtual ~GeminiProtocol() override = default;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>&, ReadonlyBytes body) override;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const&, ReadonlyBytes body) override;
};
}

View file

@ -61,7 +61,7 @@ void init(TSelf* self, TJob job)
}
template<typename TBadgedProtocol, typename TPipeResult>
OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body, TPipeResult&& pipe_result)
OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, String const& method, const URL& url, HashMap<String, String> const& headers, ReadonlyBytes body, TPipeResult&& pipe_result)
{
using TJob = typename TBadgedProtocol::Type::JobType;
using TRequest = typename TBadgedProtocol::Type::RequestType;

View file

@ -22,7 +22,7 @@ HttpProtocol::HttpProtocol()
{
}
OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body)
OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, String const& method, const URL& url, HashMap<String, String> const& headers, ReadonlyBytes body)
{
return Detail::start_request(Badge<HttpProtocol> {}, client, method, url, headers, body, get_pipe_for_request());
}

View file

@ -27,7 +27,7 @@ public:
HttpProtocol();
~HttpProtocol() override = default;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const& headers, ReadonlyBytes body) override;
};
}

View file

@ -22,7 +22,7 @@ HttpsProtocol::HttpsProtocol()
{
}
OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body)
OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, String const& method, const URL& url, HashMap<String, String> const& headers, ReadonlyBytes body)
{
return Detail::start_request(Badge<HttpsProtocol> {}, client, method, url, headers, body, get_pipe_for_request());
}

View file

@ -27,7 +27,7 @@ public:
HttpsProtocol();
~HttpsProtocol() override = default;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const& headers, ReadonlyBytes body) override;
};
}

View file

@ -19,12 +19,12 @@ static HashMap<String, Protocol*>& all_protocols()
return map;
}
Protocol* Protocol::find_by_name(const String& name)
Protocol* Protocol::find_by_name(String const& name)
{
return all_protocols().get(name).value_or(nullptr);
}
Protocol::Protocol(const String& name)
Protocol::Protocol(String const& name)
{
all_protocols().set(name, this);
}

View file

@ -16,13 +16,13 @@ class Protocol {
public:
virtual ~Protocol();
const String& name() const { return m_name; }
virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) = 0;
String const& name() const { return m_name; }
virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const& headers, ReadonlyBytes body) = 0;
static Protocol* find_by_name(const String&);
static Protocol* find_by_name(String const&);
protected:
explicit Protocol(const String& name);
explicit Protocol(String const& name);
struct Pipe {
int read_fd { -1 };
int write_fd { -1 };

View file

@ -24,7 +24,7 @@ void Request::stop()
m_client.did_finish_request({}, *this, false);
}
void Request::set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers)
void Request::set_response_headers(HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers)
{
m_response_headers = response_headers;
m_client.did_receive_headers({}, *this);

View file

@ -26,7 +26,7 @@ public:
Optional<u32> status_code() const { return m_status_code; }
Optional<u32> total_size() const { return m_total_size; }
size_t downloaded_size() const { return m_downloaded_size; }
const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers() const { return m_response_headers; }
HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
void stop();
virtual void set_certificate(String, String);
@ -39,9 +39,9 @@ public:
void did_progress(Optional<u32> total_size, u32 downloaded_size);
void set_status_code(u32 status_code) { m_status_code = status_code; }
void did_request_certificates();
void set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>&);
void set_response_headers(HashMap<String, String, CaseInsensitiveStringTraits> const&);
void set_downloaded_size(size_t size) { m_downloaded_size = size; }
const Core::Stream::File& output_stream() const { return *m_output_stream; }
Core::Stream::File const& output_stream() const { return *m_output_stream; }
protected:
explicit Request(ConnectionFromClient&, NonnullOwnPtr<Core::Stream::File>&&);

View file

@ -41,7 +41,7 @@ SpiceAgent::SpiceAgent(int fd, ConnectionToClipboardServer& connection)
send_message(buffer);
}
Optional<SpiceAgent::ClipboardType> SpiceAgent::mime_type_to_clipboard_type(const String& mime)
Optional<SpiceAgent::ClipboardType> SpiceAgent::mime_type_to_clipboard_type(String const& mime)
{
if (mime == "text/plain")
return ClipboardType::Text;
@ -120,7 +120,7 @@ void SpiceAgent::on_message_received()
auto type = (ClipboardType)clipboard_message->type;
auto data_buffer = ByteBuffer::create_uninitialized(message->size - sizeof(u32)).release_value_but_fixme_should_propagate_errors(); // FIXME: Handle possible OOM situation.
const auto total_bytes = message->size - sizeof(Clipboard);
auto const total_bytes = message->size - sizeof(Clipboard);
auto bytes_copied = header.size - sizeof(Message) - sizeof(Clipboard);
memcpy(data_buffer.data(), clipboard_message->data, bytes_copied);
@ -206,7 +206,7 @@ SpiceAgent::Message* SpiceAgent::initialize_headers(u8* data, size_t additional_
return message;
}
ByteBuffer SpiceAgent::AnnounceCapabilities::make_buffer(bool request, const Vector<Capability>& capabilities)
ByteBuffer SpiceAgent::AnnounceCapabilities::make_buffer(bool request, Vector<Capability> const& capabilities)
{
size_t required_size = sizeof(ChunkHeader) + sizeof(Message) + sizeof(AnnounceCapabilities);
auto buffer = ByteBuffer::create_uninitialized(required_size).release_value_but_fixme_should_propagate_errors(); // FIXME: Handle possible OOM situation.
@ -226,7 +226,7 @@ ByteBuffer SpiceAgent::AnnounceCapabilities::make_buffer(bool request, const Vec
return buffer;
}
ByteBuffer SpiceAgent::ClipboardGrab::make_buffer(const Vector<ClipboardType>& types)
ByteBuffer SpiceAgent::ClipboardGrab::make_buffer(Vector<ClipboardType> const& types)
{
VERIFY(types.size() > 0);
size_t variable_data_size = sizeof(u32) * types.size();

View file

@ -92,7 +92,7 @@ public:
u32 request;
u32 caps[CAPABILITIES_SIZE];
static ByteBuffer make_buffer(bool request, const Vector<Capability>& capabilities);
static ByteBuffer make_buffer(bool request, Vector<Capability> const& capabilities);
};
struct [[gnu::packed]] ClipboardGrab {
@ -120,9 +120,9 @@ private:
ConnectionToClipboardServer& m_clipboard_connection;
void on_message_received();
void send_message(const ByteBuffer& buffer);
void send_message(ByteBuffer const& buffer);
bool m_just_set_clip { false };
void read_n(void* dest, size_t n);
static Message* initialize_headers(u8* data, size_t additional_data_size, MessageType type);
static Optional<ClipboardType> mime_type_to_clipboard_type(const String& mime);
static Optional<ClipboardType> mime_type_to_clipboard_type(String const& mime);
};

View file

@ -61,7 +61,7 @@ void Service::setup_socket(SocketDescriptor& socket)
auto un = un_optional.value();
// FIXME: Propagate errors
MUST(Core::System::bind(socket_fd, (const sockaddr*)&un, sizeof(un)));
MUST(Core::System::bind(socket_fd, (sockaddr const*)&un, sizeof(un)));
// FIXME: Propagate errors
MUST(Core::System::listen(socket_fd, 16));
}
@ -270,7 +270,7 @@ void Service::did_exit(int exit_code)
activate();
}
Service::Service(const Core::ConfigFile& config, StringView name)
Service::Service(Core::ConfigFile const& config, StringView name)
: Core::Object(nullptr)
{
VERIFY(config.has_group(name));

View file

@ -27,7 +27,7 @@ public:
void save_to(JsonObject&);
private:
Service(const Core::ConfigFile&, StringView name);
Service(Core::ConfigFile const&, StringView name);
void spawn(int socket_fd = -1);

View file

@ -85,14 +85,14 @@ static ErrorOr<void> determine_system_mode()
return {};
}
static void chown_wrapper(const char* path, uid_t uid, gid_t gid)
static void chown_wrapper(char const* path, uid_t uid, gid_t gid)
{
int rc = chown(path, uid, gid);
if (rc < 0 && errno != ENOENT) {
VERIFY_NOT_REACHED();
}
}
static void chmod_wrapper(const char* path, mode_t mode)
static void chmod_wrapper(char const* path, mode_t mode)
{
int rc = chmod(path, mode);
if (rc < 0 && errno != ENOENT) {

View file

@ -169,11 +169,11 @@ void ClockWidget::paint_event(GUI::PaintEvent& event)
// Render string center-left aligned, but attempt to center the string based on a constant
// "ideal" time string (i.e., the same one used to size this widget in the initializer).
// This prevents the rest of the string from shifting around while seconds tick.
const Gfx::Font& font = Gfx::FontDatabase::default_font();
const int frame_width = frame_thickness();
const int ideal_width = m_time_width;
const int widget_width = max_width();
const int translation_x = (widget_width - ideal_width) / 2 - frame_width;
Gfx::Font const& font = Gfx::FontDatabase::default_font();
int const frame_width = frame_thickness();
int const ideal_width = m_time_width;
int const widget_width = max_width();
int const translation_x = (widget_width - ideal_width) / 2 - frame_width;
painter.draw_text(frame_inner_rect().translated(translation_x, frame_width), time_text, font, Gfx::TextAlignment::CenterLeft, palette().window_text());
}

View file

@ -23,7 +23,7 @@ struct Option {
bool default_action;
};
static const Vector<Option> options = {
static Vector<Option> const options = {
{ "Power off computer", { "/bin/shutdown", "--now", nullptr }, true, true },
{ "Reboot", { "/bin/reboot", nullptr }, true, false },
{ "Log out", { "/bin/logout", nullptr }, true, false },

View file

@ -14,7 +14,7 @@
#include <LibGfx/Palette.h>
#include <LibGfx/StylePainter.h>
TaskbarButton::TaskbarButton(const WindowIdentifier& identifier)
TaskbarButton::TaskbarButton(WindowIdentifier const& identifier)
: m_identifier(identifier)
{
}
@ -49,7 +49,7 @@ void TaskbarButton::resize_event(GUI::ResizeEvent& event)
return GUI::Button::resize_event(event);
}
static void paint_custom_progressbar(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::IntRect& text_rect, const Palette& palette, int min, int max, int value, StringView text, const Gfx::Font& font, Gfx::TextAlignment text_alignment)
static void paint_custom_progressbar(GUI::Painter& painter, Gfx::IntRect const& rect, Gfx::IntRect const& text_rect, Palette const& palette, int min, int max, int value, StringView text, Gfx::Font const& font, Gfx::TextAlignment text_alignment)
{
float range_size = max - min;
float progress = (value - min) / range_size;

View file

@ -18,7 +18,7 @@ public:
void clear_taskbar_rect();
private:
explicit TaskbarButton(const WindowIdentifier&);
explicit TaskbarButton(WindowIdentifier const&);
virtual void context_menu_event(GUI::ContextMenuEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;

View file

@ -104,9 +104,9 @@ void TaskbarWindow::show_desktop_button_clicked(unsigned)
GUI::ConnectionToWindowMangerServer::the().async_toggle_show_desktop();
}
void TaskbarWindow::on_screen_rects_change(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index)
void TaskbarWindow::on_screen_rects_change(Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index)
{
const auto& rect = rects[main_screen_index];
auto const& rect = rects[main_screen_index];
Gfx::IntRect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
set_rect(new_rect);
update_applet_area();
@ -123,7 +123,7 @@ void TaskbarWindow::update_applet_area()
GUI::ConnectionToWindowMangerServer::the().async_set_applet_area_position(new_rect.location());
}
NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier)
NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(WindowIdentifier const& identifier)
{
auto& button = m_task_button_container->add<TaskbarButton>(identifier);
button.set_min_size(20, 21);
@ -133,7 +133,7 @@ NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier&
return button;
}
void TaskbarWindow::add_window_button(::Window& window, const WindowIdentifier& identifier)
void TaskbarWindow::add_window_button(::Window& window, WindowIdentifier const& identifier)
{
if (window.button())
return;
@ -200,7 +200,7 @@ void TaskbarWindow::event(Core::Event& event)
// we adjust it so that the nearest button ends up being clicked anyways.
auto& mouse_event = static_cast<GUI::MouseEvent&>(event);
const int ADJUSTMENT = 4;
int const ADJUSTMENT = 4;
auto adjusted_x = AK::clamp(mouse_event.x(), ADJUSTMENT, width() - ADJUSTMENT);
auto adjusted_y = AK::min(mouse_event.y(), height() - ADJUSTMENT);
Gfx::IntPoint adjusted_point = { adjusted_x, adjusted_y };

View file

@ -27,9 +27,9 @@ private:
explicit TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu);
static void show_desktop_button_clicked(unsigned);
void set_quick_launch_button_data(GUI::Button&, String const&, NonnullRefPtr<Desktop::AppFile>);
void on_screen_rects_change(const Vector<Gfx::IntRect, 4>&, size_t);
NonnullRefPtr<GUI::Button> create_button(const WindowIdentifier&);
void add_window_button(::Window&, const WindowIdentifier&);
void on_screen_rects_change(Vector<Gfx::IntRect, 4> const&, size_t);
NonnullRefPtr<GUI::Button> create_button(WindowIdentifier const&);
void add_window_button(::Window&, WindowIdentifier const&);
void remove_window_button(::Window&, bool);
void update_window_button(::Window&, bool);
::Window* find_window_owner(::Window&) const;

View file

@ -20,7 +20,7 @@ public:
int client_id() const { return m_client_id; }
int window_id() const { return m_window_id; }
bool operator==(const WindowIdentifier& other) const
bool operator==(WindowIdentifier const& other) const
{
return m_client_id == other.m_client_id && m_window_id == other.m_window_id;
}
@ -38,6 +38,6 @@ private:
namespace AK {
template<>
struct Traits<WindowIdentifier> : public GenericTraits<WindowIdentifier> {
static unsigned hash(const WindowIdentifier& w) { return pair_int_hash(w.client_id(), w.window_id()); }
static unsigned hash(WindowIdentifier const& w) { return pair_int_hash(w.client_id(), w.window_id()); }
};
}

View file

@ -12,7 +12,7 @@ WindowList& WindowList::the()
return s_the;
}
Window* WindowList::find_parent(const Window& window)
Window* WindowList::find_parent(Window const& window)
{
if (!window.parent_identifier().is_valid())
return nullptr;
@ -24,7 +24,7 @@ Window* WindowList::find_parent(const Window& window)
return nullptr;
}
Window* WindowList::window(const WindowIdentifier& identifier)
Window* WindowList::window(WindowIdentifier const& identifier)
{
auto it = m_windows.find(identifier);
if (it != m_windows.end())
@ -32,7 +32,7 @@ Window* WindowList::window(const WindowIdentifier& identifier)
return nullptr;
}
Window& WindowList::ensure_window(const WindowIdentifier& identifier)
Window& WindowList::ensure_window(WindowIdentifier const& identifier)
{
auto it = m_windows.find(identifier);
if (it != m_windows.end())
@ -43,7 +43,7 @@ Window& WindowList::ensure_window(const WindowIdentifier& identifier)
return window_ref;
}
void WindowList::remove_window(const WindowIdentifier& identifier)
void WindowList::remove_window(WindowIdentifier const& identifier)
{
m_windows.remove(identifier);
}

View file

@ -14,7 +14,7 @@
class Window {
public:
explicit Window(const WindowIdentifier& identifier)
explicit Window(WindowIdentifier const& identifier)
: m_identifier(identifier)
{
}
@ -25,16 +25,16 @@ public:
m_button->remove_from_parent();
}
const WindowIdentifier& identifier() const { return m_identifier; }
WindowIdentifier const& identifier() const { return m_identifier; }
void set_parent_identifier(const WindowIdentifier& parent_identifier) { m_parent_identifier = parent_identifier; }
const WindowIdentifier& parent_identifier() const { return m_parent_identifier; }
void set_parent_identifier(WindowIdentifier const& parent_identifier) { m_parent_identifier = parent_identifier; }
WindowIdentifier const& parent_identifier() const { return m_parent_identifier; }
String title() const { return m_title; }
void set_title(const String& title) { m_title = title; }
void set_title(String const& title) { m_title = title; }
Gfx::IntRect rect() const { return m_rect; }
void set_rect(const Gfx::IntRect& rect) { m_rect = rect; }
void set_rect(Gfx::IntRect const& rect) { m_rect = rect; }
GUI::Button* button() { return m_button; }
void set_button(GUI::Button* button) { m_button = button; }
@ -67,7 +67,7 @@ public:
Optional<int> progress() const { return m_progress; }
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
Gfx::Bitmap const* icon() const { return m_icon.ptr(); }
private:
WindowIdentifier m_identifier;
@ -95,10 +95,10 @@ public:
callback(*it.value);
}
Window* find_parent(const Window&);
Window* window(const WindowIdentifier&);
Window& ensure_window(const WindowIdentifier&);
void remove_window(const WindowIdentifier&);
Window* find_parent(Window const&);
Window* window(WindowIdentifier const&);
Window& ensure_window(WindowIdentifier const&);
void remove_window(WindowIdentifier const&);
private:
HashMap<WindowIdentifier, NonnullOwnPtr<Window>> m_windows;

View file

@ -156,14 +156,14 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu()
app_category_menus.set(category, category_menu);
};
for (const auto& category : sorted_app_categories) {
for (auto const& category : sorted_app_categories) {
if (category != "Settings"sv)
create_category_menu(category);
}
// Then we create and insert all the app menu items into the right place.
int app_identifier = 0;
for (const auto& app : g_apps) {
for (auto const& app : g_apps) {
if (app.category == "Settings"sv) {
++app_identifier;
continue;

View file

@ -39,7 +39,7 @@ Client::Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd
}
};
m_parser.on_command = [this](const Command& command) {
m_parser.on_command = [this](Command const& command) {
auto result = handle_command(command);
if (result.is_error()) {
dbgln("Failed to handle the command: {}", result.error());
@ -110,7 +110,7 @@ void Client::handle_data(StringView data)
write(m_ptm_fd, data.characters_without_null_termination(), data.length());
}
ErrorOr<void> Client::handle_command(const Command& command)
ErrorOr<void> Client::handle_command(Command const& command)
{
switch (command.command) {
case CMD_DO:

View file

@ -17,7 +17,7 @@
class Parser {
public:
Function<void(const Command&)> on_command;
Function<void(Command const&)> on_command;
Function<void(StringView)> on_data;
Function<void()> on_error;
@ -31,7 +31,7 @@ protected:
Error,
};
void write(const String& str);
void write(String const& str);
private:
State m_state { State::Free };

View file

@ -51,12 +51,12 @@ Web::Page& ConnectionFromClient::page()
return m_page_host->page();
}
const Web::Page& ConnectionFromClient::page() const
Web::Page const& ConnectionFromClient::page() const
{
return m_page_host->page();
}
void ConnectionFromClient::update_system_theme(const Core::AnonymousBuffer& theme_buffer)
void ConnectionFromClient::update_system_theme(Core::AnonymousBuffer const& theme_buffer)
{
Gfx::set_system_theme(theme_buffer);
auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme_buffer);
@ -69,7 +69,7 @@ void ConnectionFromClient::update_system_fonts(String const& default_font_query,
Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query);
}
void ConnectionFromClient::update_screen_rects(const Vector<Gfx::IntRect>& rects, u32 main_screen)
void ConnectionFromClient::update_screen_rects(Vector<Gfx::IntRect> const& rects, u32 main_screen)
{
m_page_host->set_screen_rects(rects, main_screen);
}
@ -89,19 +89,19 @@ void ConnectionFromClient::load_url(const URL& url)
page().load(url);
}
void ConnectionFromClient::load_html(const String& html, const URL& url)
void ConnectionFromClient::load_html(String const& html, const URL& url)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadHTML: html={}, url={}", html, url);
page().load_html(html, url);
}
void ConnectionFromClient::set_viewport_rect(const Gfx::IntRect& rect)
void ConnectionFromClient::set_viewport_rect(Gfx::IntRect const& rect)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", rect);
m_page_host->set_viewport_rect(rect);
}
void ConnectionFromClient::add_backing_store(i32 backing_store_id, const Gfx::ShareableBitmap& bitmap)
void ConnectionFromClient::add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap const& bitmap)
{
m_backing_stores.set(backing_store_id, *bitmap.bitmap());
}
@ -111,7 +111,7 @@ void ConnectionFromClient::remove_backing_store(i32 backing_store_id)
m_backing_stores.remove(backing_store_id);
}
void ConnectionFromClient::paint(const Gfx::IntRect& content_rect, i32 backing_store_id)
void ConnectionFromClient::paint(Gfx::IntRect const& content_rect, i32 backing_store_id)
{
for (auto& pending_paint : m_pending_paint_requests) {
if (pending_paint.bitmap_id == backing_store_id) {
@ -140,22 +140,22 @@ void ConnectionFromClient::flush_pending_paint_requests()
m_pending_paint_requests.clear();
}
void ConnectionFromClient::mouse_down(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::mouse_down(Gfx::IntPoint const& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers)
{
page().handle_mousedown(position, button, modifiers);
}
void ConnectionFromClient::mouse_move(const Gfx::IntPoint& position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::mouse_move(Gfx::IntPoint const& position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers)
{
page().handle_mousemove(position, buttons, modifiers);
}
void ConnectionFromClient::mouse_up(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::mouse_up(Gfx::IntPoint const& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers)
{
page().handle_mouseup(position, button, modifiers);
}
void ConnectionFromClient::mouse_wheel(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
void ConnectionFromClient::mouse_wheel(Gfx::IntPoint const& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
{
page().handle_mousewheel(position, button, modifiers, wheel_delta_x, wheel_delta_y);
}
@ -170,7 +170,7 @@ void ConnectionFromClient::key_up(i32 key, unsigned int modifiers, u32 code_poin
page().handle_keyup((KeyCode)key, modifiers, code_point);
}
void ConnectionFromClient::debug_request(const String& request, const String& argument)
void ConnectionFromClient::debug_request(String const& request, String const& argument)
{
if (request == "dump-dom-tree") {
if (auto* doc = page().top_level_browsing_context().active_document())
@ -384,7 +384,7 @@ void ConnectionFromClient::initialize_js_console(Badge<PageHost>)
interpreter->global_object().console().set_client(*m_console_client.ptr());
}
void ConnectionFromClient::js_console_input(const String& js_source)
void ConnectionFromClient::js_console_input(String const& js_source)
{
if (m_console_client)
m_console_client->handle_input(js_source);

View file

@ -35,7 +35,7 @@ private:
explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
Web::Page& page();
const Web::Page& page() const;
Web::Page const& page() const;
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
virtual void update_system_fonts(String const&, String const&) override;

View file

@ -50,7 +50,7 @@ Gfx::Palette PageHost::palette() const
return Gfx::Palette(*m_palette_impl);
}
void PageHost::set_palette_impl(const Gfx::PaletteImpl& impl)
void PageHost::set_palette_impl(Gfx::PaletteImpl const& impl)
{
m_palette_impl = impl;
}
@ -75,7 +75,7 @@ Web::Layout::InitialContainingBlock* PageHost::layout_root()
return document->layout_node();
}
void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target)
void PageHost::paint(Gfx::IntRect const& content_rect, Gfx::Bitmap& target)
{
Gfx::Painter painter(target);
Gfx::IntRect bitmap_rect { {}, content_rect.size() };
@ -96,7 +96,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target)
layout_root->paint_all_phases(context);
}
void PageHost::set_viewport_rect(const Gfx::IntRect& rect)
void PageHost::set_viewport_rect(Gfx::IntRect const& rect)
{
page().top_level_browsing_context().set_viewport_rect(rect);
}
@ -130,7 +130,7 @@ void PageHost::page_did_layout()
m_client.async_did_layout(content_size);
}
void PageHost::page_did_change_title(const String& title)
void PageHost::page_did_change_title(String const& title)
{
m_client.async_did_change_title(title);
}
@ -145,12 +145,12 @@ void PageHost::page_did_request_scroll_to(Gfx::IntPoint const& scroll_position)
m_client.async_did_request_scroll_to(scroll_position);
}
void PageHost::page_did_request_scroll_into_view(const Gfx::IntRect& rect)
void PageHost::page_did_request_scroll_into_view(Gfx::IntRect const& rect)
{
m_client.async_did_request_scroll_into_view(rect);
}
void PageHost::page_did_enter_tooltip_area(const Gfx::IntPoint& content_position, const String& title)
void PageHost::page_did_enter_tooltip_area(Gfx::IntPoint const& content_position, String const& title)
{
m_client.async_did_enter_tooltip_area(content_position, title);
}
@ -170,12 +170,12 @@ void PageHost::page_did_unhover_link()
m_client.async_did_unhover_link();
}
void PageHost::page_did_click_link(const URL& url, const String& target, unsigned modifiers)
void PageHost::page_did_click_link(const URL& url, String const& target, unsigned modifiers)
{
m_client.async_did_click_link(url, target, modifiers);
}
void PageHost::page_did_middle_click_link(const URL& url, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers)
void PageHost::page_did_middle_click_link(const URL& url, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers)
{
m_client.async_did_middle_click_link(url, target, modifiers);
}
@ -193,17 +193,17 @@ void PageHost::page_did_finish_loading(const URL& url)
m_client.async_did_finish_loading(url);
}
void PageHost::page_did_request_context_menu(const Gfx::IntPoint& content_position)
void PageHost::page_did_request_context_menu(Gfx::IntPoint const& content_position)
{
m_client.async_did_request_context_menu(content_position);
}
void PageHost::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const URL& url, const String& target, unsigned modifiers)
void PageHost::page_did_request_link_context_menu(Gfx::IntPoint const& content_position, const URL& url, String const& target, unsigned modifiers)
{
m_client.async_did_request_link_context_menu(content_position, url, target, modifiers);
}
void PageHost::page_did_request_alert(const String& message)
void PageHost::page_did_request_alert(String const& message)
{
auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestAlert>(message);
if (!response) {
@ -212,7 +212,7 @@ void PageHost::page_did_request_alert(const String& message)
}
}
bool PageHost::page_did_request_confirm(const String& message)
bool PageHost::page_did_request_confirm(String const& message)
{
auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestConfirm>(message);
if (!response) {
@ -222,7 +222,7 @@ bool PageHost::page_did_request_confirm(const String& message)
return response->take_result();
}
String PageHost::page_did_request_prompt(const String& message, const String& default_)
String PageHost::page_did_request_prompt(String const& message, String const& default_)
{
auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestPrompt>(message, default_);
if (!response) {
@ -232,12 +232,12 @@ String PageHost::page_did_request_prompt(const String& message, const String& de
return response->take_response();
}
void PageHost::page_did_change_favicon(const Gfx::Bitmap& favicon)
void PageHost::page_did_change_favicon(Gfx::Bitmap const& favicon)
{
m_client.async_did_change_favicon(favicon.to_shareable_bitmap());
}
void PageHost::page_did_request_image_context_menu(const Gfx::IntPoint& content_position, const URL& url, const String& target, unsigned modifiers, const Gfx::Bitmap* bitmap_pointer)
void PageHost::page_did_request_image_context_menu(Gfx::IntPoint const& content_position, const URL& url, String const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer)
{
auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap();
m_client.async_did_request_image_context_menu(content_position, url, target, modifiers, bitmap);
@ -253,7 +253,7 @@ String PageHost::page_did_request_cookie(const URL& url, Web::Cookie::Source sou
return response->take_cookie();
}
void PageHost::page_did_set_cookie(const URL& url, const Web::Cookie::ParsedCookie& cookie, Web::Cookie::Source source)
void PageHost::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)
{
m_client.async_did_set_cookie(url, cookie, static_cast<u8>(source));
}

View file

@ -22,13 +22,13 @@ public:
virtual ~PageHost() = default;
Web::Page& page() { return *m_page; }
const Web::Page& page() const { return *m_page; }
Web::Page const& page() const { return *m_page; }
void paint(const Gfx::IntRect& content_rect, Gfx::Bitmap&);
void paint(Gfx::IntRect const& content_rect, Gfx::Bitmap&);
void set_palette_impl(const Gfx::PaletteImpl&);
void set_viewport_rect(const Gfx::IntRect&);
void set_screen_rects(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index]; };
void set_palette_impl(Gfx::PaletteImpl const&);
void set_viewport_rect(Gfx::IntRect const&);
void set_screen_rects(Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index]; };
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
void set_should_show_line_box_borders(bool b) { m_should_show_line_box_borders = b; }
@ -40,31 +40,31 @@ private:
virtual Gfx::Palette palette() const override;
virtual Gfx::IntRect screen_rect() const override { return m_screen_rect; }
virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override { return m_preferred_color_scheme; }
virtual void page_did_invalidate(const Gfx::IntRect&) override;
virtual void page_did_invalidate(Gfx::IntRect const&) override;
virtual void page_did_change_selection() override;
virtual void page_did_request_cursor_change(Gfx::StandardCursor) override;
virtual void page_did_layout() override;
virtual void page_did_change_title(const String&) override;
virtual void page_did_change_title(String const&) override;
virtual void page_did_request_scroll(i32, i32) override;
virtual void page_did_request_scroll_to(Gfx::IntPoint const&) override;
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override;
virtual void page_did_request_scroll_into_view(Gfx::IntRect const&) override;
virtual void page_did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override;
virtual void page_did_leave_tooltip_area() override;
virtual void page_did_hover_link(const URL&) override;
virtual void page_did_unhover_link() override;
virtual void page_did_click_link(const URL&, const String& target, unsigned modifiers) override;
virtual void page_did_middle_click_link(const URL&, const String& target, unsigned modifiers) override;
virtual void page_did_request_context_menu(const Gfx::IntPoint&) override;
virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override;
virtual void page_did_click_link(const URL&, String const& target, unsigned modifiers) override;
virtual void page_did_middle_click_link(const URL&, String const& target, unsigned modifiers) override;
virtual void page_did_request_context_menu(Gfx::IntPoint const&) override;
virtual void page_did_request_link_context_menu(Gfx::IntPoint const&, const URL&, String const& target, unsigned modifiers) override;
virtual void page_did_start_loading(const URL&) override;
virtual void page_did_finish_loading(const URL&) override;
virtual void page_did_request_alert(const String&) override;
virtual bool page_did_request_confirm(const String&) override;
virtual String page_did_request_prompt(const String&, const String&) override;
virtual void page_did_change_favicon(const Gfx::Bitmap&) override;
virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers, const Gfx::Bitmap*) override;
virtual void page_did_request_alert(String const&) override;
virtual bool page_did_request_confirm(String const&) override;
virtual String page_did_request_prompt(String const&, String const&) override;
virtual void page_did_change_favicon(Gfx::Bitmap const&) override;
virtual void page_did_request_image_context_menu(Gfx::IntPoint const&, const URL&, String const& target, unsigned modifiers, Gfx::Bitmap const*) override;
virtual String page_did_request_cookie(const URL&, Web::Cookie::Source) override;
virtual void page_did_set_cookie(const URL&, const Web::Cookie::ParsedCookie&, Web::Cookie::Source) override;
virtual void page_did_set_cookie(const URL&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override;
virtual void page_did_update_resource_count(i32) override;
explicit PageHost(ConnectionFromClient&);

View file

@ -31,7 +31,7 @@ AppletManager& AppletManager::the()
return *s_the;
}
void AppletManager::set_position(const Gfx::IntPoint& position)
void AppletManager::set_position(Gfx::IntPoint const& position)
{
m_window->move_to(position);
m_window->set_visible(true);
@ -169,7 +169,7 @@ void AppletManager::draw()
}
}
void AppletManager::draw_applet(const Window& applet)
void AppletManager::draw_applet(Window const& applet)
{
if (!applet.backing_store())
return;
@ -181,7 +181,7 @@ void AppletManager::draw_applet(const Window& applet)
painter.blit(applet.rect_in_applet_area().location(), *applet.backing_store(), applet.backing_store()->rect());
}
void AppletManager::invalidate_applet(const Window& applet, const Gfx::IntRect&)
void AppletManager::invalidate_applet(Window const& applet, Gfx::IntRect const&)
{
draw_applet(applet);
draw();

View file

@ -23,13 +23,13 @@ public:
void add_applet(Window& applet);
void remove_applet(Window& applet);
void draw();
void invalidate_applet(const Window& applet, const Gfx::IntRect& rect);
void invalidate_applet(Window const& applet, Gfx::IntRect const& rect);
void relayout();
void set_position(const Gfx::IntPoint&);
void set_position(Gfx::IntPoint const&);
Window* window() { return m_window; }
const Window* window() const { return m_window; }
Window const* window() const { return m_window; }
void did_change_theme();
@ -37,7 +37,7 @@ private:
AppletManager();
void repaint();
void draw_applet(const Window& applet);
void draw_applet(Window const& applet);
void set_hovered_applet(Window*);
Vector<WeakPtr<Window>> m_applets;

View file

@ -38,7 +38,7 @@ void Button::paint(Screen& screen, Gfx::Painter& painter)
}
}
void Button::on_mouse_event(const MouseEvent& event)
void Button::on_mouse_event(MouseEvent const& event)
{
auto interesting_button = false;

View file

@ -25,14 +25,14 @@ public:
~Button();
Gfx::IntRect relative_rect() const { return m_relative_rect; }
void set_relative_rect(const Gfx::IntRect& rect) { m_relative_rect = rect; }
void set_relative_rect(Gfx::IntRect const& rect) { m_relative_rect = rect; }
Gfx::IntRect rect() const { return { {}, m_relative_rect.size() }; }
Gfx::IntRect screen_rect() const;
void paint(Screen&, Gfx::Painter&);
void on_mouse_event(const MouseEvent&);
void on_mouse_event(MouseEvent const&);
Function<void(Button&)> on_click;
Function<void(Button&)> on_secondary_click;
@ -40,7 +40,7 @@ public:
bool is_visible() const { return m_visible; }
void set_icon(const RefPtr<MultiScaleBitmaps>& icon) { m_icon = icon; }
void set_icon(RefPtr<MultiScaleBitmaps> const& icon) { m_icon = icon; }
private:
WindowFrame& m_frame;

View file

@ -30,7 +30,7 @@ Compositor& Compositor::the()
return s_the;
}
static WallpaperMode mode_to_enum(const String& name)
static WallpaperMode mode_to_enum(String const& name)
{
if (name == "tile")
return WallpaperMode::Tile;
@ -66,14 +66,14 @@ Compositor::Compositor()
init_bitmaps();
}
const Gfx::Bitmap* Compositor::cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const
Gfx::Bitmap const* Compositor::cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const
{
if (!m_current_cursor)
return nullptr;
return &m_current_cursor->bitmap(screen.scale_factor());
}
const Gfx::Bitmap& Compositor::front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const
Gfx::Bitmap const& Compositor::front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const
{
return *screen.compositor_screen_data().m_front_bitmap;
}
@ -255,7 +255,7 @@ void Compositor::compose()
bool need_to_draw_cursor = false;
Gfx::IntRect previous_cursor_rect;
Screen* previous_cursor_screen = nullptr;
auto check_restore_cursor_back = [&](Screen& screen, const Gfx::IntRect& rect) {
auto check_restore_cursor_back = [&](Screen& screen, Gfx::IntRect const& rect) {
if (&screen == &cursor_screen && !previous_cursor_screen && !need_to_draw_cursor && rect.intersects(cursor_rect)) {
// Restore what's behind the cursor if anything touches the area of the cursor
need_to_draw_cursor = true;
@ -274,7 +274,7 @@ void Compositor::compose()
m_current_cursor_screen = &cursor_screen;
}
auto prepare_rect = [&](Screen& screen, const Gfx::IntRect& rect) {
auto prepare_rect = [&](Screen& screen, Gfx::IntRect const& rect) {
auto& screen_data = screen.compositor_screen_data();
dbgln_if(COMPOSE_DEBUG, " -> flush opaque: {}", rect);
VERIFY(!screen_data.m_flush_rects.intersects(rect));
@ -284,7 +284,7 @@ void Compositor::compose()
check_restore_cursor_back(screen, rect);
};
auto prepare_transparency_rect = [&](Screen& screen, const Gfx::IntRect& rect) {
auto prepare_transparency_rect = [&](Screen& screen, Gfx::IntRect const& rect) {
auto& screen_data = screen.compositor_screen_data();
dbgln_if(COMPOSE_DEBUG, " -> flush transparent: {}", rect);
VERIFY(!screen_data.m_flush_rects.intersects(rect));
@ -301,7 +301,7 @@ void Compositor::compose()
if (!cursor_screen.compositor_screen_data().m_cursor_back_bitmap || m_invalidated_cursor)
check_restore_cursor_back(cursor_screen, cursor_rect);
auto paint_wallpaper = [&](Screen& screen, Gfx::Painter& painter, const Gfx::IntRect& rect, const Gfx::IntRect& screen_rect) {
auto paint_wallpaper = [&](Screen& screen, Gfx::Painter& painter, Gfx::IntRect const& rect, Gfx::IntRect const& screen_rect) {
// FIXME: If the wallpaper is opaque and covers the whole rect, no need to fill with color!
painter.fill_rect(rect, background_color);
if (m_wallpaper) {
@ -728,7 +728,7 @@ void Compositor::invalidate_screen()
invalidate_screen(Screen::bounding_rect());
}
void Compositor::invalidate_screen(const Gfx::IntRect& screen_rect)
void Compositor::invalidate_screen(Gfx::IntRect const& screen_rect)
{
m_dirty_screen_rects.add(screen_rect.intersected(Screen::bounding_rect()));
@ -773,7 +773,7 @@ void Compositor::start_compose_async_timer()
}
}
bool Compositor::set_background_color(const String& background_color)
bool Compositor::set_background_color(String const& background_color)
{
auto color = Color::from_string(background_color);
if (!color.has_value())
@ -791,7 +791,7 @@ bool Compositor::set_background_color(const String& background_color)
return succeeded;
}
bool Compositor::set_wallpaper_mode(const String& mode)
bool Compositor::set_wallpaper_mode(String const& mode)
{
auto& wm = WindowManager::the();
wm.config()->write_entry("Background", "Mode", mode);
@ -856,7 +856,7 @@ void Compositor::invalidate_cursor(bool compose_immediately)
start_compose_async_timer();
}
void Compositor::change_cursor(const Cursor* cursor)
void Compositor::change_cursor(Cursor const* cursor)
{
if (m_current_cursor == cursor)
return;
@ -935,7 +935,7 @@ void Compositor::remove_overlay(Overlay& overlay)
overlay_rects_changed();
}
void CompositorScreenData::draw_cursor(Screen& screen, const Gfx::IntRect& cursor_rect)
void CompositorScreenData::draw_cursor(Screen& screen, Gfx::IntRect const& cursor_rect)
{
auto& wm = WindowManager::the();

View file

@ -58,7 +58,7 @@ struct CompositorScreenData {
void init_bitmaps(Compositor&, Screen&);
void flip_buffers(Screen&);
void draw_cursor(Screen&, const Gfx::IntRect&);
void draw_cursor(Screen&, Gfx::IntRect const&);
bool restore_cursor_back(Screen&, Gfx::IntRect&);
template<typename F>
@ -96,22 +96,22 @@ public:
void compose();
void invalidate_window();
void invalidate_screen();
void invalidate_screen(const Gfx::IntRect&);
void invalidate_screen(Gfx::IntRect const&);
void invalidate_screen(Gfx::DisjointRectSet const&);
void screen_resolution_changed();
bool set_background_color(const String& background_color);
bool set_background_color(String const& background_color);
bool set_wallpaper_mode(const String& mode);
bool set_wallpaper_mode(String const& mode);
bool set_wallpaper(RefPtr<Gfx::Bitmap>);
RefPtr<Gfx::Bitmap> wallpaper_bitmap() const { return m_wallpaper; }
void invalidate_cursor(bool = false);
Gfx::IntRect current_cursor_rect() const;
const Cursor* current_cursor() const { return m_current_cursor; }
void current_cursor_was_reloaded(const Cursor* new_cursor) { m_current_cursor = new_cursor; }
Cursor const* current_cursor() const { return m_current_cursor; }
void current_cursor_was_reloaded(Cursor const* new_cursor) { m_current_cursor = new_cursor; }
void increment_display_link_count(Badge<ConnectionFromClient>);
void decrement_display_link_count(Badge<ConnectionFromClient>);
@ -174,8 +174,8 @@ public:
void did_construct_window_manager(Badge<WindowManager>);
const Gfx::Bitmap* cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const;
const Gfx::Bitmap& front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const;
Gfx::Bitmap const* cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const;
Gfx::Bitmap const& front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const;
Gfx::Color color_at_position(Badge<ConnectionFromClient>, Screen&, Gfx::IntPoint const&) const;
void register_animation(Badge<Animation>, Animation&);
@ -202,7 +202,7 @@ private:
void start_compose_async_timer();
void recompute_overlay_rects();
void recompute_occlusions();
void change_cursor(const Cursor*);
void change_cursor(Cursor const*);
void flush(Screen&);
Gfx::IntPoint window_transition_offset(Window&);
void update_animations(Screen&, Gfx::DisjointRectSet& flush_rects);
@ -230,7 +230,7 @@ private:
WallpaperMode m_wallpaper_mode { WallpaperMode::Unchecked };
RefPtr<Gfx::Bitmap> m_wallpaper;
const Cursor* m_current_cursor { nullptr };
Cursor const* m_current_cursor { nullptr };
Screen* m_current_cursor_screen { nullptr };
unsigned m_current_cursor_frame { 0 };
RefPtr<Core::Timer> m_cursor_timer;

View file

@ -53,7 +53,7 @@ public:
return nullptr;
return menu.value();
}
const Menu* find_menu_by_id(int menu_id) const
Menu const* find_menu_by_id(int menu_id) const
{
auto menu = m_menus.get(menu_id);
if (!menu.has_value())

View file

@ -20,8 +20,8 @@ public:
static RefPtr<Cursor> create(Gfx::StandardCursor);
~Cursor() = default;
const Gfx::CursorParams& params() const { return m_params; }
const Gfx::Bitmap& bitmap(int scale_factor) const
Gfx::CursorParams const& params() const { return m_params; }
Gfx::Bitmap const& bitmap(int scale_factor) const
{
auto it = m_bitmaps.find(scale_factor);
if (it == m_bitmaps.end()) {
@ -47,7 +47,7 @@ public:
private:
Cursor() = default;
Cursor(NonnullRefPtr<Gfx::Bitmap>&&, int, const Gfx::CursorParams&);
Cursor(NonnullRefPtr<Gfx::Bitmap>&&, int, Gfx::CursorParams const&);
bool load(StringView, StringView);
void update_rect_if_animated();

View file

@ -88,7 +88,7 @@ private:
class MouseEvent final : public Event {
public:
MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x = 0, int wheel_delta_y = 0, int wheel_raw_delta_x = 0, int wheel_raw_delta_y = 0)
MouseEvent(Type type, Gfx::IntPoint const& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x = 0, int wheel_delta_y = 0, int wheel_raw_delta_x = 0, int wheel_raw_delta_y = 0)
: Event(type)
, m_position(position)
, m_buttons(buttons)
@ -101,7 +101,7 @@ public:
{
}
const Gfx::IntPoint& position() const { return m_position; }
Gfx::IntPoint const& position() const { return m_position; }
int x() const { return m_position.x(); }
int y() const { return m_position.y(); }
MouseButton button() const { return m_button; }
@ -121,7 +121,7 @@ public:
}
void set_drag(bool b) { m_drag = b; }
void set_mime_data(const Core::MimeData& mime_data) { m_mime_data = mime_data; }
void set_mime_data(Core::MimeData const& mime_data) { m_mime_data = mime_data; }
MouseEvent translated(Gfx::IntPoint const& delta) const
{
@ -145,13 +145,13 @@ private:
class ResizeEvent final : public Event {
public:
ResizeEvent(const Gfx::IntRect& rect)
ResizeEvent(Gfx::IntRect const& rect)
: Event(Event::WindowResized)
, m_rect(rect)
{
}
const Gfx::IntRect& rect() const { return m_rect; }
Gfx::IntRect const& rect() const { return m_rect; }
private:
Gfx::IntRect m_rect;

View file

@ -67,7 +67,7 @@ void KeymapSwitcher::next_keymap()
dbgln("Current system keymap: {}", current_keymap_name);
auto it = m_keymaps.find_if([&](const auto& enumerator) {
auto it = m_keymaps.find_if([&](auto const& enumerator) {
return enumerator == current_keymap_name;
});
@ -102,7 +102,7 @@ String KeymapSwitcher::get_current_keymap() const
void KeymapSwitcher::setkeymap(const AK::String& keymap)
{
pid_t child_pid;
const char* argv[] = { "/bin/keymap", "-m", keymap.characters(), nullptr };
char const* argv[] = { "/bin/keymap", "-m", keymap.characters(), nullptr };
if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
dbgln("Failed to call /bin/keymap, error: {} ({})", errno, strerror(errno));

View file

@ -38,7 +38,7 @@ private:
RefPtr<Core::FileWatcher> m_file_watcher;
const char* m_keyboard_config = "/etc/Keyboard.ini";
char const* m_keyboard_config = "/etc/Keyboard.ini";
};
}

View file

@ -47,7 +47,7 @@ Menu::Menu(ConnectionFromClient* client, int menu_id, String name)
m_alt_shortcut_character = find_ampersand_shortcut_character(m_name);
}
const Gfx::Font& Menu::font() const
Gfx::Font const& Menu::font() const
{
return Gfx::FontDatabase::default_font();
}
@ -332,7 +332,7 @@ void Menu::descend_into_submenu_at_hovered_item()
VERIFY(submenu->hovered_item()->type() != MenuItem::Separator);
}
void Menu::handle_mouse_move_event(const MouseEvent& mouse_event)
void Menu::handle_mouse_move_event(MouseEvent const& mouse_event)
{
VERIFY(menu_window());
MenuManager::the().set_current_menu(this);
@ -357,7 +357,7 @@ void Menu::handle_mouse_move_event(const MouseEvent& mouse_event)
void Menu::event(Core::Event& event)
{
if (event.type() == Event::MouseMove) {
handle_mouse_move_event(static_cast<const MouseEvent&>(event));
handle_mouse_move_event(static_cast<MouseEvent const&>(event));
return;
}
@ -368,7 +368,7 @@ void Menu::event(Core::Event& event)
if (event.type() == Event::MouseWheel && is_scrollable()) {
VERIFY(menu_window());
auto& mouse_event = static_cast<const MouseEvent&>(event);
auto& mouse_event = static_cast<MouseEvent const&>(event);
auto previous_scroll_offset = m_scroll_offset;
m_scroll_offset += mouse_event.wheel_delta_y();
m_scroll_offset = clamp(m_scroll_offset, 0, m_max_scroll_offset);
@ -402,7 +402,7 @@ void Menu::event(Core::Event& event)
} else {
// Default to the first enabled, non-separator item on key press if one has not been selected yet
int counter = 0;
for (const auto& item : m_items) {
for (auto const& item : m_items) {
if (item.type() != MenuItem::Separator && item.is_enabled()) {
set_hovered_index(counter, key == Key_Right);
break;
@ -567,7 +567,7 @@ bool Menu::remove_item_with_identifier(unsigned identifier)
return m_items.remove_first_matching([&](auto& item) { return item->identifier() == identifier; });
}
int Menu::item_index_at(const Gfx::IntPoint& position)
int Menu::item_index_at(Gfx::IntPoint const& position)
{
int i = 0;
for (auto& item : m_items) {
@ -589,12 +589,12 @@ void Menu::redraw_if_theme_changed()
redraw();
}
void Menu::popup(const Gfx::IntPoint& position)
void Menu::popup(Gfx::IntPoint const& position)
{
do_popup(position, true);
}
void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_submenu)
void Menu::do_popup(Gfx::IntPoint const& position, bool make_input, bool as_submenu)
{
if (is_empty()) {
dbgln("Menu: Empty menu popup");
@ -605,7 +605,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_subm
auto& window = ensure_menu_window(position);
redraw_if_theme_changed();
const int margin = 30;
int const margin = 30;
Gfx::IntPoint adjusted_pos = position;
if (adjusted_pos.x() + window.width() > screen.rect().right() - margin) {
@ -624,7 +624,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_subm
WindowManager::the().did_popup_a_menu({});
}
bool Menu::is_menu_ancestor_of(const Menu& other) const
bool Menu::is_menu_ancestor_of(Menu const& other) const
{
for (auto& item : m_items) {
if (!item.is_submenu())
@ -657,7 +657,7 @@ void Menu::add_item(NonnullOwnPtr<MenuItem> item)
m_items.append(move(item));
}
const Vector<size_t>* Menu::items_with_alt_shortcut(u32 alt_shortcut) const
Vector<size_t> const* Menu::items_with_alt_shortcut(u32 alt_shortcut) const
{
auto it = m_alt_shortcut_character_to_item_indices.find(to_ascii_lowercase(alt_shortcut));
if (it == m_alt_shortcut_character_to_item_indices.end())

View file

@ -31,7 +31,7 @@ public:
virtual ~Menu() override = default;
ConnectionFromClient* client() { return m_client; }
const ConnectionFromClient* client() const { return m_client; }
ConnectionFromClient const* client() const { return m_client; }
int menu_id() const { return m_menu_id; }
bool is_open() const;
@ -40,7 +40,7 @@ public:
bool is_empty() const { return m_items.is_empty(); }
size_t item_count() const { return m_items.size(); }
const MenuItem& item(size_t index) const { 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)
@ -72,7 +72,7 @@ public:
}
Gfx::IntRect rect_in_window_menubar() const { return m_rect_in_window_menubar; }
void set_rect_in_window_menubar(const Gfx::IntRect& rect) { m_rect_in_window_menubar = rect; }
void set_rect_in_window_menubar(Gfx::IntRect const& rect) { m_rect_in_window_menubar = rect; }
Window* menu_window() { return m_menu_window.ptr(); }
Window& ensure_menu_window(Gfx::IntPoint const&);
@ -94,7 +94,7 @@ public:
void draw();
void draw(MenuItem const&, bool = false);
const Gfx::Font& font() const;
Gfx::Font const& font() const;
MenuItem* item_with_identifier(unsigned);
bool remove_item_with_identifier(unsigned);
@ -113,10 +113,10 @@ public:
void set_visible(bool);
void popup(const Gfx::IntPoint&);
void do_popup(const Gfx::IntPoint&, bool make_input, bool as_submenu = false);
void popup(Gfx::IntPoint const&);
void do_popup(Gfx::IntPoint const&, bool make_input, bool as_submenu = false);
bool is_menu_ancestor_of(const Menu&) const;
bool is_menu_ancestor_of(Menu const&) const;
void redraw_if_theme_changed();
@ -126,18 +126,18 @@ public:
void descend_into_submenu_at_hovered_item();
void open_hovered_item(bool leave_menu_open);
const Vector<size_t>* items_with_alt_shortcut(u32 alt_shortcut) const;
Vector<size_t> const* items_with_alt_shortcut(u32 alt_shortcut) const;
private:
Menu(ConnectionFromClient*, int menu_id, String name);
virtual void event(Core::Event&) override;
void handle_mouse_move_event(const MouseEvent&);
void handle_mouse_move_event(MouseEvent const&);
size_t visible_item_count() const;
Gfx::IntRect stripe_rect();
int item_index_at(const Gfx::IntPoint&);
int item_index_at(Gfx::IntPoint const&);
static constexpr int padding_between_text_and_shortcut() { return 50; }
void did_activate(MenuItem&, bool leave_menu_open);
void update_for_new_hovered_item(bool make_input = false);

View file

@ -12,7 +12,7 @@
namespace WindowServer {
MenuItem::MenuItem(Menu& menu, unsigned identifier, const String& text, const String& shortcut_text, bool enabled, bool checkable, bool checked, const Gfx::Bitmap* icon)
MenuItem::MenuItem(Menu& menu, unsigned identifier, String const& text, String const& shortcut_text, bool enabled, bool checkable, bool checked, Gfx::Bitmap const* icon)
: m_menu(menu)
, m_type(Text)
, m_enabled(enabled)
@ -62,7 +62,7 @@ Menu* MenuItem::submenu()
return m_menu.client()->find_menu_by_id(m_submenu_id);
}
const Menu* MenuItem::submenu() const
Menu const* MenuItem::submenu() const
{
VERIFY(is_submenu());
VERIFY(m_menu.client());
@ -76,7 +76,7 @@ Gfx::IntRect MenuItem::rect() const
return m_rect.translated(0, m_menu.item_height() - (m_menu.scroll_offset() * m_menu.item_height()));
}
void MenuItem::set_icon(const Gfx::Bitmap* icon)
void MenuItem::set_icon(Gfx::Bitmap const* icon)
{
if (m_icon == icon)
return;

View file

@ -23,7 +23,7 @@ public:
Separator,
};
MenuItem(Menu&, unsigned identifier, const String& text, const String& shortcut_text = {}, bool enabled = true, bool checkable = false, bool checked = false, const Gfx::Bitmap* icon = nullptr);
MenuItem(Menu&, unsigned identifier, String const& text, String const& shortcut_text = {}, bool enabled = true, bool checkable = false, bool checked = false, Gfx::Bitmap const* icon = nullptr);
MenuItem(Menu&, Type);
~MenuItem() = default;
@ -47,20 +47,20 @@ public:
String shortcut_text() const { return m_shortcut_text; }
void set_shortcut_text(String text) { m_shortcut_text = move(text); }
void set_rect(const Gfx::IntRect& rect) { m_rect = rect; }
void set_rect(Gfx::IntRect const& rect) { m_rect = rect; }
Gfx::IntRect rect() const;
unsigned identifier() const { return m_identifier; }
const Gfx::Bitmap* icon() const { return m_icon; }
void set_icon(const Gfx::Bitmap*);
Gfx::Bitmap const* icon() const { return m_icon; }
void set_icon(Gfx::Bitmap const*);
bool is_submenu() const { return m_submenu_id != -1; }
int submenu_id() const { return m_submenu_id; }
void set_submenu_id(int submenu_id) { m_submenu_id = submenu_id; }
Menu* submenu();
const Menu* submenu() const;
Menu const* submenu() const;
bool is_exclusive() const { return m_exclusive; }
void set_exclusive(bool exclusive) { m_exclusive = exclusive; }

View file

@ -26,7 +26,7 @@ MenuManager::MenuManager()
s_the = this;
}
bool MenuManager::is_open(const Menu& menu) const
bool MenuManager::is_open(Menu const& menu) const
{
for (size_t i = 0; i < m_open_menu_stack.size(); ++i) {
if (&menu == m_open_menu_stack[i].ptr())
@ -55,7 +55,7 @@ void MenuManager::event(Core::Event& event)
}
if (static_cast<Event&>(event).is_key_event()) {
auto& key_event = static_cast<const KeyEvent&>(event);
auto& key_event = static_cast<KeyEvent const&>(event);
if (key_event.type() == Event::KeyUp && key_event.key() == Key_Escape) {
close_everyone();
@ -85,7 +85,7 @@ void MenuManager::event(Core::Event& event)
if (event.type() == Event::KeyDown) {
if (key_event.key() == Key_Left) {
auto it = m_open_menu_stack.find_if([&](const auto& other) { return m_current_menu == other.ptr(); });
auto it = m_open_menu_stack.find_if([&](auto const& other) { return m_current_menu == other.ptr(); });
VERIFY(!it.is_end());
// Going "back" a menu should be the previous menu in the stack

View file

@ -22,7 +22,7 @@ public:
virtual ~MenuManager() override = default;
bool is_open(const Menu&) const;
bool is_open(Menu const&) const;
bool has_open_menu() const { return !m_open_menu_stack.is_empty(); }
Menu* current_menu() { return m_current_menu.ptr(); }

View file

@ -9,7 +9,7 @@
namespace WindowServer {
const Gfx::Bitmap& MultiScaleBitmaps::bitmap(int scale_factor) const
Gfx::Bitmap const& MultiScaleBitmaps::bitmap(int scale_factor) const
{
auto it = m_bitmaps.find(scale_factor);
if (it == m_bitmaps.end()) {

View file

@ -184,10 +184,10 @@ public:
private:
Gfx::IntSize m_content_size;
const int m_rows;
const int m_columns;
const int m_target_row;
const int m_target_column;
int const m_rows;
int const m_columns;
int const m_target_row;
int const m_target_column;
};
}

View file

@ -43,7 +43,7 @@ Screen& ScreenInput::cursor_location_screen()
return *screen;
}
const Screen& ScreenInput::cursor_location_screen() const
Screen const& ScreenInput::cursor_location_screen() const
{
auto* screen = Screen::find_by_location(m_cursor_location);
VERIFY(screen);
@ -271,7 +271,7 @@ void Screen::scale_factor_changed()
constrain_pending_flush_rects();
}
Screen& Screen::closest_to_rect(const Gfx::IntRect& rect)
Screen& Screen::closest_to_rect(Gfx::IntRect const& rect)
{
Screen* best_screen = nullptr;
int best_area = 0;
@ -290,7 +290,7 @@ Screen& Screen::closest_to_rect(const Gfx::IntRect& rect)
return *best_screen;
}
Screen& Screen::closest_to_location(const Gfx::IntPoint& point)
Screen& Screen::closest_to_location(Gfx::IntPoint const& point)
{
for (auto& screen : s_screens) {
if (screen.rect().contains(point))
@ -421,7 +421,7 @@ void ScreenInput::set_scroll_step_size(unsigned step_size)
m_scroll_step_size = step_size;
}
void ScreenInput::on_receive_mouse_data(const MousePacket& packet)
void ScreenInput::on_receive_mouse_data(MousePacket const& packet)
{
auto& current_screen = cursor_location_screen();
auto prev_location = m_cursor_location;

View file

@ -35,7 +35,7 @@ public:
static ScreenInput& the();
Screen& cursor_location_screen();
const Screen& cursor_location_screen() const;
Screen const& cursor_location_screen() const;
unsigned mouse_button_state() const { return m_mouse_button_state; }
double acceleration_factor() const { return m_acceleration_factor; }
@ -44,7 +44,7 @@ public:
unsigned scroll_step_size() const { return m_scroll_step_size; }
void set_scroll_step_size(unsigned);
void on_receive_mouse_data(const MousePacket&);
void on_receive_mouse_data(MousePacket const&);
void on_receive_keyboard_data(::KeyEvent);
Gfx::IntPoint cursor_location() const { return m_cursor_location; }
@ -80,7 +80,7 @@ public:
~Screen();
static bool apply_layout(ScreenLayout&&, String&);
static const ScreenLayout& layout() { return s_layout; }
static ScreenLayout const& layout() { return s_layout; }
static Screen& main()
{
@ -88,8 +88,8 @@ public:
return *s_main_screen;
}
static Screen& closest_to_rect(const Gfx::IntRect&);
static Screen& closest_to_location(const Gfx::IntPoint&);
static Screen& closest_to_rect(Gfx::IntRect const&);
static Screen& closest_to_location(Gfx::IntPoint const&);
static Screen* find_by_index(size_t index)
{
@ -106,7 +106,7 @@ public:
return rects;
}
static Screen* find_by_location(const Gfx::IntPoint& point)
static Screen* find_by_location(Gfx::IntPoint const& point)
{
for (auto& screen : s_screens) {
if (screen.rect().contains(point))
@ -115,7 +115,7 @@ public:
return nullptr;
}
static const Gfx::IntRect& bounding_rect() { return s_bounding_screens_rect; }
static Gfx::IntRect const& bounding_rect() { return s_bounding_screens_rect; }
static size_t count() { return s_screens.size(); }
size_t index() const { return m_index; }

View file

@ -28,7 +28,7 @@ public:
return { location, { resolution.width() / scale_factor, resolution.height() / scale_factor } };
}
bool operator==(const Screen&) const = default;
bool operator==(Screen const&) const = default;
};
Vector<Screen> screens;
@ -36,13 +36,13 @@ public:
bool is_valid(String* error_msg = nullptr) const;
bool normalize();
bool load_config(const Core::ConfigFile& config_file, String* error_msg = nullptr);
bool load_config(Core::ConfigFile const& config_file, String* error_msg = nullptr);
bool save_config(Core::ConfigFile& config_file, bool sync = true) const;
bool try_auto_add_framebuffer(String const&);
// TODO: spaceship operator
bool operator!=(const ScreenLayout& other) const;
bool operator==(const ScreenLayout& other) const
bool operator!=(ScreenLayout const& other) const;
bool operator==(ScreenLayout const& other) const
{
return !(*this != other);
}
@ -52,9 +52,9 @@ public:
namespace IPC {
bool encode(Encoder&, const WindowServer::ScreenLayout::Screen&);
bool encode(Encoder&, WindowServer::ScreenLayout::Screen const&);
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout::Screen&);
bool encode(Encoder&, const WindowServer::ScreenLayout&);
bool encode(Encoder&, WindowServer::ScreenLayout const&);
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout&);
}

View file

@ -137,7 +137,7 @@ void Window::destroy()
set_visible(false);
}
void Window::set_title(const String& title)
void Window::set_title(String const& title)
{
if (m_title == title)
return;
@ -146,7 +146,7 @@ void Window::set_title(const String& title)
WindowManager::the().notify_title_changed(*this);
}
void Window::set_rect(const Gfx::IntRect& rect)
void Window::set_rect(Gfx::IntRect const& rect)
{
if (m_rect == rect)
return;
@ -167,7 +167,7 @@ void Window::set_rect(const Gfx::IntRect& rect)
invalidate_last_rendered_screen_rects();
}
void Window::set_rect_without_repaint(const Gfx::IntRect& rect)
void Window::set_rect_without_repaint(Gfx::IntRect const& rect)
{
VERIFY(!rect.is_empty());
if (m_rect == rect)
@ -246,7 +246,7 @@ void Window::nudge_into_desktop(Screen* target_screen, bool force_titlebar_visib
set_rect(new_window_rect);
}
void Window::set_minimum_size(const Gfx::IntSize& size)
void Window::set_minimum_size(Gfx::IntSize const& size)
{
if (size.is_null())
return;
@ -261,7 +261,7 @@ void Window::set_minimum_size(const Gfx::IntSize& size)
m_minimum_size = size;
}
void Window::handle_mouse_event(const MouseEvent& event)
void Window::handle_mouse_event(MouseEvent const& event)
{
set_automatic_cursor_tracking_enabled(event.buttons() != 0);
@ -357,7 +357,7 @@ void Window::set_closeable(bool closeable)
update_window_menu_items();
}
void Window::set_taskbar_rect(const Gfx::IntRect& rect)
void Window::set_taskbar_rect(Gfx::IntRect const& rect)
{
m_taskbar_rect = rect;
m_have_taskbar_rect = !m_taskbar_rect.is_empty();
@ -536,7 +536,7 @@ void Window::event(Core::Event& event)
}
if (static_cast<Event&>(event).is_mouse_event())
return handle_mouse_event(static_cast<const MouseEvent&>(event));
return handle_mouse_event(static_cast<MouseEvent const&>(event));
switch (event.type()) {
case Event::WindowEntered:
@ -546,14 +546,14 @@ void Window::event(Core::Event& event)
m_client->async_window_left(m_window_id);
break;
case Event::KeyDown:
handle_keydown_event(static_cast<const KeyEvent&>(event));
handle_keydown_event(static_cast<KeyEvent const&>(event));
break;
case Event::KeyUp:
m_client->async_key_up(m_window_id,
(u32) static_cast<const KeyEvent&>(event).code_point(),
(u32) static_cast<const KeyEvent&>(event).key(),
static_cast<const KeyEvent&>(event).modifiers(),
(u32) static_cast<const KeyEvent&>(event).scancode());
(u32) static_cast<KeyEvent const&>(event).code_point(),
(u32) static_cast<KeyEvent const&>(event).key(),
static_cast<KeyEvent const&>(event).modifiers(),
(u32) static_cast<KeyEvent const&>(event).scancode());
break;
case Event::WindowActivated:
m_client->async_window_activated(m_window_id);
@ -571,14 +571,14 @@ void Window::event(Core::Event& event)
m_client->async_window_close_request(m_window_id);
break;
case Event::WindowResized:
m_client->async_window_resized(m_window_id, static_cast<const ResizeEvent&>(event).rect());
m_client->async_window_resized(m_window_id, static_cast<ResizeEvent const&>(event).rect());
break;
default:
break;
}
}
void Window::handle_keydown_event(const KeyEvent& event)
void Window::handle_keydown_event(KeyEvent const& event)
{
if (event.modifiers() == Mod_Alt && event.key() == Key_Space && type() == WindowType::Normal && !is_frameless()) {
auto position = frame().titlebar_rect().bottom_left().translated(frame().rect().location());
@ -661,7 +661,7 @@ void Window::invalidate(Gfx::IntRect const& rect, bool invalidate_frame)
Compositor::the().invalidate_window();
}
bool Window::invalidate_no_notify(const Gfx::IntRect& rect, bool invalidate_frame)
bool Window::invalidate_no_notify(Gfx::IntRect const& rect, bool invalidate_frame)
{
if (rect.is_empty())
return false;
@ -764,7 +764,7 @@ void Window::set_default_icon()
m_icon = default_window_icon();
}
void Window::request_update(const Gfx::IntRect& rect, bool ignore_occlusion)
void Window::request_update(Gfx::IntRect const& rect, bool ignore_occlusion)
{
if (rect.is_empty())
return;
@ -865,7 +865,7 @@ void Window::handle_window_menu_action(WindowMenuAction action)
}
}
void Window::popup_window_menu(const Gfx::IntPoint& position, WindowMenuDefaultAction default_action)
void Window::popup_window_menu(Gfx::IntPoint const& position, WindowMenuDefaultAction default_action)
{
ensure_window_menu();
if (default_action == WindowMenuDefaultAction::BasedOnWindowState) {

View file

@ -88,7 +88,7 @@ public:
bool is_modified() const { return m_modified; }
void set_modified(bool);
void popup_window_menu(const Gfx::IntPoint&, WindowMenuDefaultAction);
void popup_window_menu(Gfx::IntPoint const&, WindowMenuDefaultAction);
void handle_window_menu_action(WindowMenuAction);
void window_menu_activate_default();
void request_close();
@ -139,12 +139,12 @@ public:
}
WindowFrame& frame() { return m_frame; }
const WindowFrame& frame() const { return m_frame; }
WindowFrame const& frame() const { return m_frame; }
Window* blocking_modal_window();
ConnectionFromClient* client() { return m_client; }
const ConnectionFromClient* client() const { return m_client; }
ConnectionFromClient const* client() const { return m_client; }
WindowType type() const { return m_type; }
int window_id() const { return m_window_id; }
@ -153,7 +153,7 @@ public:
i32 client_id() const { return m_client_id; }
String title() const { return m_title; }
void set_title(const String&);
void set_title(String const&);
String computed_title() const;
@ -170,7 +170,7 @@ public:
m_alpha_hit_threshold = threshold;
}
Optional<HitTestResult> hit_test(const Gfx::IntPoint&, bool include_frame = true);
Optional<HitTestResult> hit_test(Gfx::IntPoint const&, bool include_frame = true);
int x() const { return m_rect.x(); }
int y() const { return m_rect.y(); }
@ -186,34 +186,34 @@ public:
bool is_modal_dont_unparent() const { return m_modal && m_parent_window; }
Gfx::IntRect rect() const { return m_rect; }
void set_rect(const Gfx::IntRect&);
void set_rect(Gfx::IntRect const&);
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
void set_rect_without_repaint(const Gfx::IntRect&);
void set_rect_without_repaint(Gfx::IntRect const&);
bool apply_minimum_size(Gfx::IntRect&);
void nudge_into_desktop(Screen*, bool force_titlebar_visible = true);
Gfx::IntSize minimum_size() const { return m_minimum_size; }
void set_minimum_size(const Gfx::IntSize&);
void set_minimum_size(Gfx::IntSize const&);
void set_minimum_size(int width, int height) { set_minimum_size({ width, height }); }
void set_taskbar_rect(const Gfx::IntRect&);
const Gfx::IntRect& taskbar_rect() const { return m_taskbar_rect; }
void set_taskbar_rect(Gfx::IntRect const&);
Gfx::IntRect const& taskbar_rect() const { return m_taskbar_rect; }
void move_to(const Gfx::IntPoint& position) { set_rect({ position, size() }); }
void move_to(Gfx::IntPoint const& position) { set_rect({ position, size() }); }
void move_to(int x, int y) { move_to({ x, y }); }
void move_by(const Gfx::IntPoint& delta) { set_position_without_repaint(position().translated(delta)); }
void move_by(Gfx::IntPoint const& delta) { set_position_without_repaint(position().translated(delta)); }
Gfx::IntPoint position() const { return m_rect.location(); }
void set_position(const Gfx::IntPoint& position) { set_rect({ position.x(), position.y(), width(), height() }); }
void set_position_without_repaint(const Gfx::IntPoint& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }
void set_position(Gfx::IntPoint const& position) { set_rect({ position.x(), position.y(), width(), height() }); }
void set_position_without_repaint(Gfx::IntPoint const& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }
Gfx::IntSize size() const { return m_rect.size(); }
void invalidate(bool with_frame = true, bool re_render_frame = false);
void invalidate(Gfx::IntRect const&, bool invalidate_frame = false);
void invalidate_menubar();
bool invalidate_no_notify(const Gfx::IntRect& rect, bool invalidate_frame = false);
bool invalidate_no_notify(Gfx::IntRect const& rect, bool invalidate_frame = false);
void invalidate_last_rendered_screen_rects();
void invalidate_last_rendered_screen_rects_now();
[[nodiscard]] bool should_invalidate_last_rendered_screen_rects() { return exchange(m_invalidate_last_render_rects, false); }
@ -225,10 +225,10 @@ public:
Gfx::DisjointRectSet& dirty_rects() { return m_dirty_rects; }
// Only used by WindowType::Applet. Perhaps it could be a Window subclass? I don't know.
void set_rect_in_applet_area(const Gfx::IntRect& rect) { m_rect_in_applet_area = rect; }
const Gfx::IntRect& rect_in_applet_area() const { return m_rect_in_applet_area; }
void set_rect_in_applet_area(Gfx::IntRect const& rect) { m_rect_in_applet_area = rect; }
Gfx::IntRect const& rect_in_applet_area() const { return m_rect_in_applet_area; }
const Gfx::Bitmap* backing_store() const { return m_backing_store.ptr(); }
Gfx::Bitmap const* backing_store() const { return m_backing_store.ptr(); }
Gfx::Bitmap* backing_store() { return m_backing_store.ptr(); }
void set_backing_store(RefPtr<Gfx::Bitmap> backing_store, i32 serial)
@ -257,10 +257,10 @@ public:
void set_has_alpha_channel(bool value);
Gfx::IntSize size_increment() const { return m_size_increment; }
void set_size_increment(const Gfx::IntSize& increment) { m_size_increment = increment; }
void set_size_increment(Gfx::IntSize const& increment) { m_size_increment = increment; }
const Optional<Gfx::IntSize>& resize_aspect_ratio() const { return m_resize_aspect_ratio; }
void set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio)
Optional<Gfx::IntSize> const& resize_aspect_ratio() const { return m_resize_aspect_ratio; }
void set_resize_aspect_ratio(Optional<Gfx::IntSize> const& ratio)
{
// "Tiled" means that we take up a chunk of space relative to the screen.
// The screen can change, so "tiled" and "fixed aspect ratio" are mutually exclusive.
@ -272,19 +272,19 @@ public:
}
Gfx::IntSize base_size() const { return m_base_size; }
void set_base_size(const Gfx::IntSize& size) { m_base_size = size; }
void set_base_size(Gfx::IntSize const& size) { m_base_size = size; }
const Gfx::Bitmap& icon() const { return *m_icon; }
Gfx::Bitmap const& icon() const { return *m_icon; }
void set_icon(NonnullRefPtr<Gfx::Bitmap>&& icon) { m_icon = move(icon); }
void set_default_icon();
const Cursor* cursor() const { return (m_cursor_override ? m_cursor_override : m_cursor).ptr(); }
Cursor const* cursor() const { return (m_cursor_override ? m_cursor_override : m_cursor).ptr(); }
void set_cursor(RefPtr<Cursor> cursor) { m_cursor = move(cursor); }
void set_cursor_override(RefPtr<Cursor> cursor) { m_cursor_override = move(cursor); }
void remove_cursor_override() { m_cursor_override = nullptr; }
void request_update(const Gfx::IntRect&, bool ignore_occlusion = false);
void request_update(Gfx::IntRect const&, bool ignore_occlusion = false);
Gfx::DisjointRectSet take_pending_paint_rects() { return move(m_pending_paint_rects); }
bool has_taskbar_rect() const { return m_have_taskbar_rect; };
@ -299,15 +299,15 @@ public:
void detach_client(Badge<ConnectionFromClient>);
Window* parent_window() { return m_parent_window; }
const Window* parent_window() const { return m_parent_window; }
Window const* parent_window() const { return m_parent_window; }
void set_parent_window(Window&);
Vector<WeakPtr<Window>>& child_windows() { return m_child_windows; }
const Vector<WeakPtr<Window>>& child_windows() const { return m_child_windows; }
Vector<WeakPtr<Window>> const& child_windows() const { return m_child_windows; }
Vector<WeakPtr<Window>>& accessory_windows() { return m_accessory_windows; }
const Vector<WeakPtr<Window>>& accessory_windows() const { return m_accessory_windows; }
Vector<WeakPtr<Window>> const& accessory_windows() const { return m_accessory_windows; }
bool is_descendant_of(Window&) const;
@ -364,7 +364,7 @@ public:
bool is_on_any_window_stack(Badge<WindowStack>) const { return m_window_stack != nullptr; }
void set_window_stack(Badge<WindowStack>, WindowStack* stack) { m_window_stack = stack; }
const Vector<Screen*, default_screen_count>& screens() const { return m_screens; }
Vector<Screen*, default_screen_count> const& screens() const { return m_screens; }
Vector<Screen*, default_screen_count>& screens() { return m_screens; }
void set_moving_to_another_stack(bool value) { m_moving_to_another_stack = value; }
@ -385,8 +385,8 @@ private:
Window(Core::Object&, WindowType);
virtual void event(Core::Event&) override;
void handle_mouse_event(const MouseEvent&);
void handle_keydown_event(const KeyEvent&);
void handle_mouse_event(MouseEvent const&);
void handle_keydown_event(KeyEvent const&);
void add_child_window(Window&);
void add_accessory_window(Window&);
void ensure_window_menu();

View file

@ -52,7 +52,7 @@ static String s_last_menu_shadow_path;
static String s_last_taskbar_shadow_path;
static String s_last_tooltip_shadow_path;
static Gfx::IntRect frame_rect_for_window(Window& window, const Gfx::IntRect& rect)
static Gfx::IntRect frame_rect_for_window(Window& window, Gfx::IntRect const& rect)
{
if (window.is_frameless())
return rect;
@ -148,7 +148,7 @@ void WindowFrame::reload_config()
reload_icon(s_close_icon, "window-close.png", "/res/icons/16x16/window-close.png");
reload_icon(s_close_modified_icon, "window-close-modified.png", "/res/icons/16x16/window-close-modified.png");
auto load_shadow = [](const String& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) {
auto load_shadow = [](String const& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) {
if (path.is_empty()) {
last_path = String::empty();
shadow_bitmap = nullptr;
@ -305,13 +305,13 @@ void WindowFrame::paint_normal_frame(Gfx::Painter& painter)
paint_menubar(painter);
}
void WindowFrame::paint(Screen& screen, Gfx::Painter& painter, const Gfx::IntRect& rect)
void WindowFrame::paint(Screen& screen, Gfx::Painter& painter, Gfx::IntRect const& rect)
{
if (auto* cached = render_to_cache(screen))
cached->paint(*this, painter, rect);
}
void WindowFrame::PerScaleRenderedCache::paint(WindowFrame& frame, Gfx::Painter& painter, const Gfx::IntRect& rect)
void WindowFrame::PerScaleRenderedCache::paint(WindowFrame& frame, Gfx::Painter& painter, Gfx::IntRect const& rect)
{
auto frame_rect = frame.unconstrained_render_rect();
auto window_rect = frame.window().rect();
@ -526,7 +526,7 @@ void WindowFrame::set_opacity(float opacity)
WindowManager::the().notify_opacity_changed(m_window);
}
Gfx::IntRect WindowFrame::inflated_for_shadow(const Gfx::IntRect& frame_rect) const
Gfx::IntRect WindowFrame::inflated_for_shadow(Gfx::IntRect const& frame_rect) const
{
if (auto* shadow = shadow_bitmap()) {
auto total_shadow_size = shadow->default_bitmap().height();
@ -540,7 +540,7 @@ Gfx::IntRect WindowFrame::rect() const
return frame_rect_for_window(m_window, m_window.rect());
}
Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(const Gfx::IntRect& render_rect) const
Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(Gfx::IntRect const& render_rect) const
{
if (m_window.is_tiled())
return render_rect.intersected(Screen::closest_to_rect(rect()).rect());
@ -630,7 +630,7 @@ void WindowFrame::invalidate(Gfx::IntRect relative_rect)
m_window.invalidate(relative_rect, true);
}
void WindowFrame::window_rect_changed(const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect)
void WindowFrame::window_rect_changed(Gfx::IntRect const& old_rect, Gfx::IntRect const& new_rect)
{
layout_buttons();
@ -810,7 +810,7 @@ void WindowFrame::handle_mouse_event(MouseEvent const& event)
handle_border_mouse_event(event);
}
void WindowFrame::handle_border_mouse_event(const MouseEvent& event)
void WindowFrame::handle_border_mouse_event(MouseEvent const& event)
{
if (!m_window.is_resizable())
return;
@ -838,7 +838,7 @@ void WindowFrame::handle_border_mouse_event(const MouseEvent& event)
wm.start_window_resize(m_window, event.translated(rect().location()));
}
void WindowFrame::handle_menubar_mouse_event(const MouseEvent& event)
void WindowFrame::handle_menubar_mouse_event(MouseEvent const& event)
{
Menu* hovered_menu = nullptr;
auto menubar_rect = this->menubar_rect();
@ -869,7 +869,7 @@ void WindowFrame::open_menubar_menu(Menu& menu)
invalidate(menubar_rect);
}
void WindowFrame::handle_menu_mouse_event(Menu& menu, const MouseEvent& event)
void WindowFrame::handle_menu_mouse_event(Menu& menu, MouseEvent const& event)
{
auto menubar_rect = this->menubar_rect();
bool is_hover_with_any_menu_open = event.type() == MouseEvent::MouseMove && &m_window == WindowManager::the().window_with_active_menu();

View file

@ -29,7 +29,7 @@ public:
friend class WindowFrame;
public:
void paint(WindowFrame&, Gfx::Painter&, const Gfx::IntRect&);
void paint(WindowFrame&, Gfx::Painter&, Gfx::IntRect const&);
void render(WindowFrame&, Screen&);
Optional<HitTestResult> hit_test(WindowFrame&, Gfx::IntPoint const&, Gfx::IntPoint const&);
@ -51,7 +51,7 @@ public:
void window_was_constructed(Badge<Window>);
Window& window() { return m_window; }
const Window& window() const { return m_window; }
Window const& window() const { return m_window; }
Gfx::IntRect rect() const;
Gfx::IntRect render_rect() const;
@ -59,7 +59,7 @@ public:
Gfx::DisjointRectSet opaque_render_rects() const;
Gfx::DisjointRectSet transparent_render_rects() const;
void paint(Screen&, Gfx::Painter&, const Gfx::IntRect&);
void paint(Screen&, Gfx::Painter&, Gfx::IntRect const&);
void render(Screen&, Gfx::Painter&);
PerScaleRenderedCache* render_to_cache(Screen&);
@ -68,7 +68,7 @@ public:
bool handle_titlebar_icon_mouse_event(MouseEvent const&);
void handle_border_mouse_event(MouseEvent const&);
void window_rect_changed(const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect);
void window_rect_changed(Gfx::IntRect const& old_rect, Gfx::IntRect const& new_rect);
void invalidate_titlebar();
void invalidate_menubar();
void invalidate(Gfx::IntRect relative_rect);
@ -125,15 +125,15 @@ private:
void paint_tool_window_frame(Gfx::Painter&);
void paint_menubar(Gfx::Painter&);
MultiScaleBitmaps const* shadow_bitmap() const;
Gfx::IntRect inflated_for_shadow(const Gfx::IntRect&) const;
Gfx::IntRect inflated_for_shadow(Gfx::IntRect const&) const;
void handle_menubar_mouse_event(const MouseEvent&);
void handle_menu_mouse_event(Menu&, const MouseEvent&);
void handle_menubar_mouse_event(MouseEvent const&);
void handle_menu_mouse_event(Menu&, MouseEvent const&);
Gfx::WindowTheme::WindowState window_state_for_theme() const;
String computed_title() const;
Gfx::IntRect constrained_render_rect_to_screen(const Gfx::IntRect&) const;
Gfx::IntRect constrained_render_rect_to_screen(Gfx::IntRect const&) const;
Gfx::IntRect leftmost_titlebar_button_rect() const;
Window& m_window;

View file

@ -774,8 +774,8 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event)
dbgln(" [!] The window is still maximized. Not moving yet.");
}
const int tiling_deadzone = 10;
const int secondary_deadzone = 2;
int const tiling_deadzone = 10;
int const secondary_deadzone = 2;
auto& cursor_screen = Screen::closest_to_location(event.position());
auto desktop = desktop_rect(cursor_screen);
auto desktop_relative_to_screen = desktop.translated(-cursor_screen.rect().location());
@ -869,7 +869,7 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event)
return false;
if (event.type() == Event::MouseMove) {
const int vertical_maximize_deadzone = 5;
int const vertical_maximize_deadzone = 5;
auto& cursor_screen = ScreenInput::the().cursor_location_screen();
if (&cursor_screen == &Screen::closest_to_rect(m_resize_window->rect())) {
auto desktop_rect = this->desktop_rect(cursor_screen);
@ -2225,7 +2225,7 @@ void WindowManager::apply_cursor_theme(String const& theme_name)
auto cursor_theme_config = cursor_theme_config_or_error.release_value();
auto* current_cursor = Compositor::the().current_cursor();
auto reload_cursor = [&](RefPtr<Cursor>& cursor, const String& name) {
auto reload_cursor = [&](RefPtr<Cursor>& cursor, String const& name) {
bool is_current_cursor = current_cursor && current_cursor == cursor.ptr();
static auto const s_default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png";

View file

@ -28,8 +28,8 @@
namespace WindowServer {
const int double_click_speed_max = 900;
const int double_click_speed_min = 100;
int const double_click_speed_max = 900;
int const double_click_speed_min = 100;
class Screen;
class MouseEvent;

View file

@ -85,7 +85,7 @@ void WindowSwitcher::event(Core::Event& event)
event.accept();
}
void WindowSwitcher::on_key_event(const KeyEvent& event)
void WindowSwitcher::on_key_event(KeyEvent const& event)
{
if (event.type() == Event::KeyUp) {
if (event.key() == (m_mode == Mode::ShowAllWindows ? Key_Super : Key_Alt)) {
@ -212,7 +212,7 @@ void WindowSwitcher::draw()
void WindowSwitcher::refresh()
{
auto& wm = WindowManager::the();
const Window* selected_window = nullptr;
Window const* selected_window = nullptr;
if (m_selected_index > 0 && m_windows[m_selected_index])
selected_window = m_windows[m_selected_index].ptr();
if (!selected_window)

View file

@ -38,7 +38,7 @@ public:
}
void hide() { set_visible(false); }
void on_key_event(const KeyEvent&);
void on_key_event(KeyEvent const&);
void refresh();
void refresh_if_needed();