commit b614c5ffff2b35530444446c9ec20b7b821202f5
parent 3be42120afa25b0efb9dcb870422ae5eb757a87f
Author: deurzen <m.deurzen@tum.de>
Date: Tue, 21 Sep 2021 22:33:35 +0200
refactors code
Diffstat:
6 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/src/core/main.cc b/src/core/main.cc
@@ -7,7 +7,7 @@
int
main(int, char **)
{
- XConnection conn = { WM_NAME };
+ XConnection conn{ WM_NAME };
Model model(conn);
model.run();
return 0;
diff --git a/src/core/model.cc b/src/core/model.cc
@@ -710,11 +710,11 @@ Model::Model(Connection& conn)
g_instance = this;
- static const std::vector<std::string> context_names = {
+ static const std::vector<std::string> context_names{
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"
};
- static const std::vector<std::string> workspace_names = {
+ static const std::vector<std::string> workspace_names{
"1:main", "2:web", "3:term", "4", "5", "6", "7", "8", "9", "10"
};
@@ -780,7 +780,7 @@ Model::~Model()
for (std::size_t i = 0; i < m_workspaces.size(); ++i)
delete m_workspaces[i];
- std::unordered_set<Client_ptr> clients = {};
+ std::unordered_set<Client_ptr> clients{};
for (auto [_,client] : m_client_map)
clients.insert(client);
@@ -877,8 +877,7 @@ Model::acquire_partitions()
screen.compute_placeable_region();
- std::vector<Region> workspace_regions
- = { m_workspaces.size(), screen.full_region() };
+ std::vector<Region> workspace_regions(m_workspaces.size(), screen.full_region());
m_conn.set_desktop_geometry(workspace_regions);
m_conn.set_desktop_viewport(workspace_regions);
@@ -928,10 +927,9 @@ Model::search_client(SearchSelector const& selector)
{
return lhs->last_focused < rhs->last_focused;
}
- } last_focused_comparer = {};
+ } last_focused_comparer{};
- static std::set<Client_ptr, LastFocusedComparer> clients
- = {{}, last_focused_comparer};
+ static std::set<Client_ptr, LastFocusedComparer> clients{{}, last_focused_comparer};
clients.clear();
@@ -1265,7 +1263,7 @@ Model::sync_focus()
void
Model::attach_next_client()
{
- static std::atomic<unsigned> count = { 0 };
+ static std::atomic<unsigned> count{ 0 };
static auto attachment_resetter = [&,this]() mutable {
unsigned current = ++count;
@@ -1516,7 +1514,7 @@ Model::render_decoration(Client_ptr client)
void
Model::manage(const Window window, const bool ignore, const bool may_map)
{
- static std::unordered_map<std::string, Rules> default_rules_memoized = {};
+ static std::unordered_map<std::string, Rules> default_rules_memoized{};
std::optional<Region> window_geometry = m_conn.get_window_geometry(window);
@@ -2138,10 +2136,9 @@ Model::apply_stack(Workspace_ptr workspace)
{
return lhs->managed_since < rhs->managed_since;
}
- } managed_since_comparer = {};
+ } managed_since_comparer{};
- static std::set<Client_ptr, ManagedSinceComparer> managed_since_clients
- = {{}, managed_since_comparer};
+ static std::set<Client_ptr, ManagedSinceComparer> managed_since_clients{{}, managed_since_comparer};
managed_since_clients.clear();
@@ -2174,10 +2171,9 @@ Model::apply_stack(Workspace_ptr workspace)
{
return lhs->last_focused < rhs->last_focused;
}
- } last_focused_comparer = {};
+ } last_focused_comparer{};
- static std::set<Client_ptr, LastFocusedComparer> last_focused_clients
- = {{}, last_focused_comparer};
+ static std::set<Client_ptr, LastFocusedComparer> last_focused_clients{{}, last_focused_comparer};
last_focused_clients.clear();
@@ -2899,10 +2895,10 @@ Model::set_iconify_client(Toggle toggle, Client_ptr client)
void
Model::consume_client(Client_ptr producer, Client_ptr client)
{
- static std::unordered_set<std::string> ignored_producers_memoized = {};
- static std::unordered_set<std::string> ignored_consumers_memoized = {};
- static std::unordered_set<std::string> allowed_producers_memoized = {};
- static std::unordered_set<std::string> allowed_consumers_memoized = {};
+ static std::unordered_set<std::string> ignored_producers_memoized{};
+ static std::unordered_set<std::string> ignored_consumers_memoized{};
+ static std::unordered_set<std::string> allowed_producers_memoized{};
+ static std::unordered_set<std::string> allowed_consumers_memoized{};
Workspace_ptr pworkspace = get_workspace(producer->workspace);
Workspace_ptr cworkspace = get_workspace(client->workspace);
@@ -3825,7 +3821,7 @@ Model::handle_placement_request(PlacementRequestEvent event)
client->set_free_region(region);
- Placement placement = {
+ Placement placement{
Placement::PlacementMethod::Free,
client,
client->free_decoration,
@@ -4010,7 +4006,7 @@ Model::handle_screen_change()
void
Model::process_command(winsys::CommandMessage message)
{
- static const std::unordered_map<std::string_view, winsys::Direction> directions = {
+ static const std::unordered_map<std::string_view, winsys::Direction> directions{
{ "Forward", winsys::Direction::Forward },
{ "forward", winsys::Direction::Forward },
{ "fwd", winsys::Direction::Forward },
@@ -4021,7 +4017,7 @@ Model::process_command(winsys::CommandMessage message)
{ "b", winsys::Direction::Backward },
};
- static const std::unordered_map<std::string_view, std::function<void(void)>> commands = {
+ static const std::unordered_map<std::string_view, std::function<void(void)>> commands{
{ "toggle_partition",
[&,this]() {
toggle_partition();
diff --git a/src/core/rules.hh b/src/core/rules.hh
@@ -47,7 +47,7 @@ struct Rules
}
};
- Rules rules = {};
+ Rules rules{};
if (!ignore_prefix && rule.size() <= prefix.size())
return rules;
diff --git a/src/winsys/screen.hh b/src/winsys/screen.hh
@@ -96,7 +96,7 @@ namespace winsys
{
return lhs.width < rhs.width;
}
- } s_strut_comparer = {};
+ } s_strut_comparer{};
std::unordered_map<Window, std::vector<Edge>> m_windows;
std::unordered_map<Edge, std::set<Strut, StrutComparer>> m_struts;
diff --git a/src/winsys/xdata/xconnection.cc b/src/winsys/xdata/xconnection.cc
@@ -252,7 +252,7 @@ XConnection::process_messages(std::function<void(winsys::Message)> callback)
Query
};
- static const std::unordered_map<std::string_view, MessageType> message_types = {
+ static const std::unordered_map<std::string_view, MessageType> message_types{
{ "command", Command },
{ "cmd", Command },
{ "config", Config },
@@ -267,7 +267,7 @@ XConnection::process_messages(std::function<void(winsys::Message)> callback)
};
static int n = 0;
- static char msg[BUFSIZ] = { 0 };
+ static char msg[BUFSIZ] = {};
if (FD_ISSET(m_sock_fd, &m_descr)) {
m_client_fd = accept(m_sock_fd, NULL, 0);
@@ -279,7 +279,7 @@ XConnection::process_messages(std::function<void(winsys::Message)> callback)
if (rply != NULL) {
winsys::Message message = std::monostate{};
- std::deque<std::string> words = {};
+ std::deque<std::string> words{};
std::istringstream word_stream(msg);
std::string word;
@@ -791,7 +791,7 @@ XConnection::grab_bindings(std::vector<winsys::KeyInput>& key_inputs, std::vecto
}
};
- std::vector<std::size_t> modifiers_to_ignore = {
+ std::vector<std::size_t> modifiers_to_ignore{
0,
Mod2Mask,
Mod5Mask
@@ -953,7 +953,7 @@ XConnection::get_window_geometry(winsys::Window window)
std::optional<winsys::Pid>
XConnection::get_window_pid(winsys::Window window)
{
- XResClientIdSpec spec = {
+ XResClientIdSpec spec{
window,
XRES_CLIENT_ID_PID_MASK
};
@@ -1010,7 +1010,7 @@ yield:
bool
XConnection::must_manage_window(winsys::Window window)
{
- static const std::vector<winsys::WindowType> ignore_types = {
+ static const std::vector<winsys::WindowType> ignore_types{
winsys::WindowType::Desktop,
winsys::WindowType::Dock,
winsys::WindowType::Toolbar,
@@ -1034,11 +1034,11 @@ XConnection::must_manage_window(winsys::Window window)
bool
XConnection::must_free_window(winsys::Window window)
{
- static const std::vector<winsys::WindowState> free_states = {
+ static const std::vector<winsys::WindowState> free_states{
winsys::WindowState::Modal
};
- static const std::vector<winsys::WindowType> free_types = {
+ static const std::vector<winsys::WindowType> free_types{
winsys::WindowType::Dialog,
winsys::WindowType::Utility,
};
@@ -1359,7 +1359,7 @@ XConnection::init_for_wm(std::vector<std::string> const& desktop_names)
wa.cursor = XCreateFontCursor(mp_dpy, XC_left_ptr);
XChangeWindowAttributes(mp_dpy, m_root, CWCursor, &wa);
- std::vector<std::string> wm_class = { m_wm_name, m_wm_name };
+ std::vector<std::string> wm_class{ m_wm_name, m_wm_name };
replace_string_property(m_check_window, "_NET_WM_NAME", m_wm_name);
replace_stringlist_property(m_check_window, "_WM_CLASS", wm_class);
@@ -1409,7 +1409,7 @@ XConnection::set_window_state(winsys::Window window, winsys::WindowState state,
return;
if (on) {
- std::vector<winsys::WindowState> check_state = { state };
+ std::vector<winsys::WindowState> check_state{ state };
if (window_is_any_of_states(window, check_state))
return;
@@ -1437,7 +1437,7 @@ XConnection::set_window_state(winsys::Window window, winsys::WindowState state,
void
XConnection::set_window_frame_extents(winsys::Window window, winsys::Extents extents)
{
- std::vector<unsigned long> frame_extents = {
+ std::vector<unsigned long> frame_extents{
static_cast<unsigned>(extents.left),
static_cast<unsigned>(extents.right),
static_cast<unsigned>(extents.top),
@@ -1587,7 +1587,7 @@ XConnection::get_window_types(winsys::Window window)
if (!property_status_ok())
return {};
- std::unordered_set<winsys::WindowType> window_types = {};
+ std::unordered_set<winsys::WindowType> window_types{};
for (Atom atom : window_type_atoms)
window_types.insert(get_window_type_from_atom(atom));
@@ -1603,7 +1603,7 @@ XConnection::get_window_states(winsys::Window window)
if (!property_status_ok())
return {};
- std::unordered_set<winsys::WindowState> window_states = {};
+ std::unordered_set<winsys::WindowState> window_states{};
for (Atom atom : window_state_atoms)
window_states.insert(get_window_state_from_atom(atom));
@@ -1614,8 +1614,9 @@ XConnection::get_window_states(winsys::Window window)
bool
XConnection::window_is_fullscreen(winsys::Window window)
{
- static const std::vector<winsys::WindowState> fullscreen_state
- = { winsys::WindowState::Fullscreen };
+ static const std::vector<winsys::WindowState> fullscreen_state{
+ winsys::WindowState::Fullscreen
+ };
return window_is_any_of_states(window, fullscreen_state);
}
@@ -1623,8 +1624,9 @@ XConnection::window_is_fullscreen(winsys::Window window)
bool
XConnection::window_is_above(winsys::Window window)
{
- static const std::vector<winsys::WindowState> above_state
- = { winsys::WindowState::Above_ };
+ static const std::vector<winsys::WindowState> above_state{
+ winsys::WindowState::Above_
+ };
return window_is_any_of_states(window, above_state);
}
@@ -1632,8 +1634,9 @@ XConnection::window_is_above(winsys::Window window)
bool
XConnection::window_is_below(winsys::Window window)
{
- static const std::vector<winsys::WindowState> below_state
- = { winsys::WindowState::Below_ };
+ static const std::vector<winsys::WindowState> below_state{
+ winsys::WindowState::Below_
+ };
return window_is_any_of_states(window, below_state);
}
@@ -1641,8 +1644,9 @@ XConnection::window_is_below(winsys::Window window)
bool
XConnection::window_is_sticky(winsys::Window window)
{
- static const std::vector<winsys::WindowState> sticky_state
- = { winsys::WindowState::Sticky };
+ static const std::vector<winsys::WindowState> sticky_state{
+ winsys::WindowState::Sticky
+ };
return window_is_any_of_states(window, sticky_state);
}
@@ -2196,7 +2200,7 @@ XConnection::get_atomlist_property(winsys::Window window, std::string const& nam
unsigned long _ul;
unsigned char* ucp = nullptr;
Atom _a = None;
- std::vector<Atom> atomlist = {};
+ std::vector<Atom> atomlist{};
m_property_status = XGetWindowProperty(
mp_dpy,
@@ -2369,7 +2373,7 @@ XConnection::get_windowlist_property(winsys::Window window, std::string const& n
unsigned long _ul;
unsigned char* ucp = nullptr;
Atom _a = None;
- std::vector<winsys::Window> windowlist = {};
+ std::vector<winsys::Window> windowlist{};
m_property_status = XGetWindowProperty(
mp_dpy,
@@ -2464,7 +2468,7 @@ XConnection::get_string_property(winsys::Window window, std::string const& name)
unsigned long _ul;
unsigned char* ucp = nullptr;
Atom _a = None;
- std::string str_ = {};
+ std::string str_{};
m_property_status = XGetWindowProperty(
mp_dpy,
@@ -2542,7 +2546,7 @@ XConnection::get_stringlist_property(winsys::Window window, std::string const& n
unsigned long _ul;
unsigned char* ucp = nullptr;
Atom _a = None;
- std::vector<std::string> stringlist = {};
+ std::vector<std::string> stringlist{};
m_property_status = XGetWindowProperty(
mp_dpy,
@@ -2728,7 +2732,7 @@ XConnection::get_cardlist_property(winsys::Window window, std::string const& nam
unsigned long _ul;
unsigned char* ucp = nullptr;
Atom _a = None;
- std::vector<unsigned long> cardlist = {};
+ std::vector<unsigned long> cardlist{};
m_property_status = XGetWindowProperty(
mp_dpy,
@@ -2950,7 +2954,7 @@ XConnection::on_button_press()
}
};
- std::unordered_set<winsys::Modifier> modifiers = {};
+ std::unordered_set<winsys::Modifier> modifiers{};
for (auto& x11_modifier : x11_modifiers)
if ((event.state & x11_modifier) > 0)
modifiers.insert(x11_to_modifier(x11_modifier));
@@ -3020,7 +3024,7 @@ XConnection::on_button_release()
}
};
- std::unordered_set<winsys::Modifier> modifiers = {};
+ std::unordered_set<winsys::Modifier> modifiers{};
for (auto& x11_modifier : x11_modifiers)
if ((event.state & x11_modifier) > 0)
modifiers.insert(x11_to_modifier(x11_modifier));
@@ -3114,8 +3118,8 @@ XConnection::on_client_message()
}
case NetWMID::NetMoveResizeWindow:
{
- std::optional<winsys::Pos> pos = {};
- std::optional<winsys::Dim> dim = {};
+ std::optional<winsys::Pos> pos{};
+ std::optional<winsys::Dim> dim{};
pos = winsys::Pos {
static_cast<int>(event.data.l[1]),
@@ -3350,7 +3354,7 @@ XConnection::on_key_press()
}
};
- std::unordered_set<winsys::Modifier> modifiers = {};
+ std::unordered_set<winsys::Modifier> modifiers{};
for (auto& x11_modifier : x11_modifiers)
if ((event.state & x11_modifier) != 0)
modifiers.insert(x11_to_modifier(x11_modifier));
@@ -3437,7 +3441,7 @@ XConnection::on_motion_notify()
}
};
- std::unordered_set<winsys::Modifier> modifiers = {};
+ std::unordered_set<winsys::Modifier> modifiers{};
for (auto& x11_modifier : x11_modifiers)
if ((event.state & x11_modifier) != 0)
modifiers.insert(x11_to_modifier(x11_modifier));
diff --git a/src/winsys/xdata/xconnection.hh b/src/winsys/xdata/xconnection.hh
@@ -194,7 +194,7 @@ private:
fd_set m_descr;
char m_sock_path[256];
- char m_state_path[256] = { 0 };
+ char m_state_path[256] = {};
struct sockaddr_un m_sock_addr;
std::string m_wm_name;