MCPcopy Create free account
hub / github.com/WayfireWM/wayfire / apply

Method apply

plugins/window-rules/window-rules.cpp:96–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void wayfire_window_rules_t::apply(const std::string & signal, wayfire_view view)
97{
98 if (view == nullptr)
99 {
100 return;
101 }
102
103 auto toplevel = toplevel_cast(view);
104 if ((signal == "maximized") && (!toplevel || (toplevel->pending_tiled_edges() != wf::TILED_EDGES_ALL)))
105 {
106 return;
107 }
108
109 if ((signal == "unmaximized") && (!toplevel || (toplevel->pending_tiled_edges() == wf::TILED_EDGES_ALL)))
110 {
111 return;
112 }
113
114 for (const auto & rule : _rules)
115 {
116 _access_interface.set_view(view);
117 _action_interface.set_view(view);
118 auto error = rule->apply(signal, _access_interface, _action_interface);
119 if (error)
120 {
121 LOGE("Window-rules: Error while executing rule on ", signal, " signal.");
122 }
123 }
124
125 auto bounds = _lambda_registrations->rules();
126 auto begin = std::get<0>(bounds);
127 auto end = std::get<1>(bounds);
128 while (begin != end)
129 {
130 auto registration = std::get<1>(*begin);
131 bool error = false;
132
133 // Assume we will use the view access interface.
134 _access_interface.set_view(view);
135 wf::access_interface_t & access_iface = _access_interface;
136
137 // If a custom access interface is set in the regoistration, use this one.
138 if (registration->access_interface != nullptr)
139 {
140 access_iface = *registration->access_interface;
141 }
142
143 // Load if lambda wrapper.
144 if (registration->if_lambda != nullptr)
145 {
146 registration->rule_instance->setIfLambda(
147 [registration, signal, view] () -> bool
148 {
149 return registration->if_lambda(signal, view);
150 });
151 }
152
153 // Load else lambda wrapper.

Callers

nothing calls this directly

Calls 4

toplevel_castFunction · 0.85
pending_tiled_edgesMethod · 0.80
rulesMethod · 0.80
set_viewMethod · 0.45

Tested by

no test coverage detected