Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow complex nested/split screen layout shapes #7287

Closed
wants to merge 12 commits into from
6 changes: 4 additions & 2 deletions src/lib/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ Client::getClipboard(ClipboardID id, IClipboard* clipboard) const
}

void
Client::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
Client::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h, SInt32 pos_x, SInt32 pos_y) const
{
m_screen->getShape(x, y, w, h);
m_screen->getShape(x, y, w, h, pos_x, pos_y);
}

void
Expand All @@ -258,6 +258,8 @@ Client::getCursorPos(SInt32& x, SInt32& y) const
void
Client::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool)
{

LOG((CLOG_DEBUG "DAUN - entering client at pos(%d,%d)", xAbs, yAbs));
m_active = true;
m_screen->mouseMove(xAbs, yAbs);
m_screen->enter(mask);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Client : public IClient, public INode {
virtual void* getEventTarget() const;
virtual bool getClipboard(ClipboardID id, IClipboard*) const;
virtual void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const;
SInt32& width, SInt32& height, SInt32 pos_x = INT_MIN, SInt32 pos_y = INT_MIN) const;
virtual void getCursorPos(SInt32& x, SInt32& y) const;

// IClient overrides
Expand Down
2 changes: 2 additions & 0 deletions src/lib/client/ServerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ void
ServerProxy::queryInfo()
{
ClientInfo info;

LOG((CLOG_DEBUG "Daun - server proxy query info"));
m_client->getShape(info.m_x, info.m_y, info.m_w, info.m_h);
m_client->getCursorPos(info.m_mx, info.m_my);
sendInfo(info);
Expand Down
153 changes: 148 additions & 5 deletions src/lib/platform/MSWindowsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,156 @@ MSWindowsScreen::getClipboard(ClipboardID, IClipboard* dst) const
return true;
}


/* TODO: DAUN
1. Enumerate Display Monitors using EnumDisplayMonitors();
2. IF cursor position (pos_x and pos_y) is in the monitor, return the monitor boundary
3. if not found, just return original shape...?

EXAMPLE OF EnumDisplayMonitors():

struct cMonitorsVec
{
std::vector<int> iMonitors;
std::vector<HMONITOR> hMonitors;
std::vector<HDC> hdcMonitors;
std::vector<RECT> rcMonitors;

static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
{
cMonitorsVec* pThis = reinterpret_cast<cMonitorsVec*>(pData);

pThis->hMonitors.push_back(hMon);
pThis->hdcMonitors.push_back(hdc);
pThis->rcMonitors.push_back(*lprcMonitor);
pThis->iMonitors.push_back(pThis->hdcMonitors.size());
return TRUE;
}

cMonitorsVec()
{
EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)this);
}
};

int main()
{
cMonitorsVec Monitors;

for (int monitorIndex=0; monitorIndex < Monitors.iMonitors.size(); monitorIndex++)
{
std::wcout << "Screen id: " << monitorIndex << std::endl;
std::wcout << "-----------------------------------------------------" << std::endl;
std::wcout << " - screen left-top corner coordinates : (" << Monitors.rcMonitors[monitorIndex].left
<< "," << Monitors.rcMonitors[monitorIndex].top
<< ")" << std::endl;
std::wcout << " - screen dimensions (width x height) : (" << std::abs(Monitors.rcMonitors[monitorIndex].right - Monitors.rcMonitors[monitorIndex].left)
<< "," << std::abs(Monitors.rcMonitors[monitorIndex].top - Monitors.rcMonitors[monitorIndex].bottom)
<< ")" << std::endl;
std::wcout << "-----------------------------------------------------" << std::endl;
}
}
*/

struct cMonitorsVec
{
std::vector<int> iMonitors;
std::vector<HMONITOR> hMonitors;
std::vector<HDC> hdcMonitors;
std::vector<RECT> rcMonitors;

static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
{
cMonitorsVec* pThis = reinterpret_cast<cMonitorsVec*>(pData);

pThis->hMonitors.push_back(hMon);
pThis->hdcMonitors.push_back(hdc);
pThis->rcMonitors.push_back(*lprcMonitor);
pThis->iMonitors.push_back(pThis->hdcMonitors.size());
return TRUE;
}

cMonitorsVec()
{
EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)this);
}
};


void
MSWindowsScreen::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
MSWindowsScreen::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h, SInt32 pos_x, SInt32 pos_y) const
{
assert(m_class != 0);

x = m_x;
y = m_y;
w = m_w;
h = m_h;
bool found = false;

cMonitorsVec Monitors;

if (pos_x > INT_MIN && pos_y > INT_MIN){
for (int monitorIndex=0; monitorIndex < Monitors.iMonitors.size(); monitorIndex++)
{
SInt32 min_x, min_y, max_x, max_y;
min_x = Monitors.rcMonitors[monitorIndex].left;
min_y = Monitors.rcMonitors[monitorIndex].top;
max_x = Monitors.rcMonitors[monitorIndex].right;
max_y = Monitors.rcMonitors[monitorIndex].bottom;
if (pos_x >= min_x && pos_y >= min_y && pos_x <= max_x && pos_y <= max_y ){
// LOG((CLOG_DEBUG "DAUN - found display containing position %d, %d, %d, %d, mousePOS(%d, %d)", min_x, min_y, max_x, max_y, pos_x, pos_y));
found = true;
x = min_x;
y = min_y;
w = max_x - min_x;
h = max_y - min_y;
}else{
// LOG((CLOG_DEBUG "DAUN - missed display containing position %d, %d, %d, %d, mousePOS(%d, %d)", min_x, min_y, max_x, max_y, pos_x, pos_y));
}
}
}
else if (pos_x > INT_MIN){
for (int monitorIndex=0; monitorIndex < Monitors.iMonitors.size(); monitorIndex++)
{
SInt32 min_x, min_y, max_x, max_y;
min_x = Monitors.rcMonitors[monitorIndex].left;
min_y = Monitors.rcMonitors[monitorIndex].top;
max_x = Monitors.rcMonitors[monitorIndex].right;
max_y = Monitors.rcMonitors[monitorIndex].bottom;
if (pos_x >= min_x && pos_x <= max_x){
// LOG((CLOG_DEBUG "DAUN - found display containing position %d, %d, %d, %d, mousePOS(%d, %d)", min_x, min_y, max_x, max_y, pos_x, pos_y));
found = true;
x = min_x;
y = min_y;
w = max_x - min_x;
h = max_y - min_y;
}
}
}
else if (pos_y > INT_MIN){
for (int monitorIndex=0; monitorIndex < Monitors.iMonitors.size(); monitorIndex++)
{
SInt32 min_x, min_y, max_x, max_y;
min_x = Monitors.rcMonitors[monitorIndex].left;
min_y = Monitors.rcMonitors[monitorIndex].top;
max_x = Monitors.rcMonitors[monitorIndex].right;
max_y = Monitors.rcMonitors[monitorIndex].bottom;
if (pos_y >= min_y && pos_y <= max_y){
// LOG((CLOG_DEBUG "DAUN - found display containing position %d, %d, %d, %d, mousePOS(%d, %d)", min_x, min_y, max_x, max_y, pos_x, pos_y));
found = true;
x = min_x;
y = min_y;
w = max_x - min_x;
h = max_y - min_y;
}
}
}

if (!found){
LOG((CLOG_DEBUG "DAUN - couldn't find display mousePOS(%d,%d) - return (%d,%d,%d,%d)", pos_x, pos_y, m_x, m_y, m_w, m_h));
x = m_x;
y = m_y;
w = m_w;
h = m_h;
}

}

void
Expand Down Expand Up @@ -1648,6 +1789,8 @@ MSWindowsScreen::ignore() const
void
MSWindowsScreen::updateScreenShape()
{


// get shape and center
m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/platform/MSWindowsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MSWindowsScreen : public PlatformScreen {
virtual void* getEventTarget() const;
virtual bool getClipboard(ClipboardID id, IClipboard*) const;
virtual void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const;
SInt32& width, SInt32& height, SInt32 pos_x = INT_MIN, SInt32 pos_y = INT_MIN) const;
virtual void getCursorPos(SInt32& x, SInt32& y) const;

/**
Expand Down
5 changes: 4 additions & 1 deletion src/lib/platform/OSXScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ class OSXScreen : public PlatformScreen {
// IScreen overrides
void* getEventTarget() const override;
bool getClipboard(ClipboardID id, IClipboard*) const override;
/* TODO: DAUN
we want to have a getShape() to accept pos_x, pos_y
*/
void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const override;
SInt32& width, SInt32& height, SInt32 pos_x = INT_MIN, SInt32 pos_y = INT_MIN) const override;
void getCursorPos(SInt32& x, SInt32& y) const override;

// IPrimaryScreen overrides
Expand Down
Loading
Loading