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:
parent
dbd10820c3
commit
b477efa706
|
@ -24,7 +24,8 @@
|
||||||
const char* Action::m_ActionTypeNames[] =
|
const char* Action::m_ActionTypeNames[] =
|
||||||
{
|
{
|
||||||
"keyDown", "keyUp", "keystroke",
|
"keyDown", "keyUp", "keystroke",
|
||||||
"switchToScreen", "switchInDirection", "lockCursorToScreen",
|
"switchToScreen", "toggleScreen",
|
||||||
|
"switchInDirection", "lockCursorToScreen",
|
||||||
"mouseDown", "mouseUp", "mousebutton"
|
"mouseDown", "mouseUp", "mousebutton"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +46,13 @@ Action::Action() :
|
||||||
|
|
||||||
QString Action::text() const
|
QString Action::text() const
|
||||||
{
|
{
|
||||||
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]) + "(";
|
/* This function is used to save to config file which is for barriers to
|
||||||
|
* read. However the server config parse does not support functions with ()
|
||||||
|
* in the end but now argument inside. If you need a function with no
|
||||||
|
* argument, it can not have () in the end.
|
||||||
|
*/
|
||||||
|
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ?
|
||||||
|
type() + int(mouseDown) : type()]);
|
||||||
|
|
||||||
switch (type())
|
switch (type())
|
||||||
{
|
{
|
||||||
|
@ -53,6 +60,7 @@ QString Action::text() const
|
||||||
case keyUp:
|
case keyUp:
|
||||||
case keystroke:
|
case keystroke:
|
||||||
{
|
{
|
||||||
|
text += "(";
|
||||||
text += keySequence().toString();
|
text += keySequence().toString();
|
||||||
|
|
||||||
if (!keySequence().isMouseButton())
|
if (!keySequence().isMouseButton())
|
||||||
|
@ -72,19 +80,29 @@ QString Action::text() const
|
||||||
else
|
else
|
||||||
text += ",*";
|
text += ",*";
|
||||||
}
|
}
|
||||||
|
text += ")";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case switchToScreen:
|
case switchToScreen:
|
||||||
|
text += "(";
|
||||||
text += switchScreenName();
|
text += switchScreenName();
|
||||||
|
text += ")";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case toggleScreen:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case switchInDirection:
|
case switchInDirection:
|
||||||
|
text += "(";
|
||||||
text += m_SwitchDirectionNames[m_SwitchDirection];
|
text += m_SwitchDirectionNames[m_SwitchDirection];
|
||||||
|
text += ")";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lockCursorToScreen:
|
case lockCursorToScreen:
|
||||||
|
text += "(";
|
||||||
text += m_LockCursorModeNames[m_LockCursorMode];
|
text += m_LockCursorModeNames[m_LockCursorMode];
|
||||||
|
text += ")";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -92,7 +110,6 @@ QString Action::text() const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
text += ")";
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,9 @@ class Action
|
||||||
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
enum ActionType { keyDown, keyUp, keystroke,
|
||||||
|
switchToScreen, toggleScreen, switchInDirection,
|
||||||
|
lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
||||||
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
||||||
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey
|
||||||
|
|
||||||
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
||||||
// at the button id of the checked radio button
|
// at the button id of the checked radio button
|
||||||
QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen };
|
QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioToggleScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen };
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
||||||
m_pButtonGroupType->addButton(typeButtons[i], i);
|
m_pButtonGroupType->addButton(typeButtons[i], i);
|
||||||
|
|
|
@ -142,6 +142,17 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="m_pRadioToggleScreen">
|
||||||
|
<property name="text">
|
||||||
|
<string>Toggle screen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -133,6 +133,7 @@ REGISTER_EVENT(Server, error)
|
||||||
REGISTER_EVENT(Server, connected)
|
REGISTER_EVENT(Server, connected)
|
||||||
REGISTER_EVENT(Server, disconnected)
|
REGISTER_EVENT(Server, disconnected)
|
||||||
REGISTER_EVENT(Server, switchToScreen)
|
REGISTER_EVENT(Server, switchToScreen)
|
||||||
|
REGISTER_EVENT(Server, toggleScreen)
|
||||||
REGISTER_EVENT(Server, switchInDirection)
|
REGISTER_EVENT(Server, switchInDirection)
|
||||||
REGISTER_EVENT(Server, keyboardBroadcast)
|
REGISTER_EVENT(Server, keyboardBroadcast)
|
||||||
REGISTER_EVENT(Server, lockCursorToScreen)
|
REGISTER_EVENT(Server, lockCursorToScreen)
|
||||||
|
|
|
@ -432,6 +432,7 @@ public:
|
||||||
m_connected(Event::kUnknown),
|
m_connected(Event::kUnknown),
|
||||||
m_disconnected(Event::kUnknown),
|
m_disconnected(Event::kUnknown),
|
||||||
m_switchToScreen(Event::kUnknown),
|
m_switchToScreen(Event::kUnknown),
|
||||||
|
m_toggleScreen(Event::kUnknown),
|
||||||
m_switchInDirection(Event::kUnknown),
|
m_switchInDirection(Event::kUnknown),
|
||||||
m_keyboardBroadcast(Event::kUnknown),
|
m_keyboardBroadcast(Event::kUnknown),
|
||||||
m_lockCursorToScreen(Event::kUnknown),
|
m_lockCursorToScreen(Event::kUnknown),
|
||||||
|
@ -470,6 +471,13 @@ public:
|
||||||
*/
|
*/
|
||||||
Event::Type switchToScreen();
|
Event::Type switchToScreen();
|
||||||
|
|
||||||
|
//! Get toggle screen event type
|
||||||
|
/*!
|
||||||
|
Returns the toggle screen event type. The server responds to this
|
||||||
|
by toggling screens. These is no event data.
|
||||||
|
*/
|
||||||
|
Event::Type toggleScreen();
|
||||||
|
|
||||||
//! Get switch in direction event type
|
//! Get switch in direction event type
|
||||||
/*!
|
/*!
|
||||||
Returns the switch in direction event type. The server responds to this
|
Returns the switch in direction event type. The server responds to this
|
||||||
|
@ -508,6 +516,7 @@ private:
|
||||||
Event::Type m_connected;
|
Event::Type m_connected;
|
||||||
Event::Type m_disconnected;
|
Event::Type m_disconnected;
|
||||||
Event::Type m_switchToScreen;
|
Event::Type m_switchToScreen;
|
||||||
|
Event::Type m_toggleScreen;
|
||||||
Event::Type m_switchInDirection;
|
Event::Type m_switchInDirection;
|
||||||
Event::Type m_keyboardBroadcast;
|
Event::Type m_keyboardBroadcast;
|
||||||
Event::Type m_lockCursorToScreen;
|
Event::Type m_lockCursorToScreen;
|
||||||
|
|
|
@ -1182,6 +1182,10 @@ Config::parseAction(ConfigReadContext& s,
|
||||||
action = new InputFilter::SwitchToScreenAction(m_events, screen);
|
action = new InputFilter::SwitchToScreenAction(m_events, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (name == "toggleScreen") {
|
||||||
|
action = new InputFilter::ToggleScreenAction(m_events);
|
||||||
|
}
|
||||||
|
|
||||||
else if (name == "switchInDirection") {
|
else if (name == "switchInDirection") {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
throw XConfigRead(s, "syntax for action: switchInDirection(<left|right|up|down>)");
|
throw XConfigRead(s, "syntax for action: switchInDirection(<left|right|up|down>)");
|
||||||
|
|
|
@ -369,6 +369,32 @@ InputFilter::SwitchToScreenAction::perform(const Event& event)
|
||||||
Event::kDeliverImmediately));
|
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(
|
InputFilter::SwitchInDirectionAction::SwitchInDirectionAction(
|
||||||
IEventQueue* events, EDirection direction) :
|
IEventQueue* events, EDirection direction) :
|
||||||
m_direction(direction),
|
m_direction(direction),
|
||||||
|
|
|
@ -167,6 +167,20 @@ public:
|
||||||
IEventQueue* m_events;
|
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
|
// SwitchInDirectionAction
|
||||||
class SwitchInDirectionAction : public Action {
|
class SwitchInDirectionAction : public Action {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -163,6 +163,10 @@ Server::Server(
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<Server>(this,
|
new TMethodEventJob<Server>(this,
|
||||||
&Server::handleSwitchToScreenEvent));
|
&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_events->adoptHandler(m_events->forServer().switchInDirection(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<Server>(this,
|
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
|
void
|
||||||
Server::handleSwitchInDirectionEvent(const Event& event, void*)
|
Server::handleSwitchInDirectionEvent(const Event& event, void*)
|
||||||
{
|
{
|
||||||
|
|
|
@ -308,6 +308,7 @@ private:
|
||||||
void handleClientDisconnected(const Event&, void*);
|
void handleClientDisconnected(const Event&, void*);
|
||||||
void handleClientCloseTimeout(const Event&, void*);
|
void handleClientCloseTimeout(const Event&, void*);
|
||||||
void handleSwitchToScreenEvent(const Event&, void*);
|
void handleSwitchToScreenEvent(const Event&, void*);
|
||||||
|
void handleToggleScreenEvent(const Event&, void*);
|
||||||
void handleSwitchInDirectionEvent(const Event&, void*);
|
void handleSwitchInDirectionEvent(const Event&, void*);
|
||||||
void handleKeyboardBroadcastEvent(const Event&,void*);
|
void handleKeyboardBroadcastEvent(const Event&,void*);
|
||||||
void handleLockCursorToScreenEvent(const Event&, void*);
|
void handleLockCursorToScreenEvent(const Event&, void*);
|
||||||
|
|
Loading…
Reference in New Issue