Skip to content

Commit

Permalink
WindowServer: Rename WindowManager wm_config() to config()
Browse files Browse the repository at this point in the history
It looked a little silly with all of the callers saying wm.wm
  • Loading branch information
shannonbooth authored and awesomekling committed May 18, 2020
1 parent d3eccf0 commit 195c178
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
12 changes: 6 additions & 6 deletions Services/WindowServer/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Compositor::compose()
{
auto& wm = WindowManager::the();
if (m_wallpaper_mode == WallpaperMode::Unchecked)
m_wallpaper_mode = mode_to_enum(wm.wm_config()->read_entry("Background", "Mode", "simple"));
m_wallpaper_mode = mode_to_enum(wm.config()->read_entry("Background", "Mode", "simple"));
auto& ws = Screen::the();

auto dirty_rects = move(m_dirty_rects);
Expand All @@ -133,7 +133,7 @@ void Compositor::compose()
};

Color background_color = wm.palette().desktop_background();
String background_color_entry = wm.wm_config()->read_entry("Background", "Color", "");
String background_color_entry = wm.config()->read_entry("Background", "Color", "");
if (!background_color_entry.is_empty()) {
background_color = Color::from_string(background_color_entry).value_or(background_color);
}
Expand Down Expand Up @@ -320,8 +320,8 @@ void Compositor::invalidate(const Gfx::Rect& a_rect)
bool Compositor::set_background_color(const String& background_color)
{
auto& wm = WindowManager::the();
wm.wm_config()->write_entry("Background", "Color", background_color);
bool ret_val = wm.wm_config()->sync();
wm.config()->write_entry("Background", "Color", background_color);
bool ret_val = wm.config()->sync();

if (ret_val)
Compositor::invalidate();
Expand All @@ -332,8 +332,8 @@ bool Compositor::set_background_color(const String& background_color)
bool Compositor::set_wallpaper_mode(const String& mode)
{
auto& wm = WindowManager::the();
wm.wm_config()->write_entry("Background", "Mode", mode);
bool ret_val = wm.wm_config()->sync();
wm.config()->write_entry("Background", "Mode", mode);
bool ret_val = wm.config()->sync();

if (ret_val) {
m_wallpaper_mode = mode_to_enum(mode);
Expand Down
28 changes: 14 additions & 14 deletions Services/WindowServer/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ WindowManager::~WindowManager()

NonnullRefPtr<Cursor> WindowManager::get_cursor(const String& name, const Gfx::Point& hotspot)
{
auto path = m_wm_config->read_entry("Cursor", name, "/res/cursors/arrow.png");
auto path = m_config->read_entry("Cursor", name, "/res/cursors/arrow.png");
auto gb = Gfx::Bitmap::load_from_file(path);
if (gb)
return Cursor::create(*gb, hotspot);
Expand All @@ -93,7 +93,7 @@ NonnullRefPtr<Cursor> WindowManager::get_cursor(const String& name, const Gfx::P

NonnullRefPtr<Cursor> WindowManager::get_cursor(const String& name)
{
auto path = m_wm_config->read_entry("Cursor", name, "/res/cursors/arrow.png");
auto path = m_config->read_entry("Cursor", name, "/res/cursors/arrow.png");
auto gb = Gfx::Bitmap::load_from_file(path);

if (gb)
Expand All @@ -103,12 +103,12 @@ NonnullRefPtr<Cursor> WindowManager::get_cursor(const String& name)

void WindowManager::reload_config(bool set_screen)
{
m_wm_config = Core::ConfigFile::open("/etc/WindowServer/WindowServer.ini");
m_config = Core::ConfigFile::open("/etc/WindowServer/WindowServer.ini");

m_double_click_speed = m_wm_config->read_num_entry("Input", "DoubleClickSpeed", 250);
m_double_click_speed = m_config->read_num_entry("Input", "DoubleClickSpeed", 250);

if (set_screen) {
set_resolution(m_wm_config->read_num_entry("Screen", "Width", 1920), m_wm_config->read_num_entry("Screen", "Height", 1080));
set_resolution(m_config->read_num_entry("Screen", "Width", 1920), m_config->read_num_entry("Screen", "Height", 1080));
}

m_arrow_cursor = get_cursor("Arrow", { 2, 2 });
Expand Down Expand Up @@ -148,17 +148,17 @@ bool WindowManager::set_resolution(int width, int height)
return IterationDecision::Continue;
});
}
if (m_wm_config) {
if (m_config) {
if (success) {
dbg() << "Saving resolution: " << Gfx::Size(width, height) << " to config file at " << m_wm_config->file_name();
m_wm_config->write_num_entry("Screen", "Width", width);
m_wm_config->write_num_entry("Screen", "Height", height);
m_wm_config->sync();
dbg() << "Saving resolution: " << Gfx::Size(width, height) << " to config file at " << m_config->file_name();
m_config->write_num_entry("Screen", "Width", width);
m_config->write_num_entry("Screen", "Height", height);
m_config->sync();
} else {
dbg() << "Saving fallback resolution: " << resolution() << " to config file at " << m_wm_config->file_name();
m_wm_config->write_num_entry("Screen", "Width", resolution().width());
m_wm_config->write_num_entry("Screen", "Height", resolution().height());
m_wm_config->sync();
dbg() << "Saving fallback resolution: " << resolution() << " to config file at " << m_config->file_name();
m_config->write_num_entry("Screen", "Width", resolution().width());
m_config->write_num_entry("Screen", "Height", resolution().height());
m_config->sync();
}
}
return success;
Expand Down
7 changes: 2 additions & 5 deletions Services/WindowServer/WindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ class WindowManager : public Core::Object {

Palette palette() const { return Palette(*m_palette); }

RefPtr<Core::ConfigFile> wm_config() const
{
return m_wm_config;
}
RefPtr<Core::ConfigFile> config() const { return m_config; }
void reload_config(bool);

void add_window(Window&);
Expand Down Expand Up @@ -279,7 +276,7 @@ class WindowManager : public Core::Object {

NonnullRefPtr<Gfx::PaletteImpl> m_palette;

RefPtr<Core::ConfigFile> m_wm_config;
RefPtr<Core::ConfigFile> m_config;

WeakPtr<ClientConnection> m_dnd_client;
String m_dnd_text;
Expand Down

0 comments on commit 195c178

Please sign in to comment.