MCPcopy Create free account
hub / github.com/Alexays/Waybar / handleUserEvent

Method handleUserEvent

src/AModule.cpp:156–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154bool AModule::handleRelease(GdkEventButton* const& e) { return handleUserEvent(e); }
155
156bool AModule::handleUserEvent(GdkEventButton* const& e) {
157 std::string format{};
158 const std::map<std::pair<uint, GdkEventType>, std::string>::const_iterator& rec{
159 eventMap_.find(std::pair(e->button, e->type))};
160
161 if (rec != eventMap_.cend()) {
162 // First call module actions
163 this->AModule::doAction(rec->second);
164
165 format = rec->second;
166 }
167
168 // Check that a menu has been configured
169 if (config_["menu"].isString()) {
170 // Check if the event is the one specified for the "menu" option
171 if (rec->second == config_["menu"].asString()) {
172 // Popup the menu
173 gtk_widget_show_all(GTK_WIDGET(menu_));
174 gtk_menu_popup_at_pointer(GTK_MENU(menu_), reinterpret_cast<GdkEvent*>(e));
175 // Manually reset prelight to make sure the module doesn't stay in a hover state
176 if (auto* module = event_box_.get_child(); module != nullptr) {
177 module->unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
178 }
179 }
180 }
181 // Second call user scripts
182 if (!format.empty()) {
183 if (config_[format].isString())
184 format = config_[format].asString();
185 else
186 format.clear();
187 }
188 if (!format.empty()) {
189 pid_children_.push_back(util::command::forkExec(format));
190 }
191 dp.emit();
192 return true;
193}
194
195AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {
196 // only affects up/down

Callers

nothing calls this directly

Calls 3

forkExecFunction · 0.85
emptyMethod · 0.80
emitMethod · 0.45

Tested by

no test coverage detected