2011-08-31 04:59:42 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-31 04:59:42 +04:00
|
|
|
* X11 Monitor Handling
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:20:53 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-08-31 04:59:42 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2012-11-20 08:49:08 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2011-08-31 04:59:42 +04:00
|
|
|
#ifdef WITH_XINERAMA
|
|
|
|
#include <X11/extensions/Xinerama.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "xf_monitor.h"
|
|
|
|
|
|
|
|
/* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071 */
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
|
2011-08-31 04:59:42 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
VIRTUAL_SCREEN* vscreen;
|
|
|
|
|
|
|
|
#ifdef WITH_XINERAMA
|
|
|
|
int ignored, ignored2;
|
|
|
|
XineramaScreenInfo* screen_info = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
vscreen = &xfi->vscreen;
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
if (xf_GetWorkArea(xfi) != TRUE)
|
2011-09-27 07:06:45 +04:00
|
|
|
{
|
|
|
|
xfi->workArea.x = 0;
|
|
|
|
xfi->workArea.y = 0;
|
|
|
|
xfi->workArea.width = WidthOfScreen(xfi->screen);
|
|
|
|
xfi->workArea.height = HeightOfScreen(xfi->screen);
|
|
|
|
}
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
if (settings->Fullscreen)
|
2011-12-15 13:45:50 +04:00
|
|
|
{
|
2012-11-07 19:33:06 +04:00
|
|
|
settings->DesktopWidth = WidthOfScreen(xfi->screen);
|
|
|
|
settings->DesktopHeight = HeightOfScreen(xfi->screen);
|
2011-12-15 13:45:50 +04:00
|
|
|
}
|
2012-11-08 03:23:25 +04:00
|
|
|
else if (settings->Workarea)
|
2011-08-31 04:59:42 +04:00
|
|
|
{
|
2012-11-07 19:33:06 +04:00
|
|
|
settings->DesktopWidth = xfi->workArea.width;
|
|
|
|
settings->DesktopHeight = xfi->workArea.height;
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|
2012-11-08 03:23:25 +04:00
|
|
|
else if (settings->PercentScreen)
|
2011-11-02 03:53:49 +04:00
|
|
|
{
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->DesktopWidth = (xfi->workArea.width * settings->PercentScreen) / 100;
|
|
|
|
settings->DesktopHeight = (xfi->workArea.height * settings->PercentScreen) / 100;
|
2011-11-02 03:53:49 +04:00
|
|
|
}
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
if (settings->Fullscreen != TRUE && settings->Workarea != TRUE)
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-31 04:59:42 +04:00
|
|
|
|
|
|
|
#ifdef WITH_XINERAMA
|
|
|
|
if (XineramaQueryExtension(xfi->display, &ignored, &ignored2))
|
|
|
|
{
|
|
|
|
if (XineramaIsActive(xfi->display))
|
|
|
|
{
|
|
|
|
screen_info = XineramaQueryScreens(xfi->display, &vscreen->nmonitors);
|
|
|
|
|
|
|
|
if (vscreen->nmonitors > 16)
|
|
|
|
vscreen->nmonitors = 0;
|
|
|
|
|
2012-11-20 08:49:08 +04:00
|
|
|
vscreen->monitors = malloc(sizeof(MONITOR_INFO) * vscreen->nmonitors);
|
|
|
|
ZeroMemory(vscreen->monitors, sizeof(MONITOR_INFO) * vscreen->nmonitors);
|
2011-08-31 04:59:42 +04:00
|
|
|
|
|
|
|
if (vscreen->nmonitors)
|
|
|
|
{
|
|
|
|
for (i = 0; i < vscreen->nmonitors; i++)
|
|
|
|
{
|
|
|
|
vscreen->monitors[i].area.left = screen_info[i].x_org;
|
|
|
|
vscreen->monitors[i].area.top = screen_info[i].y_org;
|
|
|
|
vscreen->monitors[i].area.right = screen_info[i].x_org + screen_info[i].width - 1;
|
|
|
|
vscreen->monitors[i].area.bottom = screen_info[i].y_org + screen_info[i].height - 1;
|
|
|
|
|
|
|
|
if ((screen_info[i].x_org == 0) && (screen_info[i].y_org == 0))
|
2012-10-09 10:31:28 +04:00
|
|
|
vscreen->monitors[i].primary = TRUE;
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(screen_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-08 08:29:24 +04:00
|
|
|
settings->MonitorCount = vscreen->nmonitors;
|
2011-08-31 04:59:42 +04:00
|
|
|
|
|
|
|
for (i = 0; i < vscreen->nmonitors; i++)
|
|
|
|
{
|
2012-11-08 08:29:24 +04:00
|
|
|
settings->MonitorDefArray[i].x = vscreen->monitors[i].area.left;
|
|
|
|
settings->MonitorDefArray[i].y = vscreen->monitors[i].area.top;
|
|
|
|
settings->MonitorDefArray[i].width = vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1;
|
|
|
|
settings->MonitorDefArray[i].height = vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1;
|
|
|
|
settings->MonitorDefArray[i].is_primary = vscreen->monitors[i].primary;
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2011-09-02 21:29:17 +04:00
|
|
|
vscreen->area.left = MIN(vscreen->monitors[i].area.left, vscreen->area.left);
|
|
|
|
vscreen->area.right = MAX(vscreen->monitors[i].area.right, vscreen->area.right);
|
|
|
|
vscreen->area.top = MIN(vscreen->monitors[i].area.top, vscreen->area.top);
|
|
|
|
vscreen->area.bottom = MAX(vscreen->monitors[i].area.bottom, vscreen->area.bottom);
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
/* if no monitor information is present then make sure variables are set accordingly */
|
2012-11-08 08:29:24 +04:00
|
|
|
if (settings->MonitorCount == 0)
|
2012-08-04 02:35:17 +04:00
|
|
|
{
|
|
|
|
vscreen->area.left = 0;
|
2012-11-07 19:33:06 +04:00
|
|
|
vscreen->area.right = settings->DesktopWidth -1;
|
2012-08-04 02:35:17 +04:00
|
|
|
vscreen->area.top = 0;
|
2012-11-07 19:33:06 +04:00
|
|
|
vscreen->area.bottom = settings->DesktopHeight - 1;
|
2012-08-04 02:35:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-08 08:29:24 +04:00
|
|
|
if (settings->MonitorCount)
|
2011-12-15 13:45:50 +04:00
|
|
|
{
|
2012-11-07 19:33:06 +04:00
|
|
|
settings->DesktopWidth = vscreen->area.right - vscreen->area.left + 1;
|
|
|
|
settings->DesktopHeight = vscreen->area.bottom - vscreen->area.top + 1;
|
2011-12-15 13:45:50 +04:00
|
|
|
}
|
2011-09-02 21:29:17 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|