mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-09 07:22:21 +08:00
checkpoint. initial support for multiple displays on win32.
This commit is contained in:
@@ -6,6 +6,15 @@
|
||||
#include "CString.h"
|
||||
#include <cstring>
|
||||
|
||||
//
|
||||
// add backwards compatible multihead support (suppress bogus warning)
|
||||
//
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4706) // assignment within conditional
|
||||
#define COMPILE_MULTIMON_STUBS
|
||||
#include <multimon.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
//
|
||||
// CMSWindowsScreen
|
||||
//
|
||||
@@ -16,6 +25,7 @@ CMSWindowsScreen* CMSWindowsScreen::s_screen = NULL;
|
||||
CMSWindowsScreen::CMSWindowsScreen() :
|
||||
m_class(0),
|
||||
m_cursor(NULL),
|
||||
m_x(0), m_y(0),
|
||||
m_w(0), m_h(0),
|
||||
m_thread(0)
|
||||
{
|
||||
@@ -99,11 +109,8 @@ CMSWindowsScreen::openDisplay()
|
||||
classInfo.hIconSm = NULL;
|
||||
m_class = RegisterClassEx(&classInfo);
|
||||
|
||||
// get screen size
|
||||
// FIXME -- should handle multiple screens
|
||||
m_w = GetSystemMetrics(SM_CXSCREEN);
|
||||
m_h = GetSystemMetrics(SM_CYSCREEN);
|
||||
log((CLOG_INFO "display size: %dx%d", m_w, m_h));
|
||||
// get screen shape
|
||||
updateScreenShape();
|
||||
|
||||
// let subclass prep display
|
||||
onOpenDisplay();
|
||||
@@ -142,21 +149,25 @@ CMSWindowsScreen::getClass() const
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::updateScreenSize()
|
||||
CMSWindowsScreen::updateScreenShape()
|
||||
{
|
||||
m_w = GetSystemMetrics(SM_CXSCREEN);
|
||||
m_h = GetSystemMetrics(SM_CYSCREEN);
|
||||
log((CLOG_INFO "display resize: %dx%d", m_w, m_h));
|
||||
m_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
m_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
log((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsScreen::getScreenSize(SInt32* w, SInt32* h) const
|
||||
CMSWindowsScreen::getScreenShape(
|
||||
SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
assert(m_class != 0);
|
||||
assert(w != NULL && h != NULL);
|
||||
|
||||
*w = m_w;
|
||||
*h = m_h;
|
||||
x = m_x;
|
||||
y = m_y;
|
||||
w = m_w;
|
||||
h = m_h;
|
||||
}
|
||||
|
||||
HDESK
|
||||
|
||||
@@ -44,10 +44,11 @@ protected:
|
||||
ATOM getClass() const;
|
||||
|
||||
// update screen size cache
|
||||
void updateScreenSize();
|
||||
void updateScreenShape();
|
||||
|
||||
// get the size of the screen
|
||||
void getScreenSize(SInt32* w, SInt32* h) const;
|
||||
void getScreenShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const;
|
||||
|
||||
// get the input desktop. caller must CloseDesktop() the result.
|
||||
// do not call under windows 95/98/me.
|
||||
@@ -87,6 +88,7 @@ private:
|
||||
ATOM m_class;
|
||||
HICON m_icon;
|
||||
HCURSOR m_cursor;
|
||||
SInt32 m_x, m_y;
|
||||
SInt32 m_w, m_h;
|
||||
DWORD m_thread;
|
||||
static CMSWindowsScreen* s_screen;
|
||||
|
||||
@@ -19,6 +19,7 @@ CXWindowsScreen* CXWindowsScreen::s_screen = NULL;
|
||||
CXWindowsScreen::CXWindowsScreen() :
|
||||
m_display(NULL),
|
||||
m_root(None),
|
||||
m_x(0), m_y(0),
|
||||
m_w(0), m_h(0),
|
||||
m_stop(false)
|
||||
{
|
||||
@@ -59,10 +60,12 @@ CXWindowsScreen::openDisplay()
|
||||
m_screen = DefaultScreen(m_display);
|
||||
Screen* screen = ScreenOfDisplay(m_display, m_screen);
|
||||
|
||||
// get screen size
|
||||
// get screen shape
|
||||
m_x = 0;
|
||||
m_y = 0;
|
||||
m_w = WidthOfScreen(screen);
|
||||
m_h = HeightOfScreen(screen);
|
||||
log((CLOG_INFO "display size: %dx%d", m_w, m_h));
|
||||
log((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
|
||||
|
||||
// get the root window
|
||||
m_root = RootWindow(m_display, m_screen);
|
||||
@@ -113,13 +116,15 @@ CXWindowsScreen::getRoot() const
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsScreen::getScreenSize(SInt32* w, SInt32* h) const
|
||||
CXWindowsScreen::getScreenShape(
|
||||
SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
assert(m_display != NULL);
|
||||
assert(w != NULL && h != NULL);
|
||||
|
||||
*w = m_w;
|
||||
*h = m_h;
|
||||
x = m_x;
|
||||
y = m_y;
|
||||
w = m_w;
|
||||
h = m_h;
|
||||
}
|
||||
|
||||
Cursor
|
||||
|
||||
@@ -41,12 +41,13 @@ protected:
|
||||
// is closed.
|
||||
void closeDisplay();
|
||||
|
||||
// get the opened screen, its size, its root window. to get the
|
||||
// get the opened screen, its shape, its root window. to get the
|
||||
// display create a CDisplayLock object passing this. while the
|
||||
// object exists no other threads may access the display. do not
|
||||
// save the Display* beyond the lifetime of the CDisplayLock.
|
||||
int getScreen() const;
|
||||
void getScreenSize(SInt32* w, SInt32* h) const;
|
||||
void getScreenShape(
|
||||
SInt32& x, SInt32& y, SInt32& w, SInt32& h) const;
|
||||
Window getRoot() const;
|
||||
|
||||
// create a cursor that is transparent everywhere
|
||||
@@ -108,6 +109,7 @@ private:
|
||||
Display* m_display;
|
||||
int m_screen;
|
||||
Window m_root;
|
||||
SInt32 m_x, m_y;
|
||||
SInt32 m_w, m_h;
|
||||
bool m_stop;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user