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>
|
|
|
|
|
2014-09-12 19:13:01 +04:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
|
|
|
|
#define TAG CLIENT_TAG("x11")
|
|
|
|
|
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 */
|
|
|
|
|
2013-06-13 02:57:25 +04:00
|
|
|
int xf_list_monitors(xfContext* xfc)
|
2013-04-29 01:10:43 +04:00
|
|
|
{
|
|
|
|
#ifdef WITH_XINERAMA
|
|
|
|
Display* display;
|
2015-02-10 23:15:30 +03:00
|
|
|
int major, minor;
|
2013-04-29 01:10:43 +04:00
|
|
|
int i, nmonitors = 0;
|
|
|
|
XineramaScreenInfo* screen = NULL;
|
|
|
|
display = XOpenDisplay(NULL);
|
2015-02-10 23:15:30 +03:00
|
|
|
|
2015-01-15 23:38:52 +03:00
|
|
|
if (!display)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to open X display");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-04-29 01:10:43 +04:00
|
|
|
|
2015-02-10 23:15:30 +03:00
|
|
|
if (XineramaQueryExtension(display, &major, &minor))
|
2013-04-29 01:10:43 +04:00
|
|
|
{
|
|
|
|
if (XineramaIsActive(display))
|
|
|
|
{
|
|
|
|
screen = XineramaQueryScreens(display, &nmonitors);
|
|
|
|
|
|
|
|
for (i = 0; i < nmonitors; i++)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf(" %s [%d] %hdx%hd\t+%hd+%hd\n",
|
2016-08-03 15:16:20 +03:00
|
|
|
(i == 0) ? "*" : " ", i,
|
|
|
|
screen[i].width, screen[i].height,
|
|
|
|
screen[i].x_org, screen[i].y_org);
|
2013-04-29 01:10:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
XFree(screen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XCloseDisplay(display);
|
|
|
|
#else
|
|
|
|
Screen* screen;
|
|
|
|
Display* display;
|
|
|
|
display = XOpenDisplay(NULL);
|
|
|
|
|
2015-02-10 23:15:30 +03:00
|
|
|
if (!display)
|
2015-01-15 23:38:52 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to open X display");
|
|
|
|
return -1;
|
|
|
|
}
|
2015-02-10 23:15:30 +03:00
|
|
|
|
2013-04-29 01:10:43 +04:00
|
|
|
screen = ScreenOfDisplay(display, DefaultScreen(display));
|
2016-12-14 00:47:08 +03:00
|
|
|
printf(" * [0] %dx%d\t+0+0\n", WidthOfScreen(screen),
|
|
|
|
HeightOfScreen(screen));
|
2013-04-29 01:10:43 +04:00
|
|
|
XCloseDisplay(display);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static BOOL xf_is_monitor_id_active(xfContext* xfc, UINT32 id)
|
2011-08-31 04:59:42 +04:00
|
|
|
{
|
2015-02-10 23:15:30 +03:00
|
|
|
int index;
|
2016-08-03 15:16:20 +03:00
|
|
|
rdpSettings* settings = xfc->context.settings;
|
2015-02-10 23:15:30 +03:00
|
|
|
|
|
|
|
if (!settings->NumMonitorIds)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (index = 0; index < settings->NumMonitorIds; index++)
|
|
|
|
{
|
|
|
|
if (settings->MonitorIds[index] == id)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-04-16 18:29:52 +03:00
|
|
|
BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
|
2015-02-10 23:15:30 +03:00
|
|
|
{
|
|
|
|
int i;
|
2015-02-23 20:22:28 +03:00
|
|
|
int nmonitors = 0;
|
2017-11-07 13:11:29 +03:00
|
|
|
int monitor_index = 0;
|
2017-10-17 15:31:11 +03:00
|
|
|
BOOL primaryMonitorFound = FALSE;
|
2011-08-31 04:59:42 +04:00
|
|
|
VIRTUAL_SCREEN* vscreen;
|
2016-08-03 15:16:20 +03:00
|
|
|
rdpSettings* settings = xfc->context.settings;
|
2015-02-23 20:22:28 +03:00
|
|
|
int mouse_x, mouse_y, _dummy_i;
|
|
|
|
Window _dummy_w;
|
|
|
|
int current_monitor = 0;
|
2017-11-07 13:11:29 +03:00
|
|
|
Screen* screen;
|
2011-08-31 04:59:42 +04:00
|
|
|
#ifdef WITH_XINERAMA
|
2015-02-10 23:15:30 +03:00
|
|
|
int major, minor;
|
|
|
|
XineramaScreenInfo* screenInfo = NULL;
|
2011-08-31 04:59:42 +04:00
|
|
|
#endif
|
2013-06-13 02:57:25 +04:00
|
|
|
vscreen = &xfc->vscreen;
|
2015-04-16 18:29:52 +03:00
|
|
|
*pMaxWidth = settings->DesktopWidth;
|
|
|
|
*pMaxHeight = settings->DesktopHeight;
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* get mouse location */
|
|
|
|
if (!XQueryPointer(xfc->display, DefaultRootWindow(xfc->display),
|
2016-08-03 15:16:20 +03:00
|
|
|
&_dummy_w, &_dummy_w, &mouse_x, &mouse_y,
|
|
|
|
&_dummy_i, &_dummy_i, (void*) &_dummy_i))
|
2015-02-23 20:22:28 +03:00
|
|
|
mouse_x = mouse_y = 0;
|
|
|
|
|
2011-08-31 04:59:42 +04:00
|
|
|
#ifdef WITH_XINERAMA
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-02-10 23:15:30 +03:00
|
|
|
if (XineramaQueryExtension(xfc->display, &major, &minor))
|
2011-08-31 04:59:42 +04:00
|
|
|
{
|
2013-06-13 02:57:25 +04:00
|
|
|
if (XineramaIsActive(xfc->display))
|
2011-08-31 04:59:42 +04:00
|
|
|
{
|
2015-02-10 23:15:30 +03:00
|
|
|
screenInfo = XineramaQueryScreens(xfc->display, &vscreen->nmonitors);
|
2011-08-31 04:59:42 +04:00
|
|
|
|
|
|
|
if (vscreen->nmonitors > 16)
|
|
|
|
vscreen->nmonitors = 0;
|
|
|
|
|
|
|
|
if (vscreen->nmonitors)
|
|
|
|
{
|
|
|
|
for (i = 0; i < vscreen->nmonitors; i++)
|
|
|
|
{
|
2015-02-10 23:15:30 +03:00
|
|
|
vscreen->monitors[i].area.left = screenInfo[i].x_org;
|
|
|
|
vscreen->monitors[i].area.top = screenInfo[i].y_org;
|
|
|
|
vscreen->monitors[i].area.right = screenInfo[i].x_org + screenInfo[i].width - 1;
|
2016-08-03 15:16:20 +03:00
|
|
|
vscreen->monitors[i].area.bottom = screenInfo[i].y_org + screenInfo[i].height -
|
|
|
|
1;
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* Determine which monitor that the mouse cursor is on */
|
2016-08-03 15:16:20 +03:00
|
|
|
if ((mouse_x >= vscreen->monitors[i].area.left) &&
|
2015-02-23 20:22:28 +03:00
|
|
|
(mouse_x <= vscreen->monitors[i].area.right) &&
|
|
|
|
(mouse_y >= vscreen->monitors[i].area.top) &&
|
|
|
|
(mouse_y <= vscreen->monitors[i].area.bottom))
|
|
|
|
current_monitor = i;
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-10 23:15:30 +03:00
|
|
|
XFree(screenInfo);
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-03 15:16:20 +03:00
|
|
|
#endif
|
2015-02-23 20:22:28 +03:00
|
|
|
xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom =
|
2016-08-03 15:16:20 +03:00
|
|
|
xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right = 0;
|
2015-02-23 20:22:28 +03:00
|
|
|
|
2015-02-12 02:24:06 +03:00
|
|
|
/* WORKAROUND: With Remote Application Mode - using NET_WM_WORKAREA
|
2016-08-03 15:16:20 +03:00
|
|
|
* causes issues with the ability to fully size the window vertically
|
|
|
|
* (the bottom of the window area is never updated). So, we just set
|
|
|
|
* the workArea to match the full Screen width/height.
|
2015-02-12 02:24:06 +03:00
|
|
|
*/
|
|
|
|
if (settings->RemoteApplicationMode || !xf_GetWorkArea(xfc))
|
2013-04-29 00:27:23 +04:00
|
|
|
{
|
2013-06-13 02:57:25 +04:00
|
|
|
xfc->workArea.x = 0;
|
|
|
|
xfc->workArea.y = 0;
|
|
|
|
xfc->workArea.width = WidthOfScreen(xfc->screen);
|
|
|
|
xfc->workArea.height = HeightOfScreen(xfc->screen);
|
2013-04-29 00:27:23 +04:00
|
|
|
}
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2013-04-29 00:27:23 +04:00
|
|
|
if (settings->Fullscreen)
|
|
|
|
{
|
2015-04-16 18:29:52 +03:00
|
|
|
*pMaxWidth = WidthOfScreen(xfc->screen);
|
|
|
|
*pMaxHeight = HeightOfScreen(xfc->screen);
|
2013-04-29 00:27:23 +04:00
|
|
|
}
|
|
|
|
else if (settings->Workarea)
|
2011-08-31 04:59:42 +04:00
|
|
|
{
|
2015-04-16 18:29:52 +03:00
|
|
|
*pMaxWidth = xfc->workArea.width;
|
|
|
|
*pMaxHeight = xfc->workArea.height;
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|
2013-04-29 00:27:23 +04:00
|
|
|
else if (settings->PercentScreen)
|
|
|
|
{
|
2015-02-23 20:22:28 +03:00
|
|
|
/* If we have specific monitor information then limit the PercentScreen value
|
|
|
|
* to only affect the current monitor vs. the entire desktop
|
|
|
|
*/
|
|
|
|
if (vscreen->nmonitors > 0)
|
|
|
|
{
|
2017-09-25 10:35:49 +03:00
|
|
|
*pMaxWidth = vscreen->monitors[current_monitor].area.right -
|
2017-11-07 13:11:29 +03:00
|
|
|
vscreen->monitors[current_monitor].area.left + 1;
|
2017-09-25 10:35:49 +03:00
|
|
|
*pMaxHeight = vscreen->monitors[current_monitor].area.bottom -
|
|
|
|
vscreen->monitors[current_monitor].area.top + 1;
|
2017-11-07 13:11:29 +03:00
|
|
|
|
|
|
|
if (settings->PercentScreenUseWidth)
|
2017-09-25 10:35:49 +03:00
|
|
|
*pMaxWidth = ((vscreen->monitors[current_monitor].area.right -
|
2017-11-07 13:11:29 +03:00
|
|
|
vscreen->monitors[current_monitor].area.left + 1) * settings->PercentScreen) /
|
|
|
|
100;
|
2017-09-25 10:35:49 +03:00
|
|
|
|
2017-11-07 13:11:29 +03:00
|
|
|
if (settings->PercentScreenUseHeight)
|
2017-09-25 10:35:49 +03:00
|
|
|
*pMaxHeight = ((vscreen->monitors[current_monitor].area.bottom -
|
2017-11-07 13:11:29 +03:00
|
|
|
vscreen->monitors[current_monitor].area.top + 1) * settings->PercentScreen) /
|
|
|
|
100;
|
2015-02-23 20:22:28 +03:00
|
|
|
}
|
2017-09-25 10:35:49 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*pMaxWidth = xfc->workArea.width;
|
|
|
|
*pMaxHeight = xfc->workArea.height;
|
|
|
|
|
2017-11-07 13:11:29 +03:00
|
|
|
if (settings->PercentScreenUseWidth)
|
2017-09-25 10:35:49 +03:00
|
|
|
*pMaxWidth = (xfc->workArea.width * settings->PercentScreen) / 100;
|
2017-11-07 13:11:29 +03:00
|
|
|
|
|
|
|
if (settings->PercentScreenUseHeight)
|
2017-09-25 10:35:49 +03:00
|
|
|
*pMaxHeight = (xfc->workArea.height * settings->PercentScreen) / 100;
|
|
|
|
}
|
2013-04-29 00:27:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!settings->Fullscreen && !settings->Workarea && !settings->UseMultimon)
|
|
|
|
return TRUE;
|
2011-08-31 04:59:42 +04:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* If single monitor fullscreen OR workarea without remote app */
|
2017-10-17 15:31:11 +03:00
|
|
|
if ((settings->Fullscreen && !settings->UseMultimon && !settings->SpanMonitors) ||
|
2016-08-03 15:16:20 +03:00
|
|
|
(settings->Workarea && !settings->RemoteApplicationMode))
|
2013-04-29 03:16:23 +04:00
|
|
|
{
|
2015-02-23 20:22:28 +03:00
|
|
|
/* If no monitors were specified on the command-line then set the current monitor as active */
|
|
|
|
if (!settings->NumMonitorIds)
|
2013-04-29 03:16:23 +04:00
|
|
|
{
|
2015-02-23 20:22:28 +03:00
|
|
|
settings->MonitorIds[0] = current_monitor;
|
2013-04-29 03:16:23 +04:00
|
|
|
}
|
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* Always sets number of monitors from command-line to just 1.
|
|
|
|
* If the monitor is invalid then we will default back to current monitor
|
|
|
|
* later as a fallback. So, there is no need to validate command-line entry here.
|
|
|
|
*/
|
|
|
|
settings->NumMonitorIds = 1;
|
|
|
|
}
|
2013-04-29 00:27:23 +04:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* Create array of all active monitors by taking into account monitors requested on the command-line */
|
2013-04-29 00:27:23 +04:00
|
|
|
for (i = 0; i < vscreen->nmonitors; i++)
|
2012-08-04 02:35:17 +04:00
|
|
|
{
|
2015-02-10 23:15:30 +03:00
|
|
|
if (!xf_is_monitor_id_active(xfc, i))
|
|
|
|
continue;
|
2013-04-29 00:27:23 +04:00
|
|
|
|
2013-04-29 02:48:27 +04:00
|
|
|
settings->MonitorDefArray[nmonitors].x = vscreen->monitors[i].area.left;
|
|
|
|
settings->MonitorDefArray[nmonitors].y = vscreen->monitors[i].area.top;
|
2016-08-03 15:16:20 +03:00
|
|
|
settings->MonitorDefArray[nmonitors].width = MIN(vscreen->monitors[i].area.right
|
|
|
|
- vscreen->monitors[i].area.left + 1, *pMaxWidth);
|
|
|
|
settings->MonitorDefArray[nmonitors].height = MIN(
|
|
|
|
vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1,
|
|
|
|
*pMaxHeight);
|
2015-02-23 20:22:28 +03:00
|
|
|
settings->MonitorDefArray[nmonitors].orig_screen = i;
|
2017-11-07 13:11:29 +03:00
|
|
|
|
|
|
|
if (i == settings->MonitorIds[0])
|
|
|
|
{
|
2017-10-17 15:31:11 +03:00
|
|
|
settings->MonitorDefArray[nmonitors].is_primary = TRUE;
|
|
|
|
primaryMonitorFound = TRUE;
|
|
|
|
}
|
2017-11-07 13:11:29 +03:00
|
|
|
|
2013-04-29 00:27:23 +04:00
|
|
|
nmonitors++;
|
2012-08-04 02:35:17 +04:00
|
|
|
}
|
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* If no monitor is active(bogus command-line monitor specification) - then lets try to fallback to go fullscreen on the current monitor only */
|
|
|
|
if (nmonitors == 0 && vscreen->nmonitors > 0)
|
2013-04-29 02:48:27 +04:00
|
|
|
{
|
2015-02-23 20:22:28 +03:00
|
|
|
settings->MonitorDefArray[0].x = vscreen->monitors[current_monitor].area.left;
|
|
|
|
settings->MonitorDefArray[0].y = vscreen->monitors[current_monitor].area.top;
|
2016-08-03 15:16:20 +03:00
|
|
|
settings->MonitorDefArray[0].width = MIN(
|
|
|
|
vscreen->monitors[current_monitor].area.right -
|
|
|
|
vscreen->monitors[current_monitor].area.left + 1, *pMaxWidth);
|
|
|
|
settings->MonitorDefArray[0].height = MIN(
|
|
|
|
vscreen->monitors[current_monitor].area.bottom -
|
|
|
|
vscreen->monitors[current_monitor].area.top + 1, *pMaxHeight);
|
2015-02-23 20:22:28 +03:00
|
|
|
settings->MonitorDefArray[0].orig_screen = current_monitor;
|
|
|
|
nmonitors = 1;
|
2013-04-29 02:48:27 +04:00
|
|
|
}
|
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
settings->MonitorCount = nmonitors;
|
2013-04-29 02:48:27 +04:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
/* If we have specific monitor information */
|
|
|
|
if (settings->MonitorCount)
|
2013-04-29 03:16:23 +04:00
|
|
|
{
|
2015-02-23 20:22:28 +03:00
|
|
|
/* Initialize bounding rectangle for all monitors */
|
2015-11-04 17:01:31 +03:00
|
|
|
int vX = settings->MonitorDefArray[0].x;
|
|
|
|
int vY = settings->MonitorDefArray[0].y;
|
|
|
|
int vR = vX + settings->MonitorDefArray[0].width;
|
|
|
|
int vB = vY + settings->MonitorDefArray[0].height;
|
2015-02-23 20:22:28 +03:00
|
|
|
xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom =
|
2016-08-03 15:16:20 +03:00
|
|
|
xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right =
|
|
|
|
settings->MonitorDefArray[0].orig_screen;
|
2015-02-23 20:22:28 +03:00
|
|
|
|
|
|
|
/* Calculate bounding rectangle around all monitors to be used AND
|
|
|
|
* also set the Xinerama indices which define left/top/right/bottom monitors.
|
|
|
|
*/
|
|
|
|
for (i = 1; i < settings->MonitorCount; i++)
|
|
|
|
{
|
|
|
|
/* does the same as gdk_rectangle_union */
|
|
|
|
int destX = MIN(vX, settings->MonitorDefArray[i].x);
|
|
|
|
int destY = MIN(vY, settings->MonitorDefArray[i].y);
|
2016-08-03 15:16:20 +03:00
|
|
|
int destR = MAX(vR, settings->MonitorDefArray[i].x +
|
|
|
|
settings->MonitorDefArray[i].width);
|
|
|
|
int destB = MAX(vB, settings->MonitorDefArray[i].y +
|
|
|
|
settings->MonitorDefArray[i].height);
|
2015-02-23 20:22:28 +03:00
|
|
|
|
|
|
|
if (vX != destX)
|
|
|
|
xfc->fullscreenMonitors.left = settings->MonitorDefArray[i].orig_screen;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
if (vY != destY)
|
|
|
|
xfc->fullscreenMonitors.top = settings->MonitorDefArray[i].orig_screen;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-11-04 17:01:31 +03:00
|
|
|
if (vR != destR)
|
2015-02-23 20:22:28 +03:00
|
|
|
xfc->fullscreenMonitors.right = settings->MonitorDefArray[i].orig_screen;
|
2016-08-03 15:16:20 +03:00
|
|
|
|
2015-11-04 17:01:31 +03:00
|
|
|
if (vB != destB)
|
2015-02-23 20:22:28 +03:00
|
|
|
xfc->fullscreenMonitors.bottom = settings->MonitorDefArray[i].orig_screen;
|
|
|
|
|
|
|
|
vX = destX;
|
|
|
|
vY = destY;
|
2015-11-04 17:01:31 +03:00
|
|
|
vR = destR;
|
|
|
|
vB = destB;
|
2015-02-23 20:22:28 +03:00
|
|
|
}
|
2013-04-29 03:16:23 +04:00
|
|
|
|
2015-02-23 20:22:28 +03:00
|
|
|
settings->DesktopPosX = vX;
|
|
|
|
settings->DesktopPosY = vY;
|
|
|
|
vscreen->area.left = 0;
|
2015-11-04 17:01:31 +03:00
|
|
|
vscreen->area.right = vR - vX - 1;
|
2015-02-23 20:22:28 +03:00
|
|
|
vscreen->area.top = 0;
|
2015-11-04 17:01:31 +03:00
|
|
|
vscreen->area.bottom = vB - vY - 1;
|
2015-02-23 20:22:28 +03:00
|
|
|
|
|
|
|
if (settings->Workarea)
|
|
|
|
{
|
|
|
|
vscreen->area.top = xfc->workArea.y;
|
2015-11-04 17:01:31 +03:00
|
|
|
vscreen->area.bottom = xfc->workArea.height + xfc->workArea.y - 1;
|
2015-02-23 20:22:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!primaryMonitorFound)
|
2016-08-03 15:16:20 +03:00
|
|
|
{
|
2017-11-07 13:11:29 +03:00
|
|
|
/* If we have a command line setting we should use it */
|
|
|
|
if (settings->NumMonitorIds)
|
2015-02-23 20:22:28 +03:00
|
|
|
{
|
2017-11-07 13:11:29 +03:00
|
|
|
/* The first monitor is the first in the setting which should be used */
|
|
|
|
monitor_index = settings->MonitorIds[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This is the same as when we would trust the Xinerama results..
|
|
|
|
and set the monitor index to zero.
|
|
|
|
The monitor listed with /monitor-list on index zero is always the primary
|
|
|
|
*/
|
|
|
|
screen = DefaultScreenOfDisplay(xfc->display);
|
|
|
|
monitor_index = XScreenNumberOfScreen(screen);
|
2015-02-23 20:22:28 +03:00
|
|
|
}
|
|
|
|
|
2017-11-07 13:11:29 +03:00
|
|
|
int j = monitor_index;
|
|
|
|
|
|
|
|
/* If the "default" monitor is not 0,0 use it */
|
|
|
|
if (settings->MonitorDefArray[j].x != 0 || settings->MonitorDefArray[j].y != 0)
|
2015-02-23 20:22:28 +03:00
|
|
|
{
|
2017-11-07 13:11:29 +03:00
|
|
|
settings->MonitorDefArray[j].is_primary = TRUE;
|
|
|
|
settings->MonitorLocalShiftX = settings->MonitorDefArray[j].x;
|
|
|
|
settings->MonitorLocalShiftY = settings->MonitorDefArray[j].y;
|
2015-02-23 20:22:28 +03:00
|
|
|
primaryMonitorFound = TRUE;
|
|
|
|
}
|
2017-11-07 13:11:29 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Lets try to see if there is a monitor with a 0,0 coordinate and use it as a fallback*/
|
|
|
|
for (i = 0; i < settings->MonitorCount; i++)
|
|
|
|
{
|
|
|
|
if (!primaryMonitorFound && settings->MonitorDefArray[i].x == 0
|
|
|
|
&& settings->MonitorDefArray[i].y == 0)
|
|
|
|
{
|
|
|
|
settings->MonitorDefArray[i].is_primary = TRUE;
|
|
|
|
settings->MonitorLocalShiftX = settings->MonitorDefArray[i].x;
|
|
|
|
settings->MonitorLocalShiftY = settings->MonitorDefArray[i].y;
|
|
|
|
primaryMonitorFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 20:22:28 +03:00
|
|
|
}
|
|
|
|
|
2016-08-03 15:16:20 +03:00
|
|
|
/* Subtract monitor shift from monitor variables for server-side use.
|
2015-02-23 20:22:28 +03:00
|
|
|
* We maintain monitor shift value as Window requires the primary monitor to have a coordinate of 0,0
|
|
|
|
* In some X configurations, no monitor may have a coordinate of 0,0. This can also be happen if the user
|
|
|
|
* requests specific monitors from the command-line as well. So, we make sure to translate our primary monitor's
|
|
|
|
* upper-left corner to 0,0 on the server.
|
|
|
|
*/
|
2016-08-03 15:16:20 +03:00
|
|
|
for (i = 0; i < settings->MonitorCount; i++)
|
2015-02-23 20:22:28 +03:00
|
|
|
{
|
2016-08-03 15:16:20 +03:00
|
|
|
settings->MonitorDefArray[i].x = settings->MonitorDefArray[i].x -
|
|
|
|
settings->MonitorLocalShiftX;
|
|
|
|
settings->MonitorDefArray[i].y = settings->MonitorDefArray[i].y -
|
|
|
|
settings->MonitorLocalShiftY;
|
2015-02-23 20:22:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the desktop width and height according to the bounding rectangle around the active monitors */
|
2015-04-16 18:29:52 +03:00
|
|
|
*pMaxWidth = vscreen->area.right - vscreen->area.left + 1;
|
|
|
|
*pMaxHeight = vscreen->area.bottom - vscreen->area.top + 1;
|
2011-12-15 13:45:50 +04:00
|
|
|
}
|
2011-09-02 21:29:17 +04:00
|
|
|
|
2017-10-17 15:31:11 +03:00
|
|
|
/* some 2008 server freeze at logon if we announce support for monitor layout PDU with
|
|
|
|
* #monitors < 2. So let's announce it only if we have more than 1 monitor.
|
|
|
|
*/
|
|
|
|
if (settings->MonitorCount)
|
|
|
|
settings->SupportMonitorLayoutPdu = TRUE;
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-31 04:59:42 +04:00
|
|
|
}
|