refactor: OptionTypes, Remove corner related enums and uses static items for corner masks instead
This commit is contained in:
@ -62,31 +62,14 @@ static const OptionID kOptionClipboardSharing = OPTION_CODE("CLPS");
|
||||
static const OptionID kOptionClipboardSharingSize = OPTION_CODE("CLSZ");
|
||||
//@}
|
||||
|
||||
//! @name Screen switch corner enumeration
|
||||
//@{
|
||||
enum EScreenSwitchCorners
|
||||
{
|
||||
kNoCorner,
|
||||
kTopLeft,
|
||||
kTopRight,
|
||||
kBottomLeft,
|
||||
kBottomRight,
|
||||
kFirstCorner = kTopLeft,
|
||||
kLastCorner = kBottomRight
|
||||
};
|
||||
//@}
|
||||
|
||||
//! @name Screen switch corner masks
|
||||
//@{
|
||||
enum EScreenSwitchCornerMasks
|
||||
{
|
||||
kNoCornerMask = 0,
|
||||
kTopLeftMask = 1 << (kTopLeft - kFirstCorner),
|
||||
kTopRightMask = 1 << (kTopRight - kFirstCorner),
|
||||
kBottomLeftMask = 1 << (kBottomLeft - kFirstCorner),
|
||||
kBottomRightMask = 1 << (kBottomRight - kFirstCorner),
|
||||
kAllCornersMask = kTopLeftMask | kTopRightMask | kBottomLeftMask | kBottomRightMask
|
||||
};
|
||||
inline static const auto s_noCornerMask = 0;
|
||||
inline static const auto s_topLeftCornerMask = 1 << 0;
|
||||
inline static const auto s_topRightCornerMask = 1 << 1;
|
||||
inline static const auto s_bottomLeftCornerMask = 1 << 2;
|
||||
inline static const auto s_bottomRightCornerMask = 1 << 3;
|
||||
inline static const auto s_allCornersMask = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3;
|
||||
//@}
|
||||
|
||||
//! @name Network protocol
|
||||
|
||||
@ -1296,16 +1296,16 @@ std::string Config::getOptionValue(OptionID id, OptionValue value)
|
||||
}
|
||||
if (id == kOptionScreenSwitchCorners) {
|
||||
std::string result("none");
|
||||
if ((value & kTopLeftMask) != 0) {
|
||||
if ((value & s_topLeftCornerMask) != 0) {
|
||||
result += " +top-left";
|
||||
}
|
||||
if ((value & kTopRightMask) != 0) {
|
||||
if ((value & s_topRightCornerMask) != 0) {
|
||||
result += " +top-right";
|
||||
}
|
||||
if ((value & kBottomLeftMask) != 0) {
|
||||
if ((value & s_bottomLeftCornerMask) != 0) {
|
||||
result += " +bottom-left";
|
||||
}
|
||||
if ((value & kBottomRightMask) != 0) {
|
||||
if ((value & s_bottomRightCornerMask) != 0) {
|
||||
result += " +bottom-right";
|
||||
}
|
||||
return result;
|
||||
@ -1783,25 +1783,25 @@ OptionValue ConfigReadContext::parseModifierKey(const std::string &arg) const
|
||||
OptionValue ConfigReadContext::parseCorner(const std::string &arg) const
|
||||
{
|
||||
if (CaselessCmp::equal(arg, "left")) {
|
||||
return kTopLeftMask | kBottomLeftMask;
|
||||
return s_topLeftCornerMask | s_bottomLeftCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "right")) {
|
||||
return kTopRightMask | kBottomRightMask;
|
||||
return s_topRightCornerMask | s_bottomRightCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "top")) {
|
||||
return kTopLeftMask | kTopRightMask;
|
||||
return s_topLeftCornerMask | s_topRightCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "bottom")) {
|
||||
return kBottomLeftMask | kBottomRightMask;
|
||||
return s_bottomLeftCornerMask | s_bottomRightCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "top-left")) {
|
||||
return kTopLeftMask;
|
||||
return s_topLeftCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "top-right")) {
|
||||
return kTopRightMask;
|
||||
return s_topRightCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "bottom-left")) {
|
||||
return kBottomLeftMask;
|
||||
return s_bottomLeftCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "bottom-right")) {
|
||||
return kBottomRightMask;
|
||||
return s_bottomRightCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "none")) {
|
||||
return kNoCornerMask;
|
||||
return s_noCornerMask;
|
||||
} else if (CaselessCmp::equal(arg, "all")) {
|
||||
return kAllCornersMask;
|
||||
return s_allCornersMask;
|
||||
}
|
||||
throw XConfigRead(*this, "invalid argument \"%{1}\"", arg);
|
||||
}
|
||||
|
||||
@ -989,22 +989,22 @@ uint32_t Server::getCorner(const BaseClientProxy *client, int32_t x, int32_t y,
|
||||
// if against the left or right then check if y is within size
|
||||
if (xSide != 0) {
|
||||
if (y < ay + size) {
|
||||
return (xSide < 0) ? kTopLeftMask : kTopRightMask;
|
||||
return (xSide < 0) ? s_topLeftCornerMask : s_topRightCornerMask;
|
||||
} else if (y >= ay + ah - size) {
|
||||
return (xSide < 0) ? kBottomLeftMask : kBottomRightMask;
|
||||
return (xSide < 0) ? s_bottomLeftCornerMask : s_bottomRightCornerMask;
|
||||
}
|
||||
}
|
||||
|
||||
// if against the left or right then check if y is within size
|
||||
if (ySide != 0) {
|
||||
if (x < ax + size) {
|
||||
return (ySide < 0) ? kTopLeftMask : kBottomLeftMask;
|
||||
return (ySide < 0) ? s_topLeftCornerMask : s_bottomLeftCornerMask;
|
||||
} else if (x >= ax + aw - size) {
|
||||
return (ySide < 0) ? kTopRightMask : kBottomRightMask;
|
||||
return (ySide < 0) ? s_topRightCornerMask : s_bottomRightCornerMask;
|
||||
}
|
||||
}
|
||||
|
||||
return kNoCornerMask;
|
||||
return s_noCornerMask;
|
||||
}
|
||||
|
||||
void Server::stopRelativeMoves()
|
||||
|
||||
Reference in New Issue
Block a user