From 54096f7b9b2858794a0bd1a9c9138198785b25cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 1 May 2013 23:03:05 -0400 Subject: [PATCH] xfreerdp-server: add xinerama code --- server/X11/CMakeLists.txt | 24 ++++++++++++++ server/X11/xf_monitors.c | 68 +++++++++++++++++++++++++++++++++++++++ server/X11/xf_monitors.h | 28 ++++++++++++++++ server/X11/xf_peer.c | 3 ++ 4 files changed, 123 insertions(+) create mode 100644 server/X11/xf_monitors.c create mode 100644 server/X11/xf_monitors.h diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index acf1e12da..34381ae85 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -30,6 +30,8 @@ set(${MODULE_PREFIX}_SRCS xf_encode.h xf_update.c xf_update.h + xf_monitors.c + xf_monitors.h xf_interface.c xf_interface.h xfreerdp.h) @@ -55,10 +57,18 @@ set(XSHM_FEATURE_TYPE "RECOMMENDED") set(XSHM_FEATURE_PURPOSE "X11 shared memory") set(XSHM_FEATURE_DESCRIPTION "X11 shared memory extension") +set(XINERAMA_FEATURE_TYPE "RECOMMENDED") +set(XINERAMA_FEATURE_PURPOSE "multi-monitor") +set(XINERAMA_FEATURE_DESCRIPTION "X11 multi-monitor extension") + set(XTEST_FEATURE_TYPE "RECOMMENDED") set(XTEST_FEATURE_PURPOSE "X11 input event injection") set(XTEST_FEATURE_DESCRIPTION "X11 input event injection extension") +set(XCURSOR_FEATURE_TYPE "RECOMMENDED") +set(XCURSOR_FEATURE_PURPOSE "cursor") +set(XCURSOR_FEATURE_DESCRIPTION "X11 cursor extension") + set(XFIXES_FEATURE_TYPE "RECOMMENDED") set(XFIXES_FEATURE_PURPOSE "X11 region") set(XFIXES_FEATURE_DESCRIPTION "X11 region fix extension") @@ -72,6 +82,8 @@ find_feature(XShm ${XSHM_FEATURE_TYPE} ${XSHM_FEATURE_PURPOSE} ${XSHM_FEATURE_DE find_feature(XTest ${XTEST_FEATURE_TYPE} ${XTEST_FEATURE_PURPOSE} ${XTEST_FEATURE_DESCRIPTION}) find_feature(Xfixes ${XFIXES_FEATURE_TYPE} ${XFIXES_FEATURE_PURPOSE} ${XFIXES_FEATURE_DESCRIPTION}) find_feature(Xdamage ${XDAMAGE_FEATURE_TYPE} ${XDAMAGE_FEATURE_PURPOSE} ${XDAMAGE_FEATURE_DESCRIPTION}) +find_feature(Xcursor ${XCURSOR_FEATURE_TYPE} ${XCURSOR_FEATURE_PURPOSE} ${XCURSOR_FEATURE_DESCRIPTION}) +find_feature(Xinerama ${XINERAMA_FEATURE_TYPE} ${XINERAMA_FEATURE_PURPOSE} ${XINERAMA_FEATURE_DESCRIPTION}) if(WITH_XSHM) add_definitions(-DWITH_XSHM) @@ -84,6 +96,18 @@ if(WITH_XEXT) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XEXT_LIBRARIES}) endif() +if(WITH_XINERAMA) + add_definitions(-DWITH_XINERAMA) + include_directories(${XINERAMA_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XINERAMA_LIBRARIES}) +endif() + +if(WITH_XCURSOR) + add_definitions(-DWITH_XCURSOR) + include_directories(${XCURSOR_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XCURSOR_LIBRARIES}) +endif() + if(WITH_XDAMAGE) add_definitions(-DWITH_XDAMAGE) include_directories(${XDAMAGE_INCLUDE_DIRS}) diff --git a/server/X11/xf_monitors.c b/server/X11/xf_monitors.c new file mode 100644 index 000000000..2bf5d51f1 --- /dev/null +++ b/server/X11/xf_monitors.c @@ -0,0 +1,68 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Monitors + * + * Copyright 2013 Marc-Andre Moreau + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#ifdef WITH_XINERAMA +#include +#endif + +#include "xf_monitors.h" + +int xf_list_monitors(xfInfo* xfi) +{ +#ifdef WITH_XINERAMAZ + int i, nmonitors = 0; + int ignored, ignored2; + XineramaScreenInfo* screen = NULL; + + if (XineramaQueryExtension(xfi->display, &ignored, &ignored2)) + { + if (XineramaIsActive(xfi->display)) + { + screen = XineramaQueryScreens(xfi->display, &nmonitors); + + for (i = 0; i < nmonitors; i++) + { + printf(" %s [%d] %dx%d\t+%d+%d\n", + (i == 0) ? "*" : " ", i, + screen[i].width, screen[i].height, + screen[i].x_org, screen[i].y_org); + } + + XFree(screen); + } + } +#else + Screen* screen; + + screen = ScreenOfDisplay(xfi->display, DefaultScreen(xfi->display)); + printf(" * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); +#endif + + return 0; +} + diff --git a/server/X11/xf_monitors.h b/server/X11/xf_monitors.h new file mode 100644 index 000000000..8487c3327 --- /dev/null +++ b/server/X11/xf_monitors.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Monitors + * + * Copyright 2013 Marc-Andre Moreau + * + * 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. + */ + +#ifndef XFREERDP_SERVER_MONITORS_H +#define XFREERDP_SERVER_MONITORS_H + +#include "xfreerdp.h" + +int xf_list_monitors(xfInfo* xfi); + +#endif /* XFREERDP_SERVER_MONITORS_H */ + diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 6ff3c74b9..b9d747ce2 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -45,6 +45,7 @@ #include "xf_input.h" #include "xf_encode.h" #include "xf_update.h" +#include "xf_monitors.h" #include "makecert.h" @@ -208,6 +209,8 @@ xfInfo* xf_info_init() exit(1); } + xf_list_monitors(xfi); + xfi->xfds = ConnectionNumber(xfi->display); xfi->number = DefaultScreen(xfi->display); xfi->screen = ScreenOfDisplay(xfi->display, xfi->number);