mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-29 23:35:26 +08:00
Added toggleScreen function, using hot key to loop through all screens.
Comparing to switchToScreen, it is more handy since the user only need to hit one hotkey.
This commit is contained in:
@@ -1182,6 +1182,10 @@ Config::parseAction(ConfigReadContext& s,
|
||||
action = new InputFilter::SwitchToScreenAction(m_events, screen);
|
||||
}
|
||||
|
||||
else if (name == "toggleScreen") {
|
||||
action = new InputFilter::ToggleScreenAction(m_events);
|
||||
}
|
||||
|
||||
else if (name == "switchInDirection") {
|
||||
if (args.size() != 1) {
|
||||
throw XConfigRead(s, "syntax for action: switchInDirection(<left|right|up|down>)");
|
||||
|
||||
@@ -369,6 +369,32 @@ InputFilter::SwitchToScreenAction::perform(const Event& event)
|
||||
Event::kDeliverImmediately));
|
||||
}
|
||||
|
||||
InputFilter::ToggleScreenAction::ToggleScreenAction(IEventQueue* events) :
|
||||
m_events(events)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
InputFilter::Action*
|
||||
InputFilter::ToggleScreenAction::clone() const
|
||||
{
|
||||
return new ToggleScreenAction(*this);
|
||||
}
|
||||
|
||||
String
|
||||
InputFilter::ToggleScreenAction::format() const
|
||||
{
|
||||
return barrier::string::sprintf("toggleScreen");
|
||||
}
|
||||
|
||||
void
|
||||
InputFilter::ToggleScreenAction::perform(const Event& event)
|
||||
{
|
||||
m_events->addEvent(Event(m_events->forServer().toggleScreen(),
|
||||
event.getTarget(), NULL,
|
||||
Event::kDeliverImmediately));
|
||||
}
|
||||
|
||||
InputFilter::SwitchInDirectionAction::SwitchInDirectionAction(
|
||||
IEventQueue* events, EDirection direction) :
|
||||
m_direction(direction),
|
||||
|
||||
@@ -167,6 +167,20 @@ public:
|
||||
IEventQueue* m_events;
|
||||
};
|
||||
|
||||
// ToggleScreenAction
|
||||
class ToggleScreenAction : public Action {
|
||||
public:
|
||||
ToggleScreenAction(IEventQueue* events);
|
||||
|
||||
// Action overrides
|
||||
virtual Action* clone() const;
|
||||
virtual String format() const;
|
||||
virtual void perform(const Event&);
|
||||
|
||||
private:
|
||||
IEventQueue* m_events;
|
||||
};
|
||||
|
||||
// SwitchInDirectionAction
|
||||
class SwitchInDirectionAction : public Action {
|
||||
public:
|
||||
|
||||
@@ -163,6 +163,10 @@ Server::Server(
|
||||
m_inputFilter,
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleSwitchToScreenEvent));
|
||||
m_events->adoptHandler(m_events->forServer().toggleScreen(),
|
||||
m_inputFilter,
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleToggleScreenEvent));
|
||||
m_events->adoptHandler(m_events->forServer().switchInDirection(),
|
||||
m_inputFilter,
|
||||
new TMethodEventJob<Server>(this,
|
||||
@@ -1407,6 +1411,24 @@ Server::handleSwitchToScreenEvent(const Event& event, void*)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Server::handleToggleScreenEvent(const Event& event, void*)
|
||||
{
|
||||
std::string current = getName(m_active);
|
||||
ClientList::const_iterator index = m_clients.find(current);
|
||||
if (index == m_clients.end()) {
|
||||
LOG((CLOG_DEBUG1 "screen \"%s\" not active", current.c_str()));
|
||||
}
|
||||
else {
|
||||
++index;
|
||||
if (index == m_clients.end()) {
|
||||
index = m_clients.begin();
|
||||
}
|
||||
jumpToScreen(index->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Server::handleSwitchInDirectionEvent(const Event& event, void*)
|
||||
{
|
||||
|
||||
@@ -308,6 +308,7 @@ private:
|
||||
void handleClientDisconnected(const Event&, void*);
|
||||
void handleClientCloseTimeout(const Event&, void*);
|
||||
void handleSwitchToScreenEvent(const Event&, void*);
|
||||
void handleToggleScreenEvent(const Event&, void*);
|
||||
void handleSwitchInDirectionEvent(const Event&, void*);
|
||||
void handleKeyboardBroadcastEvent(const Event&,void*);
|
||||
void handleLockCursorToScreenEvent(const Event&, void*);
|
||||
|
||||
Reference in New Issue
Block a user