2010-02-22 20:13:30 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1993, 1998 The Open Group
|
2009-11-06 18:46:58 +01:00
|
|
|
Copyright (C) Colin Harrison 2005-2008
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall
|
|
|
|
not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
other dealings in this Software without prior written authorization
|
|
|
|
from The Open Group.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XWIN_CONFIG_H
|
|
|
|
#include <xwin-config.h>
|
|
|
|
#endif
|
|
|
|
#include "win.h"
|
|
|
|
#include "winmsg.h"
|
|
|
|
#include "winconfig.h"
|
|
|
|
#include "winprefs.h"
|
|
|
|
#ifdef DPMSExtension
|
|
|
|
#include "dpmsproc.h"
|
|
|
|
#endif
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#include <mntent.h>
|
|
|
|
#endif
|
2008-03-18 09:05:57 +01:00
|
|
|
#if defined(WIN32)
|
|
|
|
#include "xkbsrv.h"
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
#ifdef RELOCATE_PROJECTROOT
|
2013-08-11 13:15:11 +02:00
|
|
|
#pragma push_macro("Status")
|
|
|
|
#undef Status
|
|
|
|
#define Status wStatus
|
2008-04-20 17:35:42 +02:00
|
|
|
#include <shlobj.h>
|
2013-08-11 13:15:11 +02:00
|
|
|
#pragma pop_macro("Status")
|
2012-03-21 20:55:09 +01:00
|
|
|
typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner,
|
|
|
|
int nFolder,
|
|
|
|
HANDLE hToken,
|
|
|
|
DWORD dwFlags, LPTSTR pszPath);
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
2014-11-06 15:28:17 +01:00
|
|
|
|
|
|
|
#include "winmonitors.h"
|
|
|
|
#include "nonsdk_extinit.h"
|
|
|
|
#include "pseudoramiX/pseudoramiX.h"
|
|
|
|
|
2012-07-26 01:54:08 +02:00
|
|
|
#include "glx_extinit.h"
|
2013-04-10 19:04:17 +02:00
|
|
|
#ifdef XWIN_GLX_WINDOWS
|
|
|
|
#include "glx/glwindows.h"
|
Add Windows-DRI extension
If windowsdriproto headers are available, build a Windows-DRI extension,
which supports requests to enable local clients to directly render GL to a
Windows drawable:
- a query to check if WGL is being used on a screen
- a query to map a fbconfigID to a native pixelformatindex
- a query to map a drawable to a native handle
Windows-DRI can only be useful if we are using WGL, so make an note if WGL
is active on a screen.
Make validGlxDrawable() public
Adjust glxWinSetPixelFormat() so it doesn't require a context, just a
screen and config.
That enables factoring out the deferred drawable creation code as
glxWinDeferredCreateDrawable()
Enhance glxWinDeferredCreateDrawable(), so that pixmaps are placed into a
file mapping, so they exist in memory which can be shared with the direct
rendering process.
Currently, this file mapping is accessed by a name generated from the XID.
This will not be unique across multiple server instances. It would perhaps
be better, although more complicated, to use an anonymous file mapping, and
then duplicate the handle for the direct rendering process.
Use glxWinDeferredCreateDrawable() to ensure the native handle exists for
the Windows-DRI query to map a drawable to native handle.
v2:
Various printf format warning fixes
v3:
Fix format warnings on x86
Move some uninteresting windows-dri output to debug log level
v4:
check for windowsdriproto when --enable-windowsdri
use windowsdriproto_CFLAGS
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2014-07-24 13:29:41 +02:00
|
|
|
#include "dri/windowsdri.h"
|
2013-04-10 19:04:17 +02:00
|
|
|
#endif
|
2018-07-01 16:53:42 +02:00
|
|
|
#include "winauth.h"
|
2013-04-10 19:04:17 +02:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
/*
|
|
|
|
* References to external symbols
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function prototypes
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
winLogCommandLine(int argc, char *argv[]);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
winLogVersionInfo(void);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
winValidateArgs(void);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#ifdef RELOCATE_PROJECTROOT
|
2012-03-21 20:55:09 +01:00
|
|
|
const char *winGetBaseDir(void);
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For the depth 24 pixmap we default to 32 bits per pixel, but
|
|
|
|
* we change this pixmap format later if we detect that the display
|
|
|
|
* is going to be running at 24 bits per pixel.
|
|
|
|
*
|
|
|
|
* FIXME: On second thought, don't DIBs only support 32 bits per pixel?
|
|
|
|
* DIBs are the underlying bitmap used for DirectDraw surfaces, so it
|
|
|
|
* seems that all pixmap formats with depth 24 would be 32 bits per pixel.
|
|
|
|
* Confirm whether depth 24 DIBs can have 24 bits per pixel, then remove/keep
|
|
|
|
* the bits per pixel adjustment and update this comment to reflect the
|
|
|
|
* situation. Harold Hunt - 2002/07/02
|
|
|
|
*/
|
|
|
|
|
|
|
|
static PixmapFormatRec g_PixmapFormats[] = {
|
2012-03-21 20:55:09 +01:00
|
|
|
{1, 1, BITMAP_SCANLINE_PAD},
|
|
|
|
{4, 8, BITMAP_SCANLINE_PAD},
|
|
|
|
{8, 8, BITMAP_SCANLINE_PAD},
|
|
|
|
{15, 16, BITMAP_SCANLINE_PAD},
|
|
|
|
{16, 16, BITMAP_SCANLINE_PAD},
|
|
|
|
{24, 32, BITMAP_SCANLINE_PAD},
|
|
|
|
{32, 32, BITMAP_SCANLINE_PAD}
|
2008-04-20 17:35:42 +02:00
|
|
|
};
|
|
|
|
|
2020-11-21 16:45:49 +01:00
|
|
|
static Bool noDriExtension;
|
|
|
|
|
2012-07-12 01:36:43 +02:00
|
|
|
static const ExtensionModule xwinExtensions[] = {
|
|
|
|
#ifdef GLXEXT
|
Add Windows-DRI extension
If windowsdriproto headers are available, build a Windows-DRI extension,
which supports requests to enable local clients to directly render GL to a
Windows drawable:
- a query to check if WGL is being used on a screen
- a query to map a fbconfigID to a native pixelformatindex
- a query to map a drawable to a native handle
Windows-DRI can only be useful if we are using WGL, so make an note if WGL
is active on a screen.
Make validGlxDrawable() public
Adjust glxWinSetPixelFormat() so it doesn't require a context, just a
screen and config.
That enables factoring out the deferred drawable creation code as
glxWinDeferredCreateDrawable()
Enhance glxWinDeferredCreateDrawable(), so that pixmaps are placed into a
file mapping, so they exist in memory which can be shared with the direct
rendering process.
Currently, this file mapping is accessed by a name generated from the XID.
This will not be unique across multiple server instances. It would perhaps
be better, although more complicated, to use an anonymous file mapping, and
then duplicate the handle for the direct rendering process.
Use glxWinDeferredCreateDrawable() to ensure the native handle exists for
the Windows-DRI query to map a drawable to native handle.
v2:
Various printf format warning fixes
v3:
Fix format warnings on x86
Move some uninteresting windows-dri output to debug log level
v4:
check for windowsdriproto when --enable-windowsdri
use windowsdriproto_CFLAGS
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2014-07-24 13:29:41 +02:00
|
|
|
#ifdef XWIN_WINDOWS_DRI
|
|
|
|
{ WindowsDRIExtensionInit, "Windows-DRI", &noDriExtension },
|
|
|
|
#endif
|
2012-07-12 01:36:43 +02:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XwinExtensionInit
|
|
|
|
* Initialises Xwin-specific extensions.
|
|
|
|
*/
|
|
|
|
static
|
|
|
|
void XwinExtensionInit(void)
|
2009-11-07 20:28:18 +01:00
|
|
|
{
|
|
|
|
#ifdef XWIN_GLX_WINDOWS
|
2012-09-02 16:17:05 +02:00
|
|
|
if (g_fNativeGl) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/* install the native GL provider */
|
|
|
|
glxWinPushNativeProvider();
|
2009-11-07 20:28:18 +01:00
|
|
|
}
|
|
|
|
#endif
|
2012-07-12 01:36:43 +02:00
|
|
|
|
2013-09-26 21:28:37 +02:00
|
|
|
LoadExtensionList(xwinExtensions, ARRAY_SIZE(xwinExtensions), TRUE);
|
2009-11-07 20:28:18 +01:00
|
|
|
}
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#if defined(DDXBEFORERESET)
|
|
|
|
/*
|
|
|
|
* Called right before KillAllClients when the server is going to reset,
|
2020-07-05 22:07:33 +02:00
|
|
|
* allows us to shutdown our separate threads cleanly.
|
2008-04-20 17:35:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
ddxBeforeReset(void)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
winDebug("ddxBeforeReset - Hello\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
winClipboardShutdown();
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-22 00:22:57 +01:00
|
|
|
#if INPUTTHREAD
|
|
|
|
/** This function is called in Xserver/os/inputthread.c when starting
|
|
|
|
the input thread. */
|
|
|
|
void
|
|
|
|
ddxInputThreadInit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
hw/xwin: Improve WM_ENDSESSION handling using separate messaging window thread
Currently, WM_ENDSESSION just calls GiveUp() to set the DE_TERMINATE flag. But
for the X server to exit cleanly, we also need the X server dispatch loop to be
unblocked so it can notice that DE_TERMINATE has been set and exit, removing
it's lock file and any unix domain socket.
It appears that the system will terminate the process when the last UI thread in
that process returns from processing WM_ENDSESSION for the last top-level
window.
Since WM_ENDSESSION appears to sent by the system via SendMessage()
(synchronously) and the wndproc is called to process it in the message thread
for that window (the X server thread), we can't easily terminate the X server
dispatch loop from inside the WM_ENDSESSION message processing.
So, create a messaging window, a hidden, top-level window, with a separate
thread to catch this message, and process it by calling GiveUp() and then
blocking on a mutex until the X server dispatch loop exits.
Also, notice when this is a shutdown cancel WM_ENDSESSION message and take no
action.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2011-08-31 22:35:14 +02:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[], char *envp[])
|
|
|
|
{
|
|
|
|
int iReturn;
|
|
|
|
|
|
|
|
/* Create & acquire the termination mutex */
|
|
|
|
iReturn = pthread_mutex_init(&g_pmTerminating, NULL);
|
|
|
|
if (iReturn != 0) {
|
|
|
|
ErrorF("ddxMain - pthread_mutex_init () failed: %d\n", iReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
iReturn = pthread_mutex_lock(&g_pmTerminating);
|
|
|
|
if (iReturn != 0) {
|
|
|
|
ErrorF("ddxMain - pthread_mutex_lock () failed: %d\n", iReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dix_main(argc, argv, envp);
|
|
|
|
}
|
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
/* See Porting Layer Definition - p. 57 */
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
ddxGiveUp(enum ExitCode error)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int i;
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#if CYGDEBUG
|
2012-03-21 20:55:09 +01:00
|
|
|
winDebug("ddxGiveUp\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Perform per-screen deinitialization */
|
|
|
|
for (i = 0; i < g_iNumScreens; ++i) {
|
|
|
|
/* Delete the tray icon */
|
|
|
|
if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
|
|
|
|
winDeleteNotifyIcon(winGetScreenPriv(g_ScreenInfo[i].pScreen));
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
2011-07-18 15:48:23 +02:00
|
|
|
/* Unload libraries for taskbar grouping */
|
|
|
|
winPropertyStoreDestroy();
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Notify the worker threads we're exiting */
|
|
|
|
winDeinitMultiWindowWM();
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#ifdef HAS_DEVWINDOWS
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Close our handle to our message queue */
|
|
|
|
if (g_fdMessageQueue != WIN_FD_INVALID) {
|
|
|
|
/* Close /dev/windows */
|
|
|
|
close(g_fdMessageQueue);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Set the file handle to invalid */
|
|
|
|
g_fdMessageQueue = WIN_FD_INVALID;
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!g_fLogInited) {
|
2014-10-11 15:49:16 +02:00
|
|
|
g_pszLogFile = LogInit(g_pszLogFile, ".old");
|
2012-03-21 20:55:09 +01:00
|
|
|
g_fLogInited = TRUE;
|
|
|
|
}
|
|
|
|
LogClose(error);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
* At this point we aren't creating any new screens, so
|
|
|
|
* we are guaranteed to not need the DirectDraw functions.
|
|
|
|
*/
|
|
|
|
winReleaseDDProcAddresses();
|
|
|
|
|
|
|
|
/* Free concatenated command line */
|
|
|
|
free(g_pszCommandLine);
|
|
|
|
g_pszCommandLine = NULL;
|
|
|
|
|
|
|
|
/* Remove our keyboard hook if it is installed */
|
|
|
|
winRemoveKeyboardHookLL();
|
|
|
|
|
|
|
|
/* Tell Windows that we want to end the app */
|
|
|
|
PostQuitMessage(0);
|
hw/xwin: Improve WM_ENDSESSION handling using separate messaging window thread
Currently, WM_ENDSESSION just calls GiveUp() to set the DE_TERMINATE flag. But
for the X server to exit cleanly, we also need the X server dispatch loop to be
unblocked so it can notice that DE_TERMINATE has been set and exit, removing
it's lock file and any unix domain socket.
It appears that the system will terminate the process when the last UI thread in
that process returns from processing WM_ENDSESSION for the last top-level
window.
Since WM_ENDSESSION appears to sent by the system via SendMessage()
(synchronously) and the wndproc is called to process it in the message thread
for that window (the X server thread), we can't easily terminate the X server
dispatch loop from inside the WM_ENDSESSION message processing.
So, create a messaging window, a hidden, top-level window, with a separate
thread to catch this message, and process it by calling GiveUp() and then
blocking on a mutex until the X server dispatch loop exits.
Also, notice when this is a shutdown cancel WM_ENDSESSION message and take no
action.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2011-08-31 22:35:14 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
int iReturn = pthread_mutex_unlock(&g_pmTerminating);
|
|
|
|
|
2014-03-14 16:23:16 +01:00
|
|
|
winDebug("ddxGiveUp - Releasing termination mutex\n");
|
|
|
|
|
hw/xwin: Improve WM_ENDSESSION handling using separate messaging window thread
Currently, WM_ENDSESSION just calls GiveUp() to set the DE_TERMINATE flag. But
for the X server to exit cleanly, we also need the X server dispatch loop to be
unblocked so it can notice that DE_TERMINATE has been set and exit, removing
it's lock file and any unix domain socket.
It appears that the system will terminate the process when the last UI thread in
that process returns from processing WM_ENDSESSION for the last top-level
window.
Since WM_ENDSESSION appears to sent by the system via SendMessage()
(synchronously) and the wndproc is called to process it in the message thread
for that window (the X server thread), we can't easily terminate the X server
dispatch loop from inside the WM_ENDSESSION message processing.
So, create a messaging window, a hidden, top-level window, with a separate
thread to catch this message, and process it by calling GiveUp() and then
blocking on a mutex until the X server dispatch loop exits.
Also, notice when this is a shutdown cancel WM_ENDSESSION message and take no
action.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2011-08-31 22:35:14 +02:00
|
|
|
if (iReturn != 0) {
|
|
|
|
ErrorF("winMsgWindowProc - pthread_mutex_unlock () failed: %d\n",
|
|
|
|
iReturn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
winDebug("ddxGiveUp - End\n");
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
/* hasmntopt is currently not implemented for cygwin */
|
2012-03-21 20:55:09 +01:00
|
|
|
static const char *
|
|
|
|
winCheckMntOpt(const struct mntent *mnt, const char *opt)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
size_t len;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
if (mnt == NULL)
|
|
|
|
return NULL;
|
|
|
|
if (opt == NULL)
|
|
|
|
return NULL;
|
|
|
|
if (mnt->mnt_opts == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
len = strlen(opt);
|
|
|
|
s = strstr(mnt->mnt_opts, opt);
|
|
|
|
if (s == NULL)
|
|
|
|
return NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((s == mnt->mnt_opts || *(s - 1) == ',') &&
|
|
|
|
(s[len] == 0 || s[len] == ','))
|
|
|
|
return (char *) opt;
|
2008-04-20 17:35:42 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
winCheckMount(void)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
FILE *mnt;
|
|
|
|
struct mntent *ent;
|
|
|
|
|
|
|
|
enum { none = 0, sys_root, user_root, sys_tmp, user_tmp }
|
|
|
|
level = none, curlevel;
|
|
|
|
BOOL binary = TRUE;
|
|
|
|
|
|
|
|
mnt = setmntent("/etc/mtab", "r");
|
|
|
|
if (mnt == NULL) {
|
|
|
|
ErrorF("setmntent failed");
|
|
|
|
return;
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
while ((ent = getmntent(mnt)) != NULL) {
|
2012-01-25 19:53:02 +01:00
|
|
|
BOOL sys = (winCheckMntOpt(ent, "user") != NULL);
|
2012-03-21 20:55:09 +01:00
|
|
|
BOOL root = (strcmp(ent->mnt_dir, "/") == 0);
|
|
|
|
BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0);
|
|
|
|
|
2012-01-25 19:53:02 +01:00
|
|
|
if (sys) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (root)
|
|
|
|
curlevel = sys_root;
|
|
|
|
else if (tmp)
|
|
|
|
curlevel = sys_tmp;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (root)
|
|
|
|
curlevel = user_root;
|
|
|
|
else if (tmp)
|
|
|
|
curlevel = user_tmp;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curlevel <= level)
|
|
|
|
continue;
|
|
|
|
level = curlevel;
|
|
|
|
|
|
|
|
if ((winCheckMntOpt(ent, "binary") == NULL) &&
|
|
|
|
(winCheckMntOpt(ent, "binmode") == NULL))
|
|
|
|
binary = FALSE;
|
|
|
|
else
|
|
|
|
binary = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endmntent(mnt) != 1) {
|
|
|
|
ErrorF("endmntent failed");
|
|
|
|
return;
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!binary)
|
|
|
|
winMsg(X_WARNING, "/tmp mounted in textmode\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
winCheckMount(void)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RELOCATE_PROJECTROOT
|
2012-03-21 20:55:09 +01:00
|
|
|
const char *
|
2008-04-20 17:35:42 +02:00
|
|
|
winGetBaseDir(void)
|
|
|
|
{
|
|
|
|
static BOOL inited = FALSE;
|
|
|
|
static char buffer[MAX_PATH];
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (!inited) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char *fendptr;
|
|
|
|
HMODULE module = GetModuleHandle(NULL);
|
|
|
|
DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
if (sizeof(buffer) > 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
buffer[sizeof(buffer) - 1] = 0;
|
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
fendptr = buffer + size;
|
2012-03-21 20:55:09 +01:00
|
|
|
while (fendptr > buffer) {
|
|
|
|
if (*fendptr == '\\' || *fendptr == '/') {
|
2008-04-20 17:35:42 +02:00
|
|
|
*fendptr = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fendptr--;
|
|
|
|
}
|
|
|
|
inited = TRUE;
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
winFixupPaths(void)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
|
|
|
BOOL changed_fontpath = FALSE;
|
|
|
|
MessageType font_from = X_DEFAULT;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
#ifdef RELOCATE_PROJECTROOT
|
|
|
|
const char *basedir = winGetBaseDir();
|
|
|
|
size_t basedirlen = strlen(basedir);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef READ_FONTDIRS
|
|
|
|
{
|
|
|
|
/* Open fontpath configuration file */
|
|
|
|
FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt");
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (fontdirs != NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char buffer[256];
|
2012-03-21 20:55:09 +01:00
|
|
|
int needs_sep = TRUE;
|
2008-04-20 17:35:42 +02:00
|
|
|
int comment_block = FALSE;
|
|
|
|
|
2010-10-15 14:01:45 +02:00
|
|
|
/* get default fontpath */
|
2010-06-04 12:01:05 +02:00
|
|
|
char *fontpath = strdup(defaultFontPath);
|
2008-04-20 17:35:42 +02:00
|
|
|
size_t size = strlen(fontpath);
|
|
|
|
|
|
|
|
/* read all lines */
|
2012-03-21 20:55:09 +01:00
|
|
|
while (!feof(fontdirs)) {
|
2008-04-20 17:35:42 +02:00
|
|
|
size_t blen;
|
|
|
|
char *hashchar;
|
|
|
|
char *str;
|
|
|
|
int has_eol = FALSE;
|
|
|
|
|
|
|
|
/* read one line */
|
|
|
|
str = fgets(buffer, sizeof(buffer), fontdirs);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (str == NULL) /* stop on error or eof */
|
2008-04-20 17:35:42 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (strchr(str, '\n') != NULL)
|
|
|
|
has_eol = TRUE;
|
|
|
|
|
|
|
|
/* check if block is continued comment */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (comment_block) {
|
2008-04-20 17:35:42 +02:00
|
|
|
/* ignore all input */
|
2012-03-21 20:55:09 +01:00
|
|
|
*str = 0;
|
|
|
|
blen = 0;
|
|
|
|
if (has_eol) /* check if line ended in this block */
|
2008-04-20 17:35:42 +02:00
|
|
|
comment_block = FALSE;
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
2008-04-20 17:35:42 +02:00
|
|
|
/* find comment character. ignore all trailing input */
|
|
|
|
hashchar = strchr(str, '#');
|
2012-03-21 20:55:09 +01:00
|
|
|
if (hashchar != NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
*hashchar = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!has_eol) /* mark next block as continued comment */
|
2008-04-20 17:35:42 +02:00
|
|
|
comment_block = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strip whitespaces from beginning */
|
|
|
|
while (*str == ' ' || *str == '\t')
|
|
|
|
str++;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* get size, strip whitespaces from end */
|
2008-04-20 17:35:42 +02:00
|
|
|
blen = strlen(str);
|
2012-03-21 20:55:09 +01:00
|
|
|
while (blen > 0 && (str[blen - 1] == ' ' ||
|
|
|
|
str[blen - 1] == '\t' ||
|
|
|
|
str[blen - 1] == '\n')) {
|
2008-04-20 17:35:42 +02:00
|
|
|
str[--blen] = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* still something left to add? */
|
|
|
|
if (blen > 0) {
|
2008-04-20 17:35:42 +02:00
|
|
|
size_t newsize = size + blen;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
/* reserve one character more for ',' */
|
|
|
|
if (needs_sep)
|
|
|
|
newsize++;
|
|
|
|
|
|
|
|
/* allocate memory */
|
|
|
|
if (fontpath == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
fontpath = malloc(newsize + 1);
|
2008-04-20 17:35:42 +02:00
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
fontpath = realloc(fontpath, newsize + 1);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
/* add separator */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (needs_sep) {
|
2008-04-20 17:35:42 +02:00
|
|
|
fontpath[size] = ',';
|
|
|
|
size++;
|
|
|
|
needs_sep = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark next line as new entry */
|
|
|
|
if (has_eol)
|
|
|
|
needs_sep = TRUE;
|
|
|
|
|
|
|
|
/* add block */
|
|
|
|
strncpy(fontpath + size, str, blen);
|
|
|
|
fontpath[newsize] = 0;
|
|
|
|
size = newsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2012-03-21 20:55:09 +01:00
|
|
|
fclose(fontdirs);
|
2010-06-04 12:01:05 +02:00
|
|
|
defaultFontPath = strdup(fontpath);
|
2008-04-20 17:35:42 +02:00
|
|
|
free(fontpath);
|
|
|
|
changed_fontpath = TRUE;
|
|
|
|
font_from = X_CONFIG;
|
|
|
|
}
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* READ_FONTDIRS */
|
2008-04-20 17:35:42 +02:00
|
|
|
#ifdef RELOCATE_PROJECTROOT
|
|
|
|
{
|
|
|
|
const char *libx11dir = PROJECTROOT "/lib/X11";
|
|
|
|
size_t libx11dir_len = strlen(libx11dir);
|
|
|
|
char *newfp = NULL;
|
|
|
|
size_t newfp_len = 0;
|
|
|
|
const char *endptr, *ptr, *oldptr = defaultFontPath;
|
|
|
|
|
|
|
|
endptr = oldptr + strlen(oldptr);
|
|
|
|
ptr = strchr(oldptr, ',');
|
|
|
|
if (ptr == NULL)
|
|
|
|
ptr = endptr;
|
2012-03-21 20:55:09 +01:00
|
|
|
while (ptr != NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
size_t oldfp_len = (ptr - oldptr);
|
|
|
|
size_t newsize = oldfp_len;
|
|
|
|
char *newpath = malloc(newsize + 1);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
strncpy(newpath, oldptr, newsize);
|
|
|
|
newpath[newsize] = 0;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (strncmp(libx11dir, newpath, libx11dir_len) == 0) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char *compose;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
newsize = newsize - libx11dir_len + basedirlen;
|
2012-03-21 20:55:09 +01:00
|
|
|
compose = malloc(newsize + 1);
|
2008-04-20 17:35:42 +02:00
|
|
|
strcpy(compose, basedir);
|
|
|
|
strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
|
|
|
|
compose[newsize] = 0;
|
|
|
|
free(newpath);
|
|
|
|
newpath = compose;
|
|
|
|
}
|
|
|
|
|
|
|
|
oldfp_len = newfp_len;
|
|
|
|
if (oldfp_len > 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
newfp_len++; /* space for separator */
|
2008-04-20 17:35:42 +02:00
|
|
|
newfp_len += newsize;
|
|
|
|
|
|
|
|
if (newfp == NULL)
|
|
|
|
newfp = malloc(newfp_len + 1);
|
|
|
|
else
|
|
|
|
newfp = realloc(newfp, newfp_len + 1);
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (oldfp_len > 0) {
|
2008-04-20 17:35:42 +02:00
|
|
|
strcpy(newfp + oldfp_len, ",");
|
|
|
|
oldfp_len++;
|
|
|
|
}
|
|
|
|
strcpy(newfp + oldfp_len, newpath);
|
|
|
|
|
|
|
|
free(newpath);
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (*ptr == 0) {
|
2008-04-20 17:35:42 +02:00
|
|
|
oldptr = ptr;
|
|
|
|
ptr = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-04-20 17:35:42 +02:00
|
|
|
oldptr = ptr + 1;
|
|
|
|
ptr = strchr(oldptr, ',');
|
|
|
|
if (ptr == NULL)
|
|
|
|
ptr = endptr;
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2010-06-04 12:01:05 +02:00
|
|
|
defaultFontPath = strdup(newfp);
|
2008-04-20 17:35:42 +02:00
|
|
|
free(newfp);
|
|
|
|
changed_fontpath = TRUE;
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* RELOCATE_PROJECTROOT */
|
2008-04-20 17:35:42 +02:00
|
|
|
if (changed_fontpath)
|
2012-03-21 20:55:09 +01:00
|
|
|
winMsg(font_from, "FontPath set to \"%s\"\n", defaultFontPath);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#ifdef RELOCATE_PROJECTROOT
|
2012-03-21 20:55:09 +01:00
|
|
|
if (getenv("XKEYSYMDB") == NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char buffer[MAX_PATH];
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB", basedir);
|
|
|
|
buffer[sizeof(buffer) - 1] = 0;
|
2008-04-20 17:35:42 +02:00
|
|
|
putenv(buffer);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (getenv("XERRORDB") == NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char buffer[MAX_PATH];
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB", basedir);
|
|
|
|
buffer[sizeof(buffer) - 1] = 0;
|
2008-04-20 17:35:42 +02:00
|
|
|
putenv(buffer);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (getenv("XLOCALEDIR") == NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char buffer[MAX_PATH];
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale", basedir);
|
|
|
|
buffer[sizeof(buffer) - 1] = 0;
|
2008-04-20 17:35:42 +02:00
|
|
|
putenv(buffer);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (getenv("HOME") == NULL) {
|
2008-04-20 17:35:42 +02:00
|
|
|
char buffer[MAX_PATH + 5];
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
strncpy(buffer, "HOME=", 5);
|
|
|
|
|
|
|
|
/* query appdata directory */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (SHGetFolderPathA
|
|
|
|
(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0,
|
|
|
|
buffer + 5) == 0) {
|
2008-04-20 17:35:42 +02:00
|
|
|
putenv(buffer);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
winMsg(X_ERROR, "Can not determine HOME directory\n");
|
2011-07-03 20:10:52 +02:00
|
|
|
}
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
if (!g_fLogFileChanged) {
|
|
|
|
static char buffer[MAX_PATH];
|
|
|
|
DWORD size = GetTempPath(sizeof(buffer), buffer);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (size && size < sizeof(buffer)) {
|
|
|
|
snprintf(buffer + size, sizeof(buffer) - size,
|
|
|
|
"XWin.%s.log", display);
|
|
|
|
buffer[sizeof(buffer) - 1] = 0;
|
2008-04-20 17:35:42 +02:00
|
|
|
g_pszLogFile = buffer;
|
2012-03-21 20:55:09 +01:00
|
|
|
winMsg(X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile);
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
static char xkbbasedir[MAX_PATH];
|
|
|
|
|
|
|
|
snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir);
|
|
|
|
if (sizeof(xkbbasedir) > 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
xkbbasedir[sizeof(xkbbasedir) - 1] = 0;
|
2008-04-20 17:35:42 +02:00
|
|
|
XkbBaseDirectory = xkbbasedir;
|
2012-03-21 20:55:09 +01:00
|
|
|
XkbBinDirectory = basedir;
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* RELOCATE_PROJECTROOT */
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
OsVendorInit(void)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Re-initialize global variables on server reset */
|
|
|
|
winInitializeGlobals();
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
winFixupPaths();
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#ifdef DDXOSVERRORF
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!OsVendorVErrorFProc)
|
|
|
|
OsVendorVErrorFProc = OsVendorVErrorF;
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!g_fLogInited) {
|
|
|
|
/* keep this order. If LogInit fails it calls Abort which then calls
|
2014-10-31 00:45:12 +01:00
|
|
|
* ddxGiveUp where LogInit is called again and creates an infinite
|
|
|
|
* recursion. If we set g_fLogInited to TRUE before the init we
|
|
|
|
* avoid the second call
|
2012-03-21 20:55:09 +01:00
|
|
|
*/
|
|
|
|
g_fLogInited = TRUE;
|
2014-10-11 15:49:16 +02:00
|
|
|
g_pszLogFile = LogInit(g_pszLogFile, ".old");
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
LogSetParameter(XLOG_FLUSH, 1);
|
|
|
|
LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose);
|
|
|
|
LogSetParameter(XLOG_FILE_VERBOSITY, g_iLogVerbose);
|
|
|
|
|
|
|
|
/* Log the version information */
|
|
|
|
if (serverGeneration == 1)
|
|
|
|
winLogVersionInfo();
|
|
|
|
|
|
|
|
winCheckMount();
|
|
|
|
|
|
|
|
/* Add a default screen if no screens were specified */
|
|
|
|
if (g_iNumScreens == 0) {
|
|
|
|
winDebug("OsVendorInit - Creating default screen 0\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to initialize the default screen 0 if no -screen
|
|
|
|
* arguments were processed.
|
|
|
|
*
|
|
|
|
* Add a screen 0 using the defaults set by winInitializeDefaultScreens()
|
|
|
|
* and any additional default screen parameters given
|
|
|
|
*/
|
|
|
|
winInitializeScreens(1);
|
|
|
|
|
|
|
|
/* We have to flag this as an explicit screen, even though it isn't */
|
|
|
|
g_ScreenInfo[0].fExplicitScreen = TRUE;
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Work out what the default emulate3buttons setting should be, and apply
|
|
|
|
it if nothing was explicitly specified */
|
|
|
|
{
|
|
|
|
int mouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < g_iNumScreens; j++) {
|
|
|
|
if (g_ScreenInfo[j].iE3BTimeout == WIN_E3B_DEFAULT) {
|
|
|
|
if (mouseButtons < 3) {
|
|
|
|
static Bool reportOnce = TRUE;
|
|
|
|
|
|
|
|
g_ScreenInfo[j].iE3BTimeout = WIN_DEFAULT_E3B_TIME;
|
|
|
|
if (reportOnce) {
|
|
|
|
reportOnce = FALSE;
|
|
|
|
winMsg(X_PROBED,
|
|
|
|
"Windows reports only %d mouse buttons, defaulting to -emulate3buttons\n",
|
|
|
|
mouseButtons);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_ScreenInfo[j].iE3BTimeout = WIN_E3B_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-11 12:46:25 +01:00
|
|
|
|
|
|
|
/* Work out what the default resize setting should be, and apply it if it
|
|
|
|
was not explicitly specified */
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < g_iNumScreens; j++) {
|
|
|
|
if (g_ScreenInfo[j].iResizeMode == resizeDefault) {
|
|
|
|
if (g_ScreenInfo[j].fFullScreen)
|
|
|
|
g_ScreenInfo[j].iResizeMode = resizeNotAllowed;
|
|
|
|
else
|
|
|
|
g_ScreenInfo[j].iResizeMode = resizeWithRandr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-03-24 23:41:22 +01:00
|
|
|
}
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
winUseMsg(void)
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("\n");
|
|
|
|
ErrorF("\n");
|
|
|
|
ErrorF(EXECUTABLE_NAME " Device Dependent Usage:\n");
|
|
|
|
ErrorF("\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-[no]clipboard\n"
|
|
|
|
"\tEnable [disable] the clipboard integration. Default is enabled.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-clipupdates num_boxes\n"
|
|
|
|
"\tUse a clipping region to constrain shadow update blits to\n"
|
|
|
|
"\tthe updated region when num_boxes, or more, are in the\n"
|
|
|
|
"\tupdated region.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2017-01-05 14:17:59 +01:00
|
|
|
ErrorF("-[no]compositealpha\n"
|
|
|
|
"\tX windows with per-pixel alpha are composited into the Windows desktop.\n");
|
2015-08-03 17:47:38 +02:00
|
|
|
ErrorF("-[no]compositewm\n"
|
|
|
|
"\tUse the Composite extension to keep a bitmap image of each top-level\n"
|
|
|
|
"\tX window, so window contents which are occluded show correctly in\n"
|
|
|
|
"\ttask bar and task switcher previews.\n");
|
|
|
|
|
2009-11-02 18:37:14 +01:00
|
|
|
#ifdef XWIN_XF86CONFIG
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-config\n" "\tSpecify a configuration file.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-configdir\n" "\tSpecify a configuration directory.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-depth bits_per_pixel\n"
|
|
|
|
"\tSpecify an optional bitdepth to use in fullscreen mode\n"
|
|
|
|
"\twith a DirectDraw engine.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-[no]emulate3buttons [timeout]\n"
|
|
|
|
"\tEmulate 3 button mouse with an optional timeout in\n"
|
|
|
|
"\tmilliseconds.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2009-11-02 18:37:14 +01:00
|
|
|
#ifdef XWIN_EMULATEPSEUDO
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-emulatepseudo\n"
|
|
|
|
"\tCreate a depth 8 PseudoColor visual when running in\n"
|
|
|
|
"\tdepths 15, 16, 24, or 32, collectively known as TrueColor\n"
|
|
|
|
"\tdepths. The PseudoColor visual does not have correct colors,\n"
|
|
|
|
"\tand it may crash, but it at least allows you to run your\n"
|
|
|
|
"\tapplication in TrueColor modes.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-engine engine_type_id\n"
|
|
|
|
"\tOverride the server's automatically selected engine type:\n"
|
|
|
|
"\t\t1 - Shadow GDI\n"
|
|
|
|
"\t\t4 - Shadow DirectDraw4 Non-Locking\n"
|
|
|
|
);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2011-11-07 21:54:10 +01:00
|
|
|
ErrorF("-[no]hostintitle\n"
|
2011-11-07 21:54:10 +01:00
|
|
|
"\tIn multiwindow mode, add remote host names to window titles.\n");
|
|
|
|
|
2016-02-19 22:53:00 +01:00
|
|
|
ErrorF("-icon icon_specifier\n" "\tSet screen window icon in windowed mode.\n");
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-ignoreinput\n" "\tIgnore keyboard and mouse input.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2009-11-02 18:37:14 +01:00
|
|
|
#ifdef XWIN_XF86CONFIG
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-keyboard\n"
|
|
|
|
"\tSpecify a keyboard device from the configuration file.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-[no]keyhook\n"
|
|
|
|
"\tGrab special Windows keypresses like Alt-Tab or the Menu "
|
|
|
|
"key.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-lesspointer\n"
|
|
|
|
"\tHide the windows mouse pointer when it is over any\n"
|
|
|
|
"\t" EXECUTABLE_NAME
|
|
|
|
" window. This prevents ghost cursors appearing when\n"
|
|
|
|
"\tthe Windows cursor is drawn on top of the X cursor\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-logfile filename\n" "\tWrite log messages to <filename>.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-logverbose verbosity\n"
|
|
|
|
"\tSet the verbosity of log messages. [NOTE: Only a few messages\n"
|
|
|
|
"\trespect the settings yet]\n"
|
|
|
|
"\t\t0 - only print fatal error.\n"
|
|
|
|
"\t\t1 - print additional configuration information.\n"
|
|
|
|
"\t\t2 - print additional runtime information [default].\n"
|
|
|
|
"\t\t3 - print debugging and tracing information.\n");
|
2009-11-02 18:37:14 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-[no]multimonitors or -[no]multiplemonitors\n"
|
|
|
|
"\tUse the entire virtual screen if multiple\n"
|
|
|
|
"\tmonitors are present.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-multiwindow\n" "\tRun the server in multi-window mode.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-nodecoration\n"
|
|
|
|
"\tDo not draw a window border, title bar, etc. Windowed\n"
|
|
|
|
"\tmode only.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2013-09-24 16:09:22 +02:00
|
|
|
ErrorF("-[no]primary\n"
|
|
|
|
"\tWhen clipboard integration is enabled, map the X11 PRIMARY selection\n"
|
|
|
|
"\tto the Windows clipboard. Default is enabled.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-refresh rate_in_Hz\n"
|
|
|
|
"\tSpecify an optional refresh rate to use in fullscreen mode\n"
|
|
|
|
"\twith a DirectDraw engine.\n");
|
|
|
|
|
2017-01-05 14:17:59 +01:00
|
|
|
ErrorF("-resize=none|scrollbars|randr\n"
|
2012-03-21 20:55:09 +01:00
|
|
|
"\tIn windowed mode, [don't] allow resizing of the window. 'scrollbars'\n"
|
|
|
|
"\tmode gives the window scrollbars as needed, 'randr' mode uses the RANR\n"
|
2012-01-04 18:40:14 +01:00
|
|
|
"\textension to resize the X screen. 'randr' is the default.\n");
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
ErrorF("-rootless\n" "\tRun the server in rootless mode.\n");
|
|
|
|
|
|
|
|
ErrorF("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
|
|
|
|
"\tEnable screen scr_num and optionally specify a width and\n"
|
|
|
|
"\theight and initial position for that screen. Additionally\n"
|
|
|
|
"\ta monitor number can be specified to start the server on,\n"
|
|
|
|
"\tat which point, all coordinates become relative to that\n"
|
|
|
|
"\tmonitor. Examples:\n"
|
|
|
|
"\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
|
|
|
|
"\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
|
|
|
|
"\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
|
|
|
|
|
|
|
|
ErrorF("-swcursor\n"
|
|
|
|
"\tDisable the usage of the Windows cursor and use the X11 software\n"
|
|
|
|
"\tcursor instead.\n");
|
|
|
|
|
|
|
|
ErrorF("-[no]trayicon\n"
|
|
|
|
"\tDo not create a tray icon. Default is to create one\n"
|
|
|
|
"\ticon per screen. You can globally disable tray icons with\n"
|
|
|
|
"\t-notrayicon, then enable it for specific screens with\n"
|
|
|
|
"\t-trayicon for those screens.\n");
|
|
|
|
|
|
|
|
ErrorF("-[no]unixkill\n" "\tCtrl+Alt+Backspace exits the X Server.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2009-11-07 20:28:18 +01:00
|
|
|
#ifdef XWIN_GLX_WINDOWS
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-[no]wgl\n"
|
2012-01-01 05:11:18 +01:00
|
|
|
"\tEnable the GLX extension to use the native Windows WGL interface for hardware-accelerated OpenGL\n");
|
2009-11-07 20:28:18 +01:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-[no]winkill\n" "\tAlt+F4 exits the X Server.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-xkblayout XKBLayout\n"
|
|
|
|
"\tEquivalent to XKBLayout in XF86Config files.\n"
|
|
|
|
"\tFor example: -xkblayout de\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-xkbmodel XKBModel\n"
|
|
|
|
"\tEquivalent to XKBModel in XF86Config files.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-xkboptions XKBOptions\n"
|
|
|
|
"\tEquivalent to XKBOptions in XF86Config files.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-xkbrules XKBRules\n"
|
|
|
|
"\tEquivalent to XKBRules in XF86Config files.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-xkbvariant XKBVariant\n"
|
|
|
|
"\tEquivalent to XKBVariant in XF86Config files.\n"
|
|
|
|
"\tFor example: -xkbvariant nodeadkeys\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* See Porting Layer Definition - p. 57 */
|
|
|
|
void
|
|
|
|
ddxUseMsg(void)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Set a flag so that FatalError won't give duplicate warning message */
|
|
|
|
g_fSilentFatalError = TRUE;
|
|
|
|
|
|
|
|
winUseMsg();
|
|
|
|
|
|
|
|
/* Log file will not be opened for UseMsg unless we open it now */
|
|
|
|
if (!g_fLogInited) {
|
2014-10-11 15:49:16 +02:00
|
|
|
g_pszLogFile = LogInit(g_pszLogFile, ".old");
|
2012-03-21 20:55:09 +01:00
|
|
|
g_fLogInited = TRUE;
|
|
|
|
}
|
|
|
|
LogClose(EXIT_NO_ERROR);
|
|
|
|
|
|
|
|
/* Notify user where UseMsg text can be found. */
|
|
|
|
if (!g_fNoHelpMessageBox)
|
|
|
|
winMessageBoxF("The " PROJECT_NAME " help text has been printed to "
|
|
|
|
"%s.\n"
|
|
|
|
"Please open %s to read the help text.\n",
|
|
|
|
MB_ICONINFORMATION, g_pszLogFile, g_pszLogFile);
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* See Porting Layer Definition - p. 20 */
|
|
|
|
/*
|
|
|
|
* Do any global initialization, then initialize each screen.
|
2014-10-31 00:45:12 +01:00
|
|
|
*
|
2008-04-20 17:35:42 +02:00
|
|
|
* NOTE: We use ddxProcessArgument, so we don't need to touch argc and argv
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-01-25 20:17:16 +01:00
|
|
|
InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
|
2008-04-20 17:35:42 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int i;
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-09-02 16:17:05 +02:00
|
|
|
if (serverGeneration == 1)
|
|
|
|
XwinExtensionInit();
|
2012-07-12 01:36:43 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Log the command line */
|
|
|
|
winLogCommandLine(argc, argv);
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#if CYGDEBUG
|
2012-03-21 20:55:09 +01:00
|
|
|
winDebug("InitOutput\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Validate command-line arguments */
|
|
|
|
if (serverGeneration == 1 && !winValidateArgs()) {
|
|
|
|
FatalError("InitOutput - Invalid command-line arguments found. "
|
|
|
|
"Exiting.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XWIN_XF86CONFIG
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Try to read the xorg.conf-style configuration file */
|
|
|
|
if (!winReadConfigfile())
|
|
|
|
winErrorFVerb(1, "InitOutput - Error reading config file\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
winMsg(X_INFO, "xorg.conf is not supported\n");
|
|
|
|
winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html "
|
|
|
|
"for more information\n");
|
|
|
|
winConfigFiles();
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Load preferences from XWinrc file */
|
|
|
|
LoadPreferences();
|
|
|
|
|
|
|
|
/* Setup global screen info parameters */
|
2012-01-25 20:17:16 +01:00
|
|
|
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
|
|
|
|
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
|
|
|
|
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
|
|
|
|
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
|
2017-10-27 16:11:56 +02:00
|
|
|
pScreenInfo->numPixmapFormats = ARRAY_SIZE(g_PixmapFormats);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
/* Describe how we want common pixmap formats padded */
|
2017-10-27 16:11:56 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(g_PixmapFormats); i++) {
|
2012-01-25 20:17:16 +01:00
|
|
|
pScreenInfo->formats[i] = g_PixmapFormats[i];
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Load pointers to DirectDraw functions */
|
|
|
|
winGetDDProcAddresses();
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Detect supported engines */
|
|
|
|
winDetectSupportedEngines();
|
2011-07-18 15:48:23 +02:00
|
|
|
/* Load libraries for taskbar grouping */
|
|
|
|
winPropertyStoreInit();
|
2008-04-20 17:35:42 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Store the instance handle */
|
|
|
|
g_hInstance = GetModuleHandle(NULL);
|
|
|
|
|
hw/xwin: Improve WM_ENDSESSION handling using separate messaging window thread
Currently, WM_ENDSESSION just calls GiveUp() to set the DE_TERMINATE flag. But
for the X server to exit cleanly, we also need the X server dispatch loop to be
unblocked so it can notice that DE_TERMINATE has been set and exit, removing
it's lock file and any unix domain socket.
It appears that the system will terminate the process when the last UI thread in
that process returns from processing WM_ENDSESSION for the last top-level
window.
Since WM_ENDSESSION appears to sent by the system via SendMessage()
(synchronously) and the wndproc is called to process it in the message thread
for that window (the X server thread), we can't easily terminate the X server
dispatch loop from inside the WM_ENDSESSION message processing.
So, create a messaging window, a hidden, top-level window, with a separate
thread to catch this message, and process it by calling GiveUp() and then
blocking on a mutex until the X server dispatch loop exits.
Also, notice when this is a shutdown cancel WM_ENDSESSION message and take no
action.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2011-08-31 22:35:14 +02:00
|
|
|
/* Create the messaging window */
|
|
|
|
if (serverGeneration == 1)
|
|
|
|
winCreateMsgWindowThread();
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Initialize each screen */
|
|
|
|
for (i = 0; i < g_iNumScreens; ++i) {
|
|
|
|
/* Initialize the screen */
|
|
|
|
if (-1 == AddScreen(winScreenInit, argc, argv)) {
|
|
|
|
FatalError("InitOutput - Couldn't add screen %d", i);
|
|
|
|
}
|
2008-04-20 17:35:42 +02:00
|
|
|
}
|
|
|
|
|
2014-11-06 15:28:17 +01:00
|
|
|
/*
|
|
|
|
Unless full xinerama has been explicitly enabled, register all native screens with pseudoramiX
|
|
|
|
*/
|
|
|
|
if (!noPanoramiXExtension)
|
|
|
|
noPseudoramiXExtension = TRUE;
|
|
|
|
|
|
|
|
if ((g_ScreenInfo[0].fMultipleMonitors) && !noPseudoramiXExtension)
|
|
|
|
{
|
|
|
|
int pass;
|
|
|
|
|
|
|
|
PseudoramiXExtensionInit();
|
|
|
|
|
|
|
|
/* Add primary monitor on pass 0, other monitors on pass 1, to ensure
|
|
|
|
the primary monitor is first in XINERAMA list */
|
|
|
|
for (pass = 0; pass < 2; pass++)
|
|
|
|
{
|
|
|
|
int iMonitor;
|
|
|
|
|
|
|
|
for (iMonitor = 1; ; iMonitor++)
|
|
|
|
{
|
|
|
|
struct GetMonitorInfoData data;
|
2017-04-19 15:50:38 +02:00
|
|
|
if (QueryMonitor(iMonitor, &data))
|
2014-11-06 15:28:17 +01:00
|
|
|
{
|
|
|
|
MONITORINFO mi;
|
|
|
|
mi.cbSize = sizeof(MONITORINFO);
|
|
|
|
|
|
|
|
if (GetMonitorInfo(data.monitorHandle, &mi))
|
|
|
|
{
|
|
|
|
/* pass == 1 XOR primary monitor flags is set */
|
|
|
|
if ((!(pass == 1)) != (!(mi.dwFlags & MONITORINFOF_PRIMARY)))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Note the screen origin in a normalized coordinate space where (0,0) is at the top left
|
|
|
|
of the native virtual desktop area
|
|
|
|
*/
|
|
|
|
data.monitorOffsetX = data.monitorOffsetX - GetSystemMetrics(SM_XVIRTUALSCREEN);
|
|
|
|
data.monitorOffsetY = data.monitorOffsetY - GetSystemMetrics(SM_YVIRTUALSCREEN);
|
|
|
|
|
|
|
|
winDebug ("InitOutput - screen %d added at virtual desktop coordinate (%d,%d) (pseudoramiX) \n",
|
|
|
|
iMonitor-1, data.monitorOffsetX, data.monitorOffsetY);
|
|
|
|
|
|
|
|
PseudoramiXAddScreen(data.monitorOffsetX, data.monitorOffsetY,
|
|
|
|
data.monitorWidth, data.monitorHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 17:44:37 +01:00
|
|
|
xorgGlxCreateVendor();
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Generate a cookie used by internal clients for authorization */
|
|
|
|
if (g_fXdmcpEnabled || g_fAuthEnabled)
|
|
|
|
winGenerateAuthorization();
|
|
|
|
|
2008-04-20 17:35:42 +02:00
|
|
|
|
|
|
|
#if CYGDEBUG || YES
|
2012-03-21 20:55:09 +01:00
|
|
|
winDebug("InitOutput - Returning.\n");
|
2008-04-20 17:35:42 +02:00
|
|
|
#endif
|
|
|
|
}
|