add ghost function getAllDisplayDimensions, GHOST_GetAllDisplayDimensions

This returns the desktop size, not just the size of the active monitor, useful since this constrains the mouse and we dont have to detect the active monitor (which isn't so straightforward with xlib).

carbon/cocoa are TODO, they still use getMainDisplayDimensions().
This commit is contained in:
Campbell Barton
2013-01-31 10:42:26 +00:00
parent 4d2efa877e
commit 73f301c3a8
13 changed files with 100 additions and 2 deletions

View File

@@ -148,6 +148,20 @@ extern void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
GHOST_TUns32 *width,
GHOST_TUns32 *height);
/**
* Returns the dimensions of all displays combine
* (the current workspace).
* No need to worrky about overlapping monitors.
* \param systemhandle The handle to the system
* \param width A pointer the width gets put in
* \param height A pointer the height gets put in
* \return void.
*/
extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
GHOST_TUns32 *width,
GHOST_TUns32 *height);
/**
* Create a new window.
* The new window is added to the list of windows managed.

View File

@@ -226,6 +226,12 @@ public:
*/
virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const = 0;
/**
* Returns the combine dimensions of all monitors.
* \return The dimension of the workspace.
*/
virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const = 0;
/**
* Create a new window.
* The new window is added to the list of windows managed.

View File

@@ -123,7 +123,14 @@ void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
system->getMainDisplayDimensions(*width, *height);
}
void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
GHOST_TUns32 *width,
GHOST_TUns32 *height)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
system->getAllDisplayDimensions(*width, *height);
}
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
const char *title,

View File

@@ -396,6 +396,11 @@ void GHOST_SystemCarbon::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUn
height = bnds.bottom - bnds.top;
}
void GHOST_SystemCarbon::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
{
/* TODO */
getMainDisplayDimensions(width, height);
}
GHOST_IWindow *GHOST_SystemCarbon::createWindow(
const STR_String& title,

View File

@@ -91,6 +91,12 @@ public:
* \return The dimension of the main display.
*/
virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
/**
* Returns the combine dimensions of all monitors.
* \return The dimension of the workspace.
*/
virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
/**
* Create a new window.

View File

@@ -89,6 +89,11 @@ public:
*/
virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
/** Returns the combine dimensions of all monitors.
* \return The dimension of the workspace.
*/
virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
/**
* Create a new window.
* The new window is added to the list of windows managed.

View File

@@ -719,6 +719,11 @@ void GHOST_SystemCocoa::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns
[pool drain];
}
void GHOST_SystemCocoa::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
{
/* TODO! */
getMainDisplayDimensions(width, height);
}
GHOST_IWindow* GHOST_SystemCocoa::createWindow(
const STR_String& title,

View File

@@ -215,6 +215,11 @@ void GHOST_SystemWin32::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns
height = ::GetSystemMetrics(SM_CYSCREEN);
}
void GHOST_SystemWin32::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
{
width = ::GetSystemMetrics(SM_XVIRTUALSCREEN);
height = ::GetSystemMetrics(SM_YVIRTUALSCREEN);
}
GHOST_IWindow *GHOST_SystemWin32::createWindow(
const STR_String& title,

View File

@@ -100,7 +100,13 @@ public:
* \return The dimension of the main display.
*/
virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
/**
* Returns the dimensions of all displays on this system.
* \return The dimension of the main display.
*/
virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
/**
* Create a new window.
* The new window is added to the list of windows managed.

View File

@@ -242,6 +242,23 @@ getMainDisplayDimensions(
}
}
/**
* Returns the dimensions of the main display on this system.
* \return The dimension of the main display.
*/
void
GHOST_SystemX11::
getAllDisplayDimensions(
GHOST_TUns32& width,
GHOST_TUns32& height) const
{
if (m_display) {
width = DisplayWidth(m_display, DefaultScreen(m_display));
height = DisplayHeight(m_display, DefaultScreen(m_display));
}
}
/**
* Create a new window.
* The new window is added to the list of windows managed.

View File

@@ -116,6 +116,16 @@ public:
GHOST_TUns32& height
) const;
/**
* Returns the dimensions of all displays on this system.
* \return The dimension of the main display.
*/
void
getAllDisplayDimensions(
GHOST_TUns32& width,
GHOST_TUns32& height
) const;
/**
* Create a new window.
* The new window is added to the list of windows managed.

View File

@@ -114,6 +114,17 @@ void wm_get_screensize(int *width_r, int *height_r)
*height_r = uiheight;
}
/* size of all screens, useful since the mouse is bound by this */
void wm_get_screensize_all(int *width_r, int *height_r)
{
unsigned int uiwidth;
unsigned int uiheight;
GHOST_GetAllDisplayDimensions(g_system, &uiwidth, &uiheight);
*width_r = uiwidth;
*height_r = uiheight;
}
/* keeps offset and size within monitor bounds */
/* XXX solve dual screen... */
static void wm_window_check_position(rcti *rect)
@@ -829,7 +840,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
GHOST_DisposeRectangle(client_rect);
wm_get_screensize(&scr_w, &scr_h);
wm_get_screensize_all(&scr_w, &scr_h);
sizex = r - l;
sizey = b - t;
posx = l;

View File

@@ -40,6 +40,7 @@ void wm_ghost_init (bContext *C);
void wm_ghost_exit(void);
void wm_get_screensize(int *width_r, int *height_r);
void wm_get_screensize_all(int *width_r, int *height_r);
wmWindow *wm_window_new (bContext *C);
void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win);