Drop Xwin DDX
This commit is contained in:
parent
69cc6a6caa
commit
8f480147f6
|
@ -72,7 +72,7 @@ cache:
|
|||
- '%CYGWIN_ROOT%\home\%USERNAME%\.ccache'
|
||||
build_script:
|
||||
- SET PATH=%CYGWIN_ROOT%/bin
|
||||
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; meson setup --prefix=/usr -Dxv=false -Dxf86bigfont=true -Dxephyr=true -Dxvfb=true -Dxwin=true -Dxorg=true -Dhal=false -Dudev=false -Dpciaccess=false -Dint10=false build"'
|
||||
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; meson setup --prefix=/usr -Dxv=false -Dxf86bigfont=true -Dxephyr=true -Dxvfb=true -Dxorg=true -Dhal=false -Dudev=false -Dpciaccess=false -Dint10=false build"'
|
||||
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; meson configure build"'
|
||||
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ninja -C build"'
|
||||
- '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ccache -s"'
|
||||
|
|
|
@ -13,7 +13,3 @@ endif
|
|||
if build_xwayland
|
||||
subdir('xwayland')
|
||||
endif
|
||||
|
||||
if build_xwin
|
||||
subdir('xwin')
|
||||
endif
|
||||
|
|
3
hw/xwin/.gitignore
vendored
3
hw/xwin/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
winprefslex.c
|
||||
winprefsyacc.c
|
||||
winprefsyacc.h
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
|
||||
Copyright 1993, 1998 The Open Group
|
||||
|
||||
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 "dixstruct.h"
|
||||
#include "inputstr.h"
|
||||
|
||||
/*
|
||||
* Local function prototypes
|
||||
*/
|
||||
|
||||
int winProcEstablishConnection(ClientPtr /* client */ );
|
||||
|
||||
/*
|
||||
* Local global declarations
|
||||
*/
|
||||
|
||||
DeviceIntPtr g_pwinPointer;
|
||||
DeviceIntPtr g_pwinKeyboard;
|
||||
|
||||
/* Called from dix/dispatch.c */
|
||||
/*
|
||||
* Run through the Windows message queue(s) one more time.
|
||||
* Tell mi to dequeue the events that we have sent it.
|
||||
*/
|
||||
void
|
||||
ProcessInputEvents(void)
|
||||
{
|
||||
#if 0
|
||||
ErrorF("ProcessInputEvents\n");
|
||||
#endif
|
||||
|
||||
mieqProcessInputEvents();
|
||||
|
||||
#if 0
|
||||
ErrorF("ProcessInputEvents - returning\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
DDXRingBell(int volume, int pitch, int duration)
|
||||
{
|
||||
/* winKeybdBell is used instead */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
static void
|
||||
xwinDevWindowsHandlerNotify(int fd, int ready, void *data)
|
||||
{
|
||||
/* This should process Windows messages, but instead all of that is delayed
|
||||
* until the wakeup handler is called.
|
||||
*/
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* See Porting Layer Definition - p. 17 */
|
||||
void
|
||||
InitInput(int argc, char *argv[])
|
||||
{
|
||||
#if CYGDEBUG
|
||||
winDebug("InitInput\n");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wrap some functions at every generation of the server.
|
||||
*/
|
||||
if (InitialVector[2] != winProcEstablishConnection) {
|
||||
winProcEstablishConnectionOrig = InitialVector[2];
|
||||
InitialVector[2] = winProcEstablishConnection;
|
||||
}
|
||||
|
||||
if (AllocDevicePair(serverClient, "Windows",
|
||||
&g_pwinPointer, &g_pwinKeyboard,
|
||||
winMouseProc, winKeybdProc,
|
||||
FALSE) != Success)
|
||||
FatalError("InitInput - Failed to allocate slave devices.\n");
|
||||
|
||||
mieqInit();
|
||||
|
||||
/* Initialize the mode key states */
|
||||
winInitializeModeKeyStates();
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
/* Only open the windows message queue device once */
|
||||
if (g_fdMessageQueue == WIN_FD_INVALID) {
|
||||
/* Open a file descriptor for the Windows message queue */
|
||||
g_fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
|
||||
|
||||
if (g_fdMessageQueue == -1) {
|
||||
FatalError("InitInput - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
|
||||
}
|
||||
|
||||
/* Add the message queue as a device to wait for in WaitForSomething */
|
||||
SetNotifyFd(g_fdMessageQueue, xwinDevWindowsHandlerNotify, X_NOTIFY_READ, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("InitInput - returning\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
CloseInput(void)
|
||||
{
|
||||
mieqFini();
|
||||
}
|
1026
hw/xwin/InitOutput.c
1026
hw/xwin/InitOutput.c
File diff suppressed because it is too large
Load Diff
BIN
hw/xwin/X.ico
BIN
hw/xwin/X.ico
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<description>The XWin X Windows server</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
109
hw/xwin/XWin.rc
109
hw/xwin/XWin.rc
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) 2008 Yaakov Selkowitz All Rights Reserved
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 names of the authors
|
||||
*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 authors.
|
||||
*
|
||||
* Authors: Harold L Hunt II, Yaakov Selkowitz
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "winresource.h"
|
||||
#include "xwin-config.h"
|
||||
#include "version-config.h"
|
||||
|
||||
/*
|
||||
* Dialogs
|
||||
*/
|
||||
|
||||
/* About */
|
||||
ABOUT_BOX DIALOGEX 32, 32, 260, 105
|
||||
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
|
||||
CAPTION "About " XVENDORNAMESHORT
|
||||
FONT 8, "MS Shell Dlg 2"
|
||||
BEGIN
|
||||
CONTROL IDI_XWIN, IDC_STATIC, "Static", SS_ICON, 8, 8, 32, 32
|
||||
LTEXT XVENDORNAMESHORT " X Server ", IDC_STATIC, 36, 8, 220, 8
|
||||
LTEXT VENDOR_MAN_VERSION, IDC_STATIC, 36, 18, 220, 8
|
||||
LTEXT BUILDERSTRING, IDC_STATIC, 36, 28, 220, 8
|
||||
LTEXT "This software is licensed under the terms of the MIT/X11 License.", IDC_STATIC, 36, 48, 220, 20
|
||||
CONTROL __VENDORDWEBSUPPORT__, ID_ABOUT_WEBSITE, "Button",
|
||||
BS_OWNERDRAW | WS_TABSTOP, 36, 68, 220, 8
|
||||
DEFPUSHBUTTON "&OK", IDOK, 105, 85, 50, 15
|
||||
END
|
||||
|
||||
|
||||
/* Depth change */
|
||||
|
||||
DEPTH_CHANGE_BOX DIALOGEX 32, 32, 180, 100
|
||||
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTERMOUSE
|
||||
FONT 8, "MS Shell Dlg 2"
|
||||
CAPTION XVENDORNAMESHORT
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14
|
||||
CTEXT XVENDORNAMESHORT, IDC_STATIC, 40, 12, 100, 8
|
||||
CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8
|
||||
CTEXT "Restore previous resolution to use " XVENDORNAMESHORT ".", IDC_STATIC, 7, 52, 166, 8
|
||||
END
|
||||
|
||||
|
||||
/* Exit */
|
||||
|
||||
EXIT_DIALOG DIALOGEX 32, 32, 180, 78
|
||||
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
|
||||
FONT 8, "MS Shell Dlg 2"
|
||||
CAPTION "Exit " XVENDORNAMESHORT "?"
|
||||
BEGIN
|
||||
PUSHBUTTON "E&xit", IDOK, 55, 56, 30, 14
|
||||
DEFPUSHBUTTON "&Cancel", IDCANCEL, 95, 56, 30, 14
|
||||
CTEXT "E&xiting will close all screens running on this display.", IDC_STATIC, 7, 12, 166, 8
|
||||
CTEXT "No information about connected clients available.", IDC_CLIENTS_CONNECTED, 7, 24, 166, 8
|
||||
CTEXT "Proceed with shutdown of this display/server?", IDC_STATIC, 7, 36, 166, 8
|
||||
END
|
||||
|
||||
|
||||
/*
|
||||
* Menus
|
||||
*/
|
||||
|
||||
IDM_TRAYICON_MENU MENU
|
||||
BEGIN
|
||||
POPUP "TRAYICON_MENU"
|
||||
BEGIN
|
||||
MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT
|
||||
MENUITEM "Clipboard may use &PRIMARY selection", ID_APP_MONITOR_PRIMARY
|
||||
MENUITEM "&About...", ID_APP_ABOUT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit...", ID_APP_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/*
|
||||
* Icons
|
||||
*/
|
||||
|
||||
IDI_XWIN ICON "X.ico"
|
||||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "XWin.exe.manifest"
|
2322
hw/xwin/ddraw.h
2322
hw/xwin/ddraw.h
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +0,0 @@
|
|||
srcs_windows_dri = [
|
||||
'windowsdri.c',
|
||||
'windowsdri.h',
|
||||
]
|
||||
|
||||
xwin_windowsdri = static_library(
|
||||
'WindowsDRI',
|
||||
srcs_windows_dri,
|
||||
include_directories: [ inc, include_directories('../') ],
|
||||
dependencies: [
|
||||
windowsdri_dep,
|
||||
pixman_dep,
|
||||
],
|
||||
)
|
|
@ -1,274 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Jon Turney
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/extensions/windowsdristr.h>
|
||||
|
||||
#include "dixstruct.h"
|
||||
#include "extnsionst.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "swaprep.h"
|
||||
#include "protocol-versions.h"
|
||||
#include "windowsdri.h"
|
||||
#include "glx/dri_helpers.h"
|
||||
|
||||
static int WindowsDRIErrorBase = 0;
|
||||
static unsigned char WindowsDRIReqCode = 0;
|
||||
static int WindowsDRIEventBase = 0;
|
||||
|
||||
static void
|
||||
WindowsDRIResetProc(ExtensionEntry* extEntry)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
ProcWindowsDRIQueryVersion(ClientPtr client)
|
||||
{
|
||||
xWindowsDRIQueryVersionReply rep;
|
||||
|
||||
REQUEST_SIZE_MATCH(xWindowsDRIQueryVersionReq);
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.majorVersion = SERVER_WINDOWSDRI_MAJOR_VERSION;
|
||||
rep.minorVersion = SERVER_WINDOWSDRI_MINOR_VERSION;
|
||||
rep.patchVersion = SERVER_WINDOWSDRI_PATCH_VERSION;
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
swaps(&rep.majorVersion);
|
||||
swaps(&rep.minorVersion);
|
||||
swapl(&rep.patchVersion);
|
||||
}
|
||||
WriteToClient(client, sizeof(xWindowsDRIQueryVersionReply), &rep);
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
ProcWindowsDRIQueryDirectRenderingCapable(ClientPtr client)
|
||||
{
|
||||
xWindowsDRIQueryDirectRenderingCapableReply rep;
|
||||
|
||||
REQUEST(xWindowsDRIQueryDirectRenderingCapableReq);
|
||||
REQUEST_SIZE_MATCH(xWindowsDRIQueryDirectRenderingCapableReq);
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
if (!client->local)
|
||||
rep.isCapable = 0;
|
||||
else
|
||||
rep.isCapable = glxWinGetScreenAiglxIsActive(screenInfo.screens[stuff->screen]);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
}
|
||||
|
||||
WriteToClient(client,
|
||||
sizeof(xWindowsDRIQueryDirectRenderingCapableReply),
|
||||
&rep);
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
ProcWindowsDRIQueryDrawable(ClientPtr client)
|
||||
{
|
||||
xWindowsDRIQueryDrawableReply rep;
|
||||
int rc;
|
||||
|
||||
REQUEST(xWindowsDRIQueryDrawableReq);
|
||||
REQUEST_SIZE_MATCH(xWindowsDRIQueryDrawableReq);
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
rc = glxWinQueryDrawable(client, stuff->drawable, &(rep.drawable_type), &(rep.handle));
|
||||
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
swapl(&rep.handle);
|
||||
swapl(&rep.drawable_type);
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(xWindowsDRIQueryDrawableReply), &rep);
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
ProcWindowsDRIFBConfigToPixelFormat(ClientPtr client)
|
||||
{
|
||||
xWindowsDRIFBConfigToPixelFormatReply rep;
|
||||
|
||||
REQUEST(xWindowsDRIFBConfigToPixelFormatReq);
|
||||
REQUEST_SIZE_MATCH(xWindowsDRIFBConfigToPixelFormatReq);
|
||||
rep.type = X_Reply;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
rep.pixelFormatIndex = glxWinFBConfigIDToPixelFormatIndex(stuff->screen, stuff->fbConfigID);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
swapl(&rep.pixelFormatIndex);
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(xWindowsDRIFBConfigToPixelFormatReply), &rep);
|
||||
return Success;
|
||||
}
|
||||
|
||||
/* dispatch */
|
||||
|
||||
static int
|
||||
ProcWindowsDRIDispatch(ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
|
||||
switch (stuff->data) {
|
||||
case X_WindowsDRIQueryVersion:
|
||||
return ProcWindowsDRIQueryVersion(client);
|
||||
|
||||
case X_WindowsDRIQueryDirectRenderingCapable:
|
||||
return ProcWindowsDRIQueryDirectRenderingCapable(client);
|
||||
}
|
||||
|
||||
if (!client->local)
|
||||
return WindowsDRIErrorBase + WindowsDRIClientNotLocal;
|
||||
|
||||
switch (stuff->data) {
|
||||
case X_WindowsDRIQueryDrawable:
|
||||
return ProcWindowsDRIQueryDrawable(client);
|
||||
|
||||
case X_WindowsDRIFBConfigToPixelFormat:
|
||||
return ProcWindowsDRIFBConfigToPixelFormat(client);
|
||||
|
||||
default:
|
||||
return BadRequest;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SNotifyEvent(xWindowsDRINotifyEvent *from,
|
||||
xWindowsDRINotifyEvent *to)
|
||||
{
|
||||
to->type = from->type;
|
||||
to->kind = from->kind;
|
||||
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
||||
cpswapl(from->time, to->time);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcWindowsDRIQueryVersion(ClientPtr client)
|
||||
{
|
||||
REQUEST(xWindowsDRIQueryVersionReq);
|
||||
swaps(&stuff->length);
|
||||
return ProcWindowsDRIQueryVersion(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcWindowsDRIQueryDirectRenderingCapable(ClientPtr client)
|
||||
{
|
||||
REQUEST(xWindowsDRIQueryDirectRenderingCapableReq);
|
||||
swaps(&stuff->length);
|
||||
swapl(&stuff->screen);
|
||||
return ProcWindowsDRIQueryDirectRenderingCapable(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcWindowsDRIQueryDrawable(ClientPtr client)
|
||||
{
|
||||
REQUEST(xWindowsDRIQueryDrawableReq);
|
||||
swaps(&stuff->length);
|
||||
swapl(&stuff->screen);
|
||||
swapl(&stuff->drawable);
|
||||
return ProcWindowsDRIQueryDrawable(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcWindowsDRIFBConfigToPixelFormat(ClientPtr client)
|
||||
{
|
||||
REQUEST(xWindowsDRIFBConfigToPixelFormatReq);
|
||||
swaps(&stuff->length);
|
||||
swapl(&stuff->screen);
|
||||
swapl(&stuff->fbConfigID);
|
||||
return ProcWindowsDRIFBConfigToPixelFormat(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcWindowsDRIDispatch(ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
|
||||
switch (stuff->data) {
|
||||
case X_WindowsDRIQueryVersion:
|
||||
return SProcWindowsDRIQueryVersion(client);
|
||||
|
||||
case X_WindowsDRIQueryDirectRenderingCapable:
|
||||
return SProcWindowsDRIQueryDirectRenderingCapable(client);
|
||||
}
|
||||
|
||||
if (!client->local)
|
||||
return WindowsDRIErrorBase + WindowsDRIClientNotLocal;
|
||||
|
||||
switch (stuff->data) {
|
||||
case X_WindowsDRIQueryDrawable:
|
||||
return SProcWindowsDRIQueryDrawable(client);
|
||||
|
||||
case X_WindowsDRIFBConfigToPixelFormat:
|
||||
return SProcWindowsDRIFBConfigToPixelFormat(client);
|
||||
|
||||
default:
|
||||
return BadRequest;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WindowsDRIExtensionInit(void)
|
||||
{
|
||||
ExtensionEntry* extEntry;
|
||||
|
||||
if ((extEntry = AddExtension(WINDOWSDRINAME,
|
||||
WindowsDRINumberEvents,
|
||||
WindowsDRINumberErrors,
|
||||
ProcWindowsDRIDispatch,
|
||||
SProcWindowsDRIDispatch,
|
||||
WindowsDRIResetProc,
|
||||
StandardMinorOpcode))) {
|
||||
size_t i;
|
||||
WindowsDRIReqCode = (unsigned char)extEntry->base;
|
||||
WindowsDRIErrorBase = extEntry->errorBase;
|
||||
WindowsDRIEventBase = extEntry->eventBase;
|
||||
for (i = 0; i < WindowsDRINumberEvents; i++)
|
||||
EventSwapVector[WindowsDRIEventBase + i] = (EventSwapPtr)SNotifyEvent;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Jon Turney
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifndef windowsdri_h
|
||||
#define windowsdri_h
|
||||
|
||||
void WindowsDRIExtensionInit(void);
|
||||
|
||||
#endif /* windowsdri_h */
|
6
hw/xwin/glx/.gitignore
vendored
6
hw/xwin/glx/.gitignore
vendored
|
@ -1,6 +0,0 @@
|
|||
# ignore generated files
|
||||
diag.txt
|
||||
generated_gl_shim.c
|
||||
generated_gl_thunks.c
|
||||
generated_gl_thunks.def
|
||||
generated_wgl_wrappers.c
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Jon Turney
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <glx/glxserver.h>
|
||||
#include <glx/glxutil.h>
|
||||
#include <X11/extensions/windowsdriconst.h>
|
||||
|
||||
#include "indirect.h"
|
||||
#include "winpriv.h"
|
||||
#include "dri_helpers.h"
|
||||
#include "win.h"
|
||||
|
||||
int
|
||||
glxWinQueryDrawable(ClientPtr client, XID drawId, unsigned int *type, unsigned int *handle)
|
||||
{
|
||||
__GLXWinDrawable *pDrawable;
|
||||
int err;
|
||||
|
||||
if (validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY,
|
||||
DixReadAccess, (__GLXdrawable **)&pDrawable, &err)) {
|
||||
|
||||
switch (pDrawable->base.type)
|
||||
{
|
||||
case GLX_DRAWABLE_WINDOW:
|
||||
{
|
||||
HWND h = winGetWindowInfo((WindowPtr)(pDrawable->base.pDraw));
|
||||
*handle = (uintptr_t)h;
|
||||
*type = WindowsDRIDrawableWindow;
|
||||
}
|
||||
break;
|
||||
|
||||
case GLX_DRAWABLE_PIXMAP:
|
||||
glxWinDeferredCreateDrawable(pDrawable, pDrawable->base.config);
|
||||
*handle = pDrawable->base.pDraw->id;
|
||||
// The XID is used to create a unique name for a file mapping
|
||||
// shared with the requesting process
|
||||
//
|
||||
// XXX: Alternatively, we could use an anonymous file mapping
|
||||
// and use DuplicateHandle to make pDrawable->hSection available
|
||||
// to the requesting process... ?
|
||||
*type = WindowsDRIDrawablePixmap;
|
||||
break;
|
||||
|
||||
case GLX_DRAWABLE_PBUFFER:
|
||||
glxWinDeferredCreateDrawable(pDrawable, pDrawable->base.config);
|
||||
*handle = (uintptr_t)(pDrawable->hPbuffer);
|
||||
*type = WindowsDRIDrawablePbuffer;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(FALSE);
|
||||
*handle = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
HWND h;
|
||||
/* The drawId XID doesn't identify a GLX drawable. The only other valid
|
||||
alternative is that it is the XID of a window drawable that is being
|
||||
used by the pre-GLX 1.3 interface */
|
||||
DrawablePtr pDraw;
|
||||
int rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess);
|
||||
if (rc != Success || pDraw->type != DRAWABLE_WINDOW) {
|
||||
return err;
|
||||
}
|
||||
|
||||
h = winGetWindowInfo((WindowPtr)(pDraw));
|
||||
*handle = (uintptr_t)h;
|
||||
*type = WindowsDRIDrawableWindow;
|
||||
}
|
||||
|
||||
winDebug("glxWinQueryDrawable: type %d, handle %p\n", *type, (void *)(uintptr_t)*handle);
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
glxWinFBConfigIDToPixelFormatIndex(int scr, int fbConfigID)
|
||||
{
|
||||
__GLXscreen *screen = glxGetScreen(screenInfo.screens[scr]);
|
||||
__GLXconfig *c;
|
||||
|
||||
for (c = screen->fbconfigs;
|
||||
c != NULL;
|
||||
c = c->next) {
|
||||
if (c->fbconfigID == fbConfigID)
|
||||
return ((GLXWinConfig *)c)->pixelFormatIndex;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Bool
|
||||
glxWinGetScreenAiglxIsActive(ScreenPtr pScreen)
|
||||
{
|
||||
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
|
||||
return pWinScreen->fNativeGlActive;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Jon Turney
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifndef dri_helpers_h
|
||||
#define dri_helpers_h
|
||||
|
||||
#include "dixstruct.h"
|
||||
|
||||
int
|
||||
glxWinQueryDrawable(ClientPtr client, XID drawId, unsigned int *type, unsigned int *handle);
|
||||
|
||||
int
|
||||
glxWinFBConfigIDToPixelFormatIndex(int scr, int fbConfigID);
|
||||
|
||||
Bool
|
||||
glxWinGetScreenAiglxIsActive(ScreenPtr pScreen);
|
||||
|
||||
#endif /* dri_helpers_h */
|
|
@ -1,471 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
#
|
||||
# python script to generate cdecl to stdcall wrappers for GL functions
|
||||
# adapted from genheaders.py
|
||||
#
|
||||
# Copyright (c) 2013 The Khronos Group Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and/or associated documentation files (the
|
||||
# "Materials"), to deal in the Materials without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
# permit persons to whom the Materials are furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Materials.
|
||||
#
|
||||
# THE MATERIALS ARE 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 AUTHORS OR COPYRIGHT HOLDERS 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
|
||||
# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
|
||||
import sys, time, pdb, string, cProfile
|
||||
from reg import *
|
||||
|
||||
# Default input / log files
|
||||
errFilename = None
|
||||
diagFilename = 'diag.txt'
|
||||
regFilename = 'gl.xml'
|
||||
outFilename = 'gen_gl_wrappers.c'
|
||||
|
||||
protect=True
|
||||
prefix="gl"
|
||||
preresolve=False
|
||||
wrapper=False
|
||||
shim=False
|
||||
thunk=False
|
||||
thunkdefs=False
|
||||
staticwrappers=False
|
||||
nodebug=False
|
||||
|
||||
# list of WGL extension functions we use
|
||||
used_wgl_ext_fns = {key: 1 for key in [
|
||||
"wglSwapIntervalEXT",
|
||||
"wglGetExtensionsStringARB",
|
||||
"wglDestroyPbufferARB",
|
||||
"wglGetPbufferDCARB",
|
||||
"wglReleasePbufferDCARB",
|
||||
"wglCreatePbufferARB",
|
||||
"wglMakeContextCurrentARB",
|
||||
"wglChoosePixelFormatARB",
|
||||
"wglGetPixelFormatAttribivARB",
|
||||
"wglGetPixelFormatAttribivARB"
|
||||
]}
|
||||
|
||||
if __name__ == '__main__':
|
||||
i = 1
|
||||
while (i < len(sys.argv)):
|
||||
arg = sys.argv[i]
|
||||
i = i + 1
|
||||
if (arg == '-noprotect'):
|
||||
print('Disabling inclusion protection in output headers', file=sys.stderr)
|
||||
protect = False
|
||||
elif (arg == '-registry'):
|
||||
regFilename = sys.argv[i]
|
||||
i = i+1
|
||||
print('Using registry', regFilename, file=sys.stderr)
|
||||
elif (arg == '-outfile'):
|
||||
outFilename = sys.argv[i]
|
||||
i = i+1
|
||||
elif (arg == '-preresolve'):
|
||||
preresolve=True
|
||||
elif (arg == '-wrapper'):
|
||||
wrapper=True
|
||||
elif (arg == '-shim'):
|
||||
shim=True
|
||||
elif (arg == '-thunk'):
|
||||
thunk=True
|
||||
elif (arg == '-thunkdefs'):
|
||||
thunkdefs=True
|
||||
elif (arg == '-staticwrappers'):
|
||||
staticwrappers=True
|
||||
elif (arg == '-prefix'):
|
||||
prefix = sys.argv[i]
|
||||
i = i+1
|
||||
elif (arg == '-nodebug'):
|
||||
nodebug = True
|
||||
elif (arg[0:1] == '-'):
|
||||
print('Unrecognized argument:', arg, file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
print('Generating', outFilename, file=sys.stderr)
|
||||
|
||||
# Load & parse registry
|
||||
reg = Registry()
|
||||
tree = etree.parse(regFilename)
|
||||
reg.loadElementTree(tree)
|
||||
|
||||
if shim:
|
||||
versions = '1\.[012]'
|
||||
else:
|
||||
versions = '.*'
|
||||
|
||||
genOpts = CGeneratorOptions(
|
||||
apiname = prefix,
|
||||
profile = 'compatibility',
|
||||
versions = versions,
|
||||
emitversions = versions,
|
||||
defaultExtensions = prefix, # Default extensions for GL
|
||||
protectFile = protect,
|
||||
protectFeature = protect,
|
||||
protectProto = protect,
|
||||
)
|
||||
|
||||
# create error/warning & diagnostic files
|
||||
if (errFilename):
|
||||
errWarn = open(errFilename,'w')
|
||||
else:
|
||||
errWarn = sys.stderr
|
||||
diag = open(diagFilename, 'w')
|
||||
|
||||
def ParseCmdRettype(cmd):
|
||||
proto=noneStr(cmd.elem.find('proto'))
|
||||
rettype=noneStr(proto.text)
|
||||
if rettype.lower()!="void ":
|
||||
plist = ([t for t in proto.itertext()])
|
||||
rettype = ''.join(plist[:-1])
|
||||
rettype=rettype.strip()
|
||||
return rettype
|
||||
|
||||
def ParseCmdParams(cmd):
|
||||
params = cmd.elem.findall('param')
|
||||
plist=[]
|
||||
for param in params:
|
||||
# construct the formal parameter definition from ptype and name
|
||||
# elements, also using any text found around these in the
|
||||
# param element, in the order it appears in the document
|
||||
paramtype = ''
|
||||
# also extract the formal parameter name from the name element
|
||||
paramname = ''
|
||||
for t in param.iter():
|
||||
if t.tag == 'ptype' or t.tag == 'param':
|
||||
paramtype = paramtype + noneStr(t.text)
|
||||
if t.tag == 'name':
|
||||
paramname = t.text + '_'
|
||||
paramtype = paramtype + ' ' + paramname
|
||||
if t.tail is not None:
|
||||
paramtype = paramtype + t.tail.strip()
|
||||
plist.append((paramtype, paramname))
|
||||
return plist
|
||||
|
||||
class PreResolveOutputGenerator(OutputGenerator):
|
||||
def __init__(self,
|
||||
errFile = sys.stderr,
|
||||
warnFile = sys.stderr,
|
||||
diagFile = sys.stdout):
|
||||
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
|
||||
self.wrappers={}
|
||||
def beginFile(self, genOpts):
|
||||
self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename)
|
||||
def endFile(self):
|
||||
self.outFile.write('\nvoid ' + prefix + 'ResolveExtensionProcs(void)\n{\n')
|
||||
for funcname in self.wrappers.keys():
|
||||
self.outFile.write( ' PRERESOLVE(PFN' + funcname.upper() + 'PROC, "' + funcname + '");\n')
|
||||
self.outFile.write('}\n\n')
|
||||
def beginFeature(self, interface, emit):
|
||||
OutputGenerator.beginFeature(self, interface, emit)
|
||||
def endFeature(self):
|
||||
OutputGenerator.endFeature(self)
|
||||
def genType(self, typeinfo, name):
|
||||
OutputGenerator.genType(self, typeinfo, name)
|
||||
def genEnum(self, enuminfo, name):
|
||||
OutputGenerator.genEnum(self, enuminfo, name)
|
||||
def genCmd(self, cmd, name):
|
||||
OutputGenerator.genCmd(self, cmd, name)
|
||||
|
||||
if prefix == 'wgl' and not name in used_wgl_ext_fns:
|
||||
return
|
||||
|
||||
self.outFile.write('RESOLVE_DECL(PFN' + name.upper() + 'PROC);\n')
|
||||
self.wrappers[name]=1
|
||||
|
||||
class WrapperOutputGenerator(OutputGenerator):
|
||||
def __init__(self,
|
||||
errFile = sys.stderr,
|
||||
warnFile = sys.stderr,
|
||||
diagFile = sys.stdout):
|
||||
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
|
||||
def beginFile(self, genOpts):
|
||||
self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename)
|
||||
def endFile(self):
|
||||
pass
|
||||
def beginFeature(self, interface, emit):
|
||||
OutputGenerator.beginFeature(self, interface, emit)
|
||||
self.OldVersion = self.featureName.startswith('GL_VERSION_1_0') or self.featureName.startswith('GL_VERSION_1_1')
|
||||
def endFeature(self):
|
||||
OutputGenerator.endFeature(self)
|
||||
def genType(self, typeinfo, name):
|
||||
OutputGenerator.genType(self, typeinfo, name)
|
||||
def genEnum(self, enuminfo, name):
|
||||
OutputGenerator.genEnum(self, enuminfo, name)
|
||||
def genCmd(self, cmd, name):
|
||||
OutputGenerator.genCmd(self, cmd, name)
|
||||
|
||||
if prefix == 'wgl' and not name in used_wgl_ext_fns:
|
||||
return
|
||||
|
||||
rettype=ParseCmdRettype(cmd)
|
||||
|
||||
if staticwrappers: self.outFile.write("static ")
|
||||
self.outFile.write("%s %sWrapper("%(rettype, name))
|
||||
plist=ParseCmdParams(cmd)
|
||||
Comma=""
|
||||
if len(plist):
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, ptype))
|
||||
Comma=", "
|
||||
else:
|
||||
self.outFile.write("void")
|
||||
|
||||
self.outFile.write(")\n{\n")
|
||||
|
||||
# for GL 1.0 and 1.1 functions, generate stdcall wrappers which call the function directly
|
||||
if self.OldVersion:
|
||||
if not nodebug:
|
||||
self.outFile.write(' if (glxWinDebugSettings.enable%scallTrace) ErrorF("%s\\n");\n'%(prefix.upper(), name))
|
||||
self.outFile.write(" glWinDirectProcCalls++;\n")
|
||||
self.outFile.write("\n")
|
||||
|
||||
if rettype.lower()=="void":
|
||||
self.outFile.write(" %s( "%(name))
|
||||
else:
|
||||
self.outFile.write(" return %s( "%(name))
|
||||
|
||||
Comma=""
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, pname))
|
||||
Comma=", "
|
||||
|
||||
# for GL 1.2+ functions, generate stdcall wrappers which use wglGetProcAddress()
|
||||
else:
|
||||
if rettype.lower()=="void":
|
||||
self.outFile.write(' RESOLVE(PFN%sPROC, "%s");\n'%(name.upper(), name))
|
||||
|
||||
if not nodebug:
|
||||
self.outFile.write("\n")
|
||||
self.outFile.write(' if (glxWinDebugSettings.enable%scallTrace) ErrorF("%s\\n");\n'%(prefix.upper(), name))
|
||||
self.outFile.write("\n")
|
||||
|
||||
self.outFile.write(" RESOLVED_PROC(PFN%sPROC)( """%(name.upper()))
|
||||
else:
|
||||
self.outFile.write(' RESOLVE_RET(PFN%sPROC, "%s", FALSE);\n'%(name.upper(), name))
|
||||
|
||||
if not nodebug:
|
||||
self.outFile.write("\n")
|
||||
self.outFile.write(' if (glxWinDebugSettings.enable%scallTrace) ErrorF("%s\\n");\n'%(prefix.upper(), name))
|
||||
self.outFile.write("\n")
|
||||
|
||||
self.outFile.write(" return RESOLVED_PROC(PFN%sPROC)("%(name.upper()))
|
||||
|
||||
Comma=""
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, pname))
|
||||
Comma=", "
|
||||
self.outFile.write(" );\n}\n\n")
|
||||
|
||||
class ThunkOutputGenerator(OutputGenerator):
|
||||
def __init__(self,
|
||||
errFile = sys.stderr,
|
||||
warnFile = sys.stderr,
|
||||
diagFile = sys.stdout):
|
||||
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
|
||||
def beginFile(self, genOpts):
|
||||
self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename)
|
||||
def endFile(self):
|
||||
pass
|
||||
def beginFeature(self, interface, emit):
|
||||
OutputGenerator.beginFeature(self, interface, emit)
|
||||
self.OldVersion = (self.featureName in ['GL_VERSION_1_0', 'GL_VERSION_1_1'])
|
||||
def endFeature(self):
|
||||
OutputGenerator.endFeature(self)
|
||||
def genType(self, typeinfo, name):
|
||||
OutputGenerator.genType(self, typeinfo, name)
|
||||
def genEnum(self, enuminfo, name):
|
||||
OutputGenerator.genEnum(self, enuminfo, name)
|
||||
def genCmd(self, cmd, name):
|
||||
OutputGenerator.genCmd(self, cmd, name)
|
||||
|
||||
rettype=ParseCmdRettype(cmd)
|
||||
self.outFile.write("%s %sWrapper("%(rettype, name))
|
||||
plist=ParseCmdParams(cmd)
|
||||
|
||||
Comma=""
|
||||
if len(plist):
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, ptype))
|
||||
Comma=", "
|
||||
else:
|
||||
self.outFile.write("void")
|
||||
|
||||
self.outFile.write(")\n{\n")
|
||||
|
||||
# for GL 1.0 and 1.1 functions, generate stdcall thunk wrappers which call the function directly
|
||||
if self.OldVersion:
|
||||
if rettype.lower()=="void":
|
||||
self.outFile.write(" %s( "%(name))
|
||||
else:
|
||||
self.outFile.write(" return %s( "%(name))
|
||||
|
||||
Comma=""
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, pname))
|
||||
Comma=", "
|
||||
|
||||
# for GL 1.2+ functions, generate wrappers which use wglGetProcAddress()
|
||||
else:
|
||||
if rettype.lower()=="void":
|
||||
self.outFile.write(' RESOLVE(PFN%sPROC, "%s");\n'%(name.upper(), name))
|
||||
self.outFile.write(" RESOLVED_PROC(PFN%sPROC)( """%(name.upper()))
|
||||
else:
|
||||
self.outFile.write(' RESOLVE_RET(PFN%sPROC, "%s", FALSE);\n'%(name.upper(), name))
|
||||
self.outFile.write(" return RESOLVED_PROC(PFN%sPROC)("%(name.upper()))
|
||||
|
||||
Comma=""
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, pname))
|
||||
Comma=", "
|
||||
self.outFile.write(" );\n}\n\n")
|
||||
|
||||
class ThunkDefsOutputGenerator(OutputGenerator):
|
||||
def __init__(self,
|
||||
errFile = sys.stderr,
|
||||
warnFile = sys.stderr,
|
||||
diagFile = sys.stdout):
|
||||
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
|
||||
def beginFile(self, genOpts):
|
||||
self.outFile.write("EXPORTS\n"); # this must be the first line for libtool to realize this is a .def file
|
||||
self.outFile.write('; Automatically generated from %s - DO NOT EDIT\n\n'%regFilename)
|
||||
def endFile(self):
|
||||
pass
|
||||
def beginFeature(self, interface, emit):
|
||||
OutputGenerator.beginFeature(self, interface, emit)
|
||||
def endFeature(self):
|
||||
OutputGenerator.endFeature(self)
|
||||
def genType(self, typeinfo, name):
|
||||
OutputGenerator.genType(self, typeinfo, name)
|
||||
def genEnum(self, enuminfo, name):
|
||||
OutputGenerator.genEnum(self, enuminfo, name)
|
||||
def genCmd(self, cmd, name):
|
||||
OutputGenerator.genCmd(self, cmd, name)
|
||||
|
||||
# export the wrapper function with the name of the function it wraps
|
||||
self.outFile.write("%s = %sWrapper\n"%(name, name))
|
||||
|
||||
class ShimOutputGenerator(OutputGenerator):
|
||||
def __init__(self,
|
||||
errFile = sys.stderr,
|
||||
warnFile = sys.stderr,
|
||||
diagFile = sys.stdout):
|
||||
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
|
||||
def beginFile(self, genOpts):
|
||||
self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename)
|
||||
def endFile(self):
|
||||
pass
|
||||
def beginFeature(self, interface, emit):
|
||||
OutputGenerator.beginFeature(self, interface, emit)
|
||||
self.OldVersion = (self.featureName in ['GL_VERSION_1_0', 'GL_VERSION_1_1', 'GL_VERSION_1_2', 'GL_ARB_imaging', 'GL_ARB_multitexture', 'GL_ARB_texture_compression'])
|
||||
def endFeature(self):
|
||||
OutputGenerator.endFeature(self)
|
||||
def genType(self, typeinfo, name):
|
||||
OutputGenerator.genType(self, typeinfo, name)
|
||||
def genEnum(self, enuminfo, name):
|
||||
OutputGenerator.genEnum(self, enuminfo, name)
|
||||
def genCmd(self, cmd, name):
|
||||
OutputGenerator.genCmd(self, cmd, name)
|
||||
|
||||
if not self.OldVersion:
|
||||
return
|
||||
|
||||
# for GL functions which are in the ABI, generate a shim which calls the function via GetProcAddress
|
||||
rettype=ParseCmdRettype(cmd)
|
||||
self.outFile.write("%s %s("%(rettype, name))
|
||||
plist=ParseCmdParams(cmd)
|
||||
|
||||
Comma=""
|
||||
if len(plist):
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, ptype))
|
||||
Comma=", "
|
||||
else:
|
||||
self.outFile.write("void")
|
||||
|
||||
self.outFile.write(")\n{\n")
|
||||
|
||||
self.outFile.write(' typedef %s (* PFN%sPROC)(' % (rettype, name.upper()))
|
||||
|
||||
if len(plist):
|
||||
Comma=""
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s %s"%(Comma, ptype))
|
||||
Comma=", "
|
||||
else:
|
||||
self.outFile.write("void")
|
||||
|
||||
self.outFile.write(');\n')
|
||||
|
||||
if rettype.lower()=="void":
|
||||
self.outFile.write(' RESOLVE(PFN%sPROC, "%s");\n'%(name.upper(), name))
|
||||
self.outFile.write(' RESOLVED_PROC(')
|
||||
else:
|
||||
self.outFile.write(' RESOLVE_RET(PFN%sPROC, "%s", 0);\n'%(name.upper(), name))
|
||||
self.outFile.write(' return RESOLVED_PROC(')
|
||||
|
||||
Comma=""
|
||||
for ptype, pname in plist:
|
||||
self.outFile.write("%s%s"%(Comma, pname))
|
||||
Comma=", "
|
||||
|
||||
self.outFile.write(" );\n}\n\n")
|
||||
|
||||
def genHeaders():
|
||||
outFile = open(outFilename,"w")
|
||||
|
||||
if preresolve:
|
||||
gen = PreResolveOutputGenerator(errFile=errWarn,
|
||||
warnFile=errWarn,
|
||||
diagFile=diag)
|
||||
gen.outFile=outFile
|
||||
reg.setGenerator(gen)
|
||||
reg.apiGen(genOpts)
|
||||
|
||||
if wrapper:
|
||||
gen = WrapperOutputGenerator(errFile=errWarn,
|
||||
warnFile=errWarn,
|
||||
diagFile=diag)
|
||||
gen.outFile=outFile
|
||||
reg.setGenerator(gen)
|
||||
reg.apiGen(genOpts)
|
||||
|
||||
if shim:
|
||||
gen = ShimOutputGenerator(errFile=errWarn,
|
||||
warnFile=errWarn,
|
||||
diagFile=diag)
|
||||
gen.outFile=outFile
|
||||
reg.setGenerator(gen)
|
||||
reg.apiGen(genOpts)
|
||||
|
||||
if thunk:
|
||||
gen = ThunkOutputGenerator(errFile=errWarn,
|
||||
warnFile=errWarn,
|
||||
diagFile=diag)
|
||||
gen.outFile=outFile
|
||||
reg.setGenerator(gen)
|
||||
reg.apiGen(genOpts)
|
||||
|
||||
|
||||
if thunkdefs:
|
||||
gen = ThunkDefsOutputGenerator(errFile=errWarn,
|
||||
warnFile=errWarn,
|
||||
diagFile=diag)
|
||||
gen.outFile=outFile
|
||||
reg.setGenerator(gen)
|
||||
reg.apiGen(genOpts)
|
||||
|
||||
outFile.close()
|
||||
|
||||
genHeaders()
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* File: glshim.c
|
||||
* Purpose: GL shim which redirects to a specified DLL
|
||||
*
|
||||
* Copyright (c) Jon TURNEY 2013
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
A GL shim which redirects to a specified DLL
|
||||
|
||||
XWin is statically linked with this, rather than the system libGL, so that
|
||||
GL calls can be directed to mesa cygGL-1.dll, or cygnativeGLthunk.dll
|
||||
(which contains cdecl-to-stdcall thunks to the native openGL32.dll)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#define GL_GLEXT_LEGACY
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#undef GL_ARB_imaging
|
||||
#undef GL_VERSION_1_3
|
||||
#include <GL/glext.h>
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <os.h>
|
||||
#include "glwindows.h"
|
||||
#include <glx/glxserver.h>
|
||||
|
||||
extern void *glXGetProcAddressARB(const char *);
|
||||
|
||||
static HMODULE hMod = NULL;
|
||||
|
||||
/*
|
||||
Implement the __glGetProcAddress function by just using GetProcAddress() on the selected DLL
|
||||
*/
|
||||
void *glXGetProcAddressARB(const char *symbol)
|
||||
{
|
||||
void *proc;
|
||||
|
||||
/* Default to the mesa GL implementation if one hasn't been selected yet */
|
||||
if (!hMod)
|
||||
glWinSelectImplementation(0);
|
||||
|
||||
proc = GetProcAddress(hMod, symbol);
|
||||
|
||||
if (glxWinDebugSettings.enableGLcallTrace)
|
||||
ErrorF("glXGetProcAddressARB: Resolved '%s' in %p to %p\n", symbol, hMod, proc);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
/*
|
||||
Select a GL implementation DLL
|
||||
*/
|
||||
int glWinSelectImplementation(int native)
|
||||
{
|
||||
const char *dllname;
|
||||
|
||||
if (native) {
|
||||
dllname = "cygnativeGLthunk.dll";
|
||||
}
|
||||
else {
|
||||
dllname = "cygGL-1.dll";
|
||||
}
|
||||
|
||||
hMod = LoadLibraryEx(dllname, NULL, 0);
|
||||
if (hMod == NULL) {
|
||||
ErrorF("glWinSelectGLimplementation: Could not load '%s'\n", dllname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ErrorF("glWinSelectGLimplementation: Loaded '%s'\n", dllname);
|
||||
|
||||
/* Connect __glGetProcAddress() to our implementation of glXGetProcAddressARB() above */
|
||||
__glXsetGetProcAddress((glx_gpa_proc)glXGetProcAddressARB);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RESOLVE_RET(proctype, symbol, retval) \
|
||||
proctype proc = (proctype)glXGetProcAddressARB(symbol); \
|
||||
if (proc == NULL) return retval;
|
||||
|
||||
#define RESOLVE(proctype, symbol) RESOLVE_RET(proctype, symbol,)
|
||||
#define RESOLVED_PROC proc
|
||||
|
||||
/* Include generated shims for direct linkage to GL functions which are in the ABI */
|
||||
#include "generated_gl_shim.ic"
|
||||
|
||||
/*
|
||||
Special wrapper for glAddSwapHintRectWIN for copySubBuffers
|
||||
|
||||
Only used with native GL if the GL_WIN_swap_hint extension is present, so we enable
|
||||
GLX_MESA_copy_sub_buffer
|
||||
*/
|
||||
typedef void (__stdcall * PFNGLADDSWAPHINTRECTWIN) (GLint x, GLint y,
|
||||
GLsizei width,
|
||||
GLsizei height);
|
||||
|
||||
void
|
||||
glAddSwapHintRectWINWrapper(GLint x, GLint y, GLsizei width,
|
||||
GLsizei height)
|
||||
{
|
||||
RESOLVE(PFNGLADDSWAPHINTRECTWIN, "glAddSwapHintRectWIN");
|
||||
RESOLVED_PROC(x, y, width, height);
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* File: glthunk.c
|
||||
* Purpose: cdecl thunk wrapper library for Win32 stdcall OpenGL library
|
||||
*
|
||||
* Copyright (c) Jon TURNEY 2009,2013
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
*/
|
||||
|
||||
// define USE_OPENGL32 makes gl.h declare gl*() function prototypes with stdcall linkage,
|
||||
// so our generated wrappers will correctly link with the functions in opengl32.dll
|
||||
#define USE_OPENGL32
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
|
||||
#define GL_GLEXT_LEGACY
|
||||
#include <GL/gl.h>
|
||||
#undef GL_ARB_imaging
|
||||
#undef GL_VERSION_1_3
|
||||
#include <GL/glext.h>
|
||||
|
||||
static PROC
|
||||
glWinResolveHelper(PROC * cache, const char *symbol)
|
||||
{
|
||||
PROC proc = NULL;
|
||||
|
||||
/* If not yet cached, call wglGetProcAddress */
|
||||
if ((*cache) == NULL) {
|
||||
proc = wglGetProcAddress(symbol);
|
||||
if (proc == NULL) {
|
||||
(*cache) = (PROC) - 1;
|
||||
}
|
||||
else {
|
||||
(*cache) = proc;
|
||||
}
|
||||
}
|
||||
/* Cached wglGetProcAddress failure */
|
||||
else if ((*cache) == (PROC) - 1) {
|
||||
proc = 0;
|
||||
}
|
||||
/* Cached wglGetProcAddress result */
|
||||
else {
|
||||
proc = (*cache);
|
||||
}
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
#define RESOLVE_RET(proctype, symbol, retval) \
|
||||
static PROC cache = NULL; \
|
||||
__stdcall proctype proc = (proctype)glWinResolveHelper(&cache, symbol); \
|
||||
if (proc == NULL) { \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
#define RESOLVE(proctype, symbol) RESOLVE_RET(proctype, symbol,)
|
||||
|
||||
#define RESOLVED_PROC(proctype) proc
|
||||
|
||||
/*
|
||||
Include generated cdecl wrappers for stdcall gl*() functions in opengl32.dll
|
||||
|
||||
OpenGL 1.2 and upward is treated as extensions, function address must
|
||||
found using wglGetProcAddress(), but also stdcall so still need wrappers...
|
||||
*/
|
||||
|
||||
#include "generated_gl_thunks.ic"
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* File: glwindows.h
|
||||
* Purpose: Header for GLX implementation using native Windows OpenGL library
|
||||
*
|
||||
* Authors: Alexander Gottwald
|
||||
* Jon TURNEY
|
||||
*
|
||||
* Copyright (c) Jon TURNEY 2009
|
||||
* Copyright (c) Alexander Gottwald 2004
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
*/
|
||||
|
||||
#ifndef GLWINDOWS_H
|
||||
#define GLWINDOWS_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned int enableDebug:1;
|
||||
unsigned int enableTrace:1;
|
||||
unsigned int dumpPFD:1;
|
||||
unsigned int dumpHWND:1;
|
||||
unsigned int dumpDC:1;
|
||||
unsigned int enableGLcallTrace:1;
|
||||
unsigned int enableWGLcallTrace:1;
|
||||
} glxWinDebugSettingsRec;
|
||||
|
||||
extern glxWinDebugSettingsRec glxWinDebugSettings;
|
||||
|
||||
void glxWinPushNativeProvider(void);
|
||||
void glAddSwapHintRectWINWrapper(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
int glWinSelectImplementation(int native);
|
||||
|
||||
#if 1
|
||||
#define GLWIN_TRACE_MSG(msg, args...) if (glxWinDebugSettings.enableTrace) ErrorF(msg " [%s:%d]\n" , ##args , __FUNCTION__, __LINE__ )
|
||||
#define GLWIN_DEBUG_MSG(msg, args...) if (glxWinDebugSettings.enableDebug) ErrorF(msg " [%s:%d]\n" , ##args , __FUNCTION__, __LINE__ )
|
||||
#else
|
||||
#define GLWIN_TRACE_MSG(a, ...)
|
||||
#define GLWIN_DEBUG_MSG(a, ...)
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Jon TURNEY
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifndef indirect_h
|
||||
#define indirect_h
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <GL/wglext.h>
|
||||
#include <glx/extension_string.h>
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/*
|
||||
* structure definitions
|
||||
*/
|
||||
|
||||
typedef struct __GLXWinContext __GLXWinContext;
|
||||
typedef struct __GLXWinDrawable __GLXWinDrawable;
|
||||
typedef struct __GLXWinScreen glxWinScreen;
|
||||
typedef struct __GLXWinConfig GLXWinConfig;
|
||||
|
||||
struct __GLXWinContext {
|
||||
__GLXcontext base;
|
||||
HGLRC ctx; /* Windows GL Context */
|
||||
__GLXWinContext *shareContext; /* Context with which we will share display lists and textures */
|
||||
HWND hwnd; /* For detecting when HWND has changed */
|
||||
};
|
||||
|
||||
struct __GLXWinDrawable {
|
||||
__GLXdrawable base;
|
||||
__GLXWinContext *drawContext;
|
||||
__GLXWinContext *readContext;
|
||||
|
||||
/* If this drawable is GLX_DRAWABLE_PBUFFER */
|
||||
HPBUFFERARB hPbuffer;
|
||||
|
||||
/* If this drawable is GLX_DRAWABLE_PIXMAP */
|
||||
HDC dibDC;
|
||||
HANDLE hSection; /* file mapping handle */
|
||||
HBITMAP hDIB;
|
||||
HBITMAP hOldDIB; /* original DIB for DC */
|
||||
void *pOldBits; /* original pBits for this drawable's pixmap */
|
||||
};
|
||||
|
||||
struct __GLXWinScreen {
|
||||
__GLXscreen base;
|
||||
|
||||
Bool has_WGL_ARB_multisample;
|
||||
Bool has_WGL_ARB_pixel_format;
|
||||
Bool has_WGL_ARB_pbuffer;
|
||||
Bool has_WGL_ARB_render_texture;
|
||||
Bool has_WGL_ARB_make_current_read;
|
||||
Bool has_WGL_ARB_framebuffer_sRGB;
|
||||
|
||||
/* wrapped screen functions */
|
||||
RealizeWindowProcPtr RealizeWindow;
|
||||
UnrealizeWindowProcPtr UnrealizeWindow;
|
||||
CopyWindowProcPtr CopyWindow;
|
||||
};
|
||||
|
||||
struct __GLXWinConfig {
|
||||
__GLXconfig base;
|
||||
int pixelFormatIndex;
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
|
||||
void
|
||||
glxWinDeferredCreateDrawable(__GLXWinDrawable *draw, __GLXconfig *config);
|
||||
|
||||
#endif /* indirect_h */
|
|
@ -1,102 +0,0 @@
|
|||
python3 = import('python3')
|
||||
|
||||
# XWin requires OpenGL spec files in order to generate wrapper code for native GL functions
|
||||
py3 = python3.find_python()
|
||||
if run_command(py3, '-c', 'import lxml;').returncode() != 0
|
||||
error('python3 lxml module not found')
|
||||
endif
|
||||
|
||||
khronos_spec_dir = dependency('khronos-opengl-registry').get_pkgconfig_variable('specdir')
|
||||
|
||||
gen_gl_wrappers_opts= ['-nodebug']
|
||||
gen_gl_wrappers_cmd = ['env', 'PYTHONPATH=' + khronos_spec_dir, py3, files('./gen_gl_wrappers.py'), gen_gl_wrappers_opts]
|
||||
|
||||
wgl_wrappers = custom_target(
|
||||
'gen_wgl_wrappers',
|
||||
command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-prefix', 'wgl', '-wrapper', '-preresolve', '-outfile', '@OUTPUT@'],
|
||||
input: join_paths(khronos_spec_dir, 'wgl.xml'),
|
||||
output: 'generated_wgl_wrappers.ic',
|
||||
depend_files: join_paths(khronos_spec_dir, 'reg.py'),
|
||||
)
|
||||
|
||||
gl_shim = custom_target(
|
||||
'gen_gl_shim',
|
||||
command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-shim', '-outfile', '@OUTPUT@'],
|
||||
input: join_paths(khronos_spec_dir, 'gl.xml'),
|
||||
output: 'generated_gl_shim.ic',
|
||||
depend_files: join_paths(khronos_spec_dir, 'reg.py'),
|
||||
)
|
||||
|
||||
gl_thunks = custom_target(
|
||||
'gen_gl_thunks',
|
||||
command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-thunk', '-outfile', '@OUTPUT@'],
|
||||
input: join_paths(khronos_spec_dir, 'gl.xml'),
|
||||
output: 'generated_gl_thunks.ic',
|
||||
depend_files: join_paths(khronos_spec_dir, 'reg.py'),
|
||||
)
|
||||
|
||||
gl_thunks_def = custom_target(
|
||||
'gen_gl_thunks_def',
|
||||
command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-thunkdefs', '-outfile', '@OUTPUT@'],
|
||||
input: join_paths(khronos_spec_dir, 'gl.xml'),
|
||||
output: 'generated_gl_thunks.def',
|
||||
depend_files: join_paths(khronos_spec_dir, 'reg.py'),
|
||||
)
|
||||
|
||||
srcs_windows_glx = [
|
||||
'winpriv.c',
|
||||
'winpriv.h',
|
||||
'glwindows.h',
|
||||
'glshim.c',
|
||||
gl_shim,
|
||||
'indirect.c',
|
||||
'indirect.h',
|
||||
'wgl_ext_api.c',
|
||||
wgl_wrappers,
|
||||
'wgl_ext_api.h',
|
||||
]
|
||||
|
||||
if build_windowsdri
|
||||
srcs_windows_glx += [
|
||||
'dri_helpers.c',
|
||||
'dri_helpers.h',
|
||||
]
|
||||
endif
|
||||
|
||||
xwin_glx_c_args = []
|
||||
xwin_glx_c_args += '-DHAVE_XWIN_CONFIG_H'
|
||||
xwin_glx_c_args += '-DXWIN_GLX_WINDOWS'
|
||||
|
||||
xwin_glx = static_library(
|
||||
'XwinGLX',
|
||||
srcs_windows_glx,
|
||||
include_directories: [
|
||||
inc,
|
||||
top_dir_inc,
|
||||
include_directories('../'),
|
||||
],
|
||||
dependencies: common_dep,
|
||||
c_args: xwin_glx_c_args,
|
||||
)
|
||||
|
||||
srcs_wgl_thunk = [
|
||||
'glthunk.c',
|
||||
gl_thunks,
|
||||
]
|
||||
|
||||
WGLthunk = shared_library(
|
||||
'nativeGLthunk',
|
||||
srcs_wgl_thunk,
|
||||
include_directories: [
|
||||
inc,
|
||||
top_dir_inc,
|
||||
],
|
||||
c_args: xwin_glx_c_args + [
|
||||
'-Wno-unused-function',
|
||||
'-Wno-missing-prototypes',
|
||||
'-Wno-missing-declarations',
|
||||
],
|
||||
link_args: ['-lopengl32'],
|
||||
vs_module_defs: gl_thunks_def,
|
||||
install: true,
|
||||
)
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* File: wgl_ext_api.c
|
||||
* Purpose: Wrapper functions for Win32 OpenGL wgl extension functions
|
||||
*
|
||||
* Authors: Jon TURNEY
|
||||
*
|
||||
* Copyright (c) Jon TURNEY 2009
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#include <glx/glxserver.h>
|
||||
#include <glx/glxext.h>
|
||||
#include <GL/wglext.h>
|
||||
#include <wgl_ext_api.h>
|
||||
#include "glwindows.h"
|
||||
|
||||
#define RESOLVE_DECL(type) \
|
||||
static type type##proc = NULL;
|
||||
|
||||
#define PRERESOLVE(type, symbol) \
|
||||
type##proc = (type)wglGetProcAddress(symbol);
|
||||
|
||||
#define RESOLVE_RET(type, symbol, retval) \
|
||||
if (type##proc == NULL) { \
|
||||
ErrorF("wglwrap: Can't resolve \"%s\"\n", symbol); \
|
||||
__glXErrorCallBack(0); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,)
|
||||
|
||||
#define RESOLVED_PROC(type) type##proc
|
||||
|
||||
/*
|
||||
* Include generated cdecl wrappers for stdcall WGL functions
|
||||
*
|
||||
* There are extensions to the wgl*() API as well; again we call
|
||||
* these functions by using wglGetProcAddress() to get a pointer
|
||||
* to the function, and wrapping it for cdecl/stdcall conversion
|
||||
*
|
||||
* We arrange to resolve the functions up front, as they need a
|
||||
* context to work, as we like to use them to be able to select
|
||||
* a context. Again, this assumption fails badly on multimontor
|
||||
* systems...
|
||||
*/
|
||||
|
||||
#include "generated_wgl_wrappers.ic"
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* File: wgl_ext_api.h
|
||||
* Purpose: Wrapper functions for Win32 OpenGL wgl extension functions
|
||||
*
|
||||
* Authors: Jon TURNEY
|
||||
*
|
||||
* Copyright (c) Jon TURNEY 2009
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
*/
|
||||
|
||||
#ifndef wgl_ext_api_h
|
||||
#define wgl_ext_api_h
|
||||
|
||||
#include <GL/wglext.h>
|
||||
|
||||
void wglResolveExtensionProcs(void);
|
||||
|
||||
/*
|
||||
Prototypes for wrapper functions we actually use
|
||||
XXX: should be automatically generated as well
|
||||
*/
|
||||
|
||||
const char *wglGetExtensionsStringARBWrapper(HDC hdc);
|
||||
BOOL wglMakeContextCurrentARBWrapper(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
HDC wglGetCurrentReadDCARBWrapper(VOID);
|
||||
|
||||
BOOL wglGetPixelFormatAttribivARBWrapper(HDC hdc,
|
||||
int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
UINT nAttributes,
|
||||
const int *piAttributes,
|
||||
int *piValues);
|
||||
|
||||
BOOL wglGetPixelFormatAttribfvARBWrapper(HDC hdc,
|
||||
int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
UINT nAttributes,
|
||||
const int *piAttributes,
|
||||
FLOAT * pfValues);
|
||||
|
||||
BOOL wglChoosePixelFormatARBWrapper(HDC hdc,
|
||||
const int *piAttribIList,
|
||||
const FLOAT * pfAttribFList,
|
||||
UINT nMaxFormats,
|
||||
int *piFormats, UINT * nNumFormats);
|
||||
|
||||
HPBUFFERARB wglCreatePbufferARBWrapper(HDC hDC,
|
||||
int iPixelFormat,
|
||||
int iWidth,
|
||||
int iHeight, const int *piAttribList);
|
||||
|
||||
HDC wglGetPbufferDCARBWrapper(HPBUFFERARB hPbuffer);
|
||||
|
||||
int wglReleasePbufferDCARBWrapper(HPBUFFERARB hPbuffer, HDC hDC);
|
||||
|
||||
BOOL wglDestroyPbufferARBWrapper(HPBUFFERARB hPbuffer);
|
||||
|
||||
BOOL wglQueryPbufferARBWrapper(HPBUFFERARB hPbuffer,
|
||||
int iAttribute, int *piValue);
|
||||
|
||||
BOOL wglSwapIntervalEXTWrapper(int interval);
|
||||
|
||||
int wglGetSwapIntervalEXTWrapper(void);
|
||||
|
||||
#endif /* wgl_ext_api_h */
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* Export window information for the Windows-OpenGL GLX implementation.
|
||||
*
|
||||
* Authors: Alexander Gottwald
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winpriv.h"
|
||||
#include "winwindow.h"
|
||||
|
||||
void
|
||||
winCreateWindowsWindow(WindowPtr pWin);
|
||||
|
||||
/**
|
||||
* Return size and handles of a window.
|
||||
* If pWin is NULL, then the information for the root window is requested.
|
||||
*/
|
||||
HWND
|
||||
winGetWindowInfo(WindowPtr pWin)
|
||||
{
|
||||
winTrace("%s: pWin %p XID 0x%x\n", __FUNCTION__, pWin, (unsigned int)pWin->drawable.id);
|
||||
|
||||
/* a real window was requested */
|
||||
if (pWin != NULL) {
|
||||
/* Get the window and screen privates */
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
|
||||
winScreenInfoPtr pScreenInfo = NULL;
|
||||
HWND hwnd = NULL;
|
||||
|
||||
if (pWinScreen == NULL) {
|
||||
ErrorF("winGetWindowInfo: screen has no privates\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hwnd = pWinScreen->hwndScreen;
|
||||
|
||||
pScreenInfo = pWinScreen->pScreenInfo;
|
||||
/* check for multiwindow mode */
|
||||
if (pScreenInfo->fMultiWindow) {
|
||||
winWindowPriv(pWin);
|
||||
|
||||
if (pWinPriv == NULL) {
|
||||
ErrorF("winGetWindowInfo: window has no privates\n");
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
if (pWinPriv->hWnd == NULL) {
|
||||
winCreateWindowsWindow(pWin);
|
||||
winDebug("winGetWindowInfo: forcing window to exist\n");
|
||||
}
|
||||
|
||||
if (pWinPriv->hWnd != NULL) {
|
||||
/* copy window handle */
|
||||
hwnd = pWinPriv->hWnd;
|
||||
|
||||
/* mark GLX active on that hwnd */
|
||||
pWinPriv->fWglUsed = TRUE;
|
||||
}
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ScreenPtr pScreen = g_ScreenInfo[0].pScreen;
|
||||
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
|
||||
|
||||
if (pWinScreen == NULL) {
|
||||
ErrorF("winGetWindowInfo: screen has no privates\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ErrorF("winGetWindowInfo: returning root window\n");
|
||||
|
||||
return pWinScreen->hwndScreen;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Bool
|
||||
winCheckScreenAiglxIsSupported(ScreenPtr pScreen)
|
||||
{
|
||||
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
|
||||
winScreenInfoPtr pScreenInfo = pWinScreen->pScreenInfo;
|
||||
|
||||
if (pScreenInfo->fMultiWindow)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
winSetScreenAiglxIsActive(ScreenPtr pScreen)
|
||||
{
|
||||
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
|
||||
pWinScreen->fNativeGlActive = TRUE;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* Export window information for the Windows-OpenGL GLX implementation.
|
||||
*
|
||||
* Authors: Alexander Gottwald
|
||||
*/
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <windowstr.h>
|
||||
|
||||
HWND winGetWindowInfo(WindowPtr pWin);
|
||||
Bool winCheckScreenAiglxIsSupported(ScreenPtr pScreen);
|
||||
void winSetScreenAiglxIsActive(ScreenPtr pScreen);
|
|
@ -1,421 +0,0 @@
|
|||
.TH XWIN 1 @vendorversion@
|
||||
.SH NAME
|
||||
XWin \- X Server for the Cygwin environment on Microsoft Windows
|
||||
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B XWin
|
||||
[ options ] ...
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIXWin\fP is an X Server for the X Window System on the Cygwin environment
|
||||
running on Microsoft Windows.
|
||||
|
||||
|
||||
.SH MODES
|
||||
\fIXWin\fP can operate in 3 different modes:
|
||||
.br
|
||||
* \fISingle Window\fP: This is the default mode. Each X screen
|
||||
appears as a single \fIWindows\fP window and all X windows are contained
|
||||
within this window.
|
||||
(In X terminology, the \fIWindows\fP window contains the root window for
|
||||
the screen)
|
||||
.br
|
||||
* \fIMulti-Window\fP: In this mode \fIXWin\fP uses its own integrated
|
||||
window manager in order to handle the top-level X windows, in such a
|
||||
way that they appear as normal \fIWindows\fP windows.
|
||||
.br
|
||||
* \fIRootless\fP: In this mode the X server works in a window
|
||||
containing the whole screen but this root window (traditionally covered with an X hatch
|
||||
pattern) is hidden from view, so only top-level X windows are seen.
|
||||
|
||||
.SH OPTIONS
|
||||
In addition to the normal server options described in the \fIXserver(1)\fP
|
||||
manual page, \fIXWin\fP accepts the following command line switches,
|
||||
\fIall\fP of which are optional:
|
||||
|
||||
.SH OPTIONS CONTROLLING WINDOWING MODE
|
||||
Only one of these options may be specified.
|
||||
.TP 8
|
||||
.B (default)
|
||||
Windowed or rooted mode.
|
||||
Each X screen appears as a single \fIWindows\fP window and all X windows are
|
||||
contained within those windows.
|
||||
.TP 8
|
||||
.B \-multiwindow
|
||||
Each top-level X window appears in its own \fIWindows\fP window.
|
||||
Also start the integrated \fIWindows\fP-based window manager.
|
||||
.TP 8
|
||||
.B \-rootless
|
||||
Run the server in rootless mode.
|
||||
The X server works on a window covering the whole screen but the root window
|
||||
is hidden from view.
|
||||
.PP
|
||||
\fBNOTE:\fP \fI-multiwindow\fP mode uses its own internal window manager.
|
||||
All other modes require an external window manager in order to move, resize, and perform other
|
||||
operations on the individual X windows.
|
||||
|
||||
.SH OPTIONS FOR SPECIFYING X SCREENS
|
||||
An X display may be composed of multiple screens.
|
||||
The default behaviour is to create a single screen 0 that is roughly the
|
||||
size of useful area of the primary monitor (allowing for any window
|
||||
decorations and the task-bar).
|
||||
|
||||
Screen specific parameters can be applied as a
|
||||
default to all screens by placing those screen specific parameters
|
||||
before any \fB\-screen\fP parameter. Screen specific parameters placed after
|
||||
the first \fB\-screen\fP parameter will apply only to the immediately
|
||||
preceding \fB\-screen\fP parameter.
|
||||
.TP 8
|
||||
.B \-[no]multimonitors or \-[no]multiplemonitors
|
||||
Create a screen 0 that covers all monitors [the primary monitor] on a system with
|
||||
multiple monitors.
|
||||
Fake XINERAMA data is created describing the individual monitors,
|
||||
(This is similar to the 'merged framebuffer' or 'pseudo-xinerama' mode provided by
|
||||
some drivers for the xorg X server).
|
||||
This option is currently enabled by default in \fB\-multiwindow\fP mode.
|
||||
.TP 8
|
||||
.B "\-screen \fIscreen_number\fP [\fIW\fP \fIH\fP [\fIX\fP \fIY\fP] | [[\fIW\fPx\fIH\fP[+\fIX\fP+\fIY\fP]][@\fIM\fP]] ] "
|
||||
Create screen number
|
||||
.I screen_number
|
||||
and optionally specify its
|
||||
.I height,
|
||||
.I width
|
||||
and
|
||||
.I initial position.
|
||||
Additionally a
|
||||
.I
|
||||
monitor number
|
||||
(which count from 1) can be specified to place the screen on,
|
||||
at which point, all coordinates become relative to that monitor.
|
||||
Screen numbers must be contiguous starting from zero and cannot be duplicated.
|
||||
|
||||
Examples:
|
||||
|
||||
.I " -screen 0 @1 ; on 1st monitor using its full resolution (the default)"
|
||||
|
||||
.I " -screen 0 800x600+100+100@2 ; on 2nd monitor offset 100,100 size 800x600"
|
||||
|
||||
.I " -screen 0 1024x768@3 ; on 3rd monitor size 1024x768"
|
||||
|
||||
.SH OPTIONS CONTROLLING THE APPEARANCE OF THE X SCREEN WINDOWS
|
||||
These parameters only apply to windowed mode screens i.e. not
|
||||
in \fB-multiwindow\fP or \fB-rootless\fP mode.
|
||||
.TP 8
|
||||
.B "\-fullscreen"
|
||||
The X server window takes the full screen, covering completely the
|
||||
\fIWindows\fP desktop.
|
||||
Currently \fB\-fullscreen\fP may only be applied to one X screen.
|
||||
.TP 8
|
||||
.B "\-icon" \fIicon-specifier\fP
|
||||
Override the window icon for the screen window from the default.
|
||||
The \fIicon-specifier\fP is as defined in \fIXWinrc(@filemansuffix@)\fP.
|
||||
.TP 8
|
||||
.B \-nodecoration
|
||||
Do not give the Cygwin/X window a \fIWindows\fP window border, title bar,
|
||||
etc.
|
||||
This parameter is ignored when the \fB\-fullscreen\fP parameter is specified.
|
||||
.TP 8
|
||||
.B \-scrollbars
|
||||
Alternative name for \fB\-resize=scrollbars\fP.
|
||||
|
||||
.SH OPTIONS CONTROLLING RESIZE BEHAVIOUR
|
||||
.TP 8
|
||||
.B \-resize[=none|scrollbars|randr]
|
||||
Select the resize mode of an X screen.
|
||||
The default is \fBnone\fP if \fB\-fullscreen\fP is used, \fBrandr\fP otherwise.
|
||||
|
||||
.RS
|
||||
.IP \fB\-resize=none\fP 8
|
||||
The screen is not resizable.
|
||||
|
||||
In windowed mode, if the window has decorations, a fixed frame is used.
|
||||
|
||||
Alternative name is \fB\-noresize\fP.
|
||||
|
||||
.IP \fB\-resize=scrollbars\fP 8
|
||||
The screen window is resizeable, but the screen is not resizable.
|
||||
|
||||
In windowed mode, if the window has decorations, a resizing frame is used.
|
||||
Scrollbars are drawn when needed to allow the entire X screen
|
||||
to viewed by adjusting them.
|
||||
|
||||
This also permits screens bigger than the \fIWindows\fP virtual desktop to be used.
|
||||
|
||||
This parameter is ignored in \fB-multiwindow\fP or \fB-rootless\fP mode.
|
||||
Alternative name is \fB\-scrollbars\fP.
|
||||
|
||||
.IP \fB\-resize=randr\fP 8
|
||||
The screen is resizable and the screen window is resizeable.
|
||||
|
||||
In windowed mode, if the window has decorations, a resizing frame is used.
|
||||
|
||||
Resizing the \fIWindows\fP window will use the RANDR extension to change
|
||||
the size of the X screen. Likewise, changing the size of
|
||||
the X screen using the RANDR extension will cause the size
|
||||
of the \fIWindows\fP window containing the X screen to be changed.
|
||||
|
||||
In \fB-multiwindow\fP or \fB-rootless\fP mode, if the X screen is
|
||||
of the same dimensions as a Windows monitor or the virtual desktop,
|
||||
the X server will respond to the WM_DISPLAYCHANGED sent when those
|
||||
dimensions change by resizing the X screen. Changing the size
|
||||
of the X screen using the RANDR extension is not permitted.
|
||||
|
||||
The maximum dimensions of the screen are the dimensions of the \fIWindows\fP virtual desktop.
|
||||
|
||||
.IP \fB\-resize\fP 8
|
||||
on its own is equivalent to \fB\-resize=randr\fP
|
||||
.RE
|
||||
|
||||
.SH OPTIONS FOR MULTIWINDOW MODE
|
||||
.TP 8
|
||||
.B \-[no]hostintitle
|
||||
Add the host name to the window title for X applications which are running
|
||||
on remote hosts, when that information is available and it's useful to do so.
|
||||
The default is enabled.
|
||||
.TP 8
|
||||
.B \-[no]compositewm
|
||||
Use Composite extension redirection to maintain a bitmap image of each top-level
|
||||
X window, so window contents which are occluded show correctly in task bar and
|
||||
task switcher previews.
|
||||
The default is enabled.
|
||||
.TP 8
|
||||
.B \-[no]compositealpha
|
||||
X windows with per-pixel alpha are composited into the \fIWindows\fP desktop
|
||||
(i.e. a \fIWindows\fP window can be seen through any transparency in an X window
|
||||
placed over it).
|
||||
|
||||
This option has no effect on Windows 8 and 8.1.
|
||||
This option has no effect if \fB-compositewm\fP is disabled.
|
||||
The default is disabled.
|
||||
|
||||
.SH OPTIONS CONTROLLING WINDOWS INTEGRATION
|
||||
.TP 8
|
||||
.B \-[no]clipboard
|
||||
Enables [disables] the integration between the X11 clipboard and
|
||||
\fIWindows\fP clipboard. The default is enabled.
|
||||
.TP 8
|
||||
.B "\-emulate3buttons [\fItimeout\fP]"
|
||||
Emulate a three button mouse; pressing both buttons within
|
||||
.I timeout
|
||||
milliseconds causes an emulated middle button press. The default
|
||||
.I timeout
|
||||
is 50 milliseconds. Note that most mice with scroll wheel have middle
|
||||
button functionality, usually you will need this option only if you have
|
||||
a two button mouse without scroll wheel. Default is to enable this
|
||||
option if \fIWindows\fP reports a two button mouse, disabled otherwise.
|
||||
.TP 8
|
||||
.B \-[no]keyhook
|
||||
Enable [disable] a low-level keyboard hook for catching
|
||||
special keypresses like Menu and Alt+Tab and passing them to the X
|
||||
Server instead of letting \fIWindows\fP handle them.
|
||||
.TP 8
|
||||
.B \-lesspointer
|
||||
Normally the \fIWindows\fP mouse cursor is hidden when the mouse is
|
||||
over an active Cygwin/X window. This option causes the mouse cursor
|
||||
also to be hidden when it is over an inactive Cygwin/X window. This
|
||||
prevents the \fIWindows\fP mouse cursor from being drawn on top of the X
|
||||
cursor.
|
||||
This parameter has no effect unless \fB-swcursor\fP is also specified.
|
||||
.TP 8
|
||||
.B \-[no]primary
|
||||
Clipboard integration may [will not] use the PRIMARY selection.
|
||||
The default is enabled.
|
||||
.TP 8
|
||||
.B \-swcursor
|
||||
Disable the usage of the \fIWindows\fP cursor and use the X11 software cursor instead.
|
||||
This option is ignored if \fB-compositewm\fP is also enabled.
|
||||
.TP 8
|
||||
.B \-[no]trayicon
|
||||
Do not create a tray icon. Default is to create one
|
||||
icon per screen. You can globally disable tray icons with
|
||||
\fB\-notrayicon\fP, then enable it for specific screens with
|
||||
\fB\-trayicon\fP for those screens.
|
||||
.TP 8
|
||||
.B \-[no]unixkill
|
||||
Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a
|
||||
signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination
|
||||
is disabled by default.
|
||||
.TP 8
|
||||
.B \-[no]wgl
|
||||
Enable [disable] the GLX extension to use the native Windows WGL interface
|
||||
for hardware accelerated OpenGL (AIGLX). The default is enabled.
|
||||
.TP 8
|
||||
.B \-[no]winkill
|
||||
Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the
|
||||
X Server.
|
||||
The \fIAlt-F4\fP key combination is enabled by default.
|
||||
|
||||
.SH DRAWING ENGINE OPTIONS
|
||||
.TP 8
|
||||
.B "\-clipupdates \fInum_boxes\fP"
|
||||
Specify an optional threshold, above which the regions in a shadow
|
||||
update operation will be collected into a GDI clipping region. The
|
||||
clipping region is then used to do a single bit block transfer that is
|
||||
constrained to the updated area by the clipping region. There is some
|
||||
overhead involved in creating, installing, destroying, and removing
|
||||
the clipping region, thus there may not be much benefit for a small
|
||||
number of boxes (less than 10). It is even possible that this
|
||||
functionality does not provide a benefit at any number of boxes; we
|
||||
can only determine the usefulness of this feature through testing.
|
||||
This option probably has limited effect on current \fIWindows\fP versions
|
||||
as they already perform GDI batching.
|
||||
.TP 8
|
||||
.B "\-engine \fIengine_type_id\fP"
|
||||
This option, which is intended for Cygwin/X developers,
|
||||
overrides the server's automatically selected drawing engine type. This
|
||||
parameter will be ignored if the specified drawing engine type is not
|
||||
supported on the current system.
|
||||
|
||||
Default behavior is to select the drawing engine with optimum performance that
|
||||
supports the specified depth and window configuration.
|
||||
|
||||
The engine type ids are:
|
||||
.RS
|
||||
.IP 1 4
|
||||
Shadow GDI
|
||||
.IP 4 4
|
||||
Shadow DirectDraw Non-Locking
|
||||
.RE
|
||||
|
||||
.SH FULLSCREEN OPTIONS
|
||||
.TP 8
|
||||
.B "\-depth \fIdepth\fP"
|
||||
Specify the color depth, in bits per pixel, to use when running in
|
||||
fullscreen with a DirectDraw engine. This parameter is ignored if
|
||||
\fB\-fullscreen\fP is not specified.
|
||||
.TP 8
|
||||
.B "\-refresh \fIrate_in_Hz\fP"
|
||||
Specify an optional refresh rate to use when running in
|
||||
fullscreen with a DirectDraw engine. This parameter is ignored if
|
||||
\fB\-fullscreen\fP is not specified.
|
||||
|
||||
.SH MISCELLANEOUS OPTIONS
|
||||
See also the normal server options described in the \fIXserver(1)\fP
|
||||
manual page
|
||||
|
||||
.TP 8
|
||||
.B \-help
|
||||
Write a help text listing supported command line options and their description to the console.
|
||||
.TP 8
|
||||
.B \-ignoreinput
|
||||
Ignore keyboard and mouse input. This is usually only used for testing
|
||||
and debugging purposes.
|
||||
.TP 8
|
||||
.B "\-logfile \fIfilename\fP"
|
||||
Change the server log file from the default of \fI
|
||||
@logdir@/XWin.n.log\fP,
|
||||
where \fIn\fP is the display number of the XWin server, to \fIfilename\fP.
|
||||
.TP 8
|
||||
.B "\-logverbose \fIlevel\fP"
|
||||
Control the degree of verbosity of the log messages with the integer
|
||||
parameter \fIlevel\fP. For \fIlevel\fP=0 only fatal errors are
|
||||
reported, for \fIlevel\fP=1 simple information about
|
||||
configuration is also given, for \fIlevel\fP=2 (default)
|
||||
additional runtime information is recorded
|
||||
and for \fIlevel\fP=3 detailed log
|
||||
information (including trace and debug output) is produced. Bigger
|
||||
values will yield a still more detailed debug output.
|
||||
.TP 8
|
||||
.B "\-xkblayout \fIlayout\fP"
|
||||
.TP 8
|
||||
.B "\-xkbmodel \fImodel\fP"
|
||||
.TP 8
|
||||
.B "\-xkboptions \fIoption\fP"
|
||||
.TP 8
|
||||
.B "\-xkbrules \fIrule\fP"
|
||||
.TP 8
|
||||
.B "\-xkbvariant \fIvariant\fp"
|
||||
These options configure the xkeyboard extension to load
|
||||
a particular keyboard map as the X server starts. The behavior is similar
|
||||
to the \fIsetxkbmap\fP(1) program.
|
||||
|
||||
See the \fIxkeyboard-config\fP(@miscmansuffix@) manual page for a list of
|
||||
keyboard configurations.
|
||||
|
||||
The keyboard layout data is located at \fI@datadir@/X11/xkb/\fP. Additional information
|
||||
can be found in the README files there and in the \fIsetxkbmap\fP(1) manual page.
|
||||
|
||||
For example, in order to load a German layout for a pc105 keyboard, use the options:
|
||||
.br
|
||||
.I " \-xkblayout de \-xkbmodel pc105"
|
||||
|
||||
Alternatively, you can use the \fIsetxkbmap\fP(1) program after \fIXWin\fP is
|
||||
running.
|
||||
|
||||
The default is to select a keyboard configuration matching your current layout as
|
||||
reported by \fIWindows\fP, if known, or the default X server configuration
|
||||
if no matching keyboard configuration was found.
|
||||
|
||||
.SH UNDOCUMENTED OPTIONS
|
||||
These options are undocumented. Do not use them.
|
||||
|
||||
.TP 8
|
||||
.B \-emulatepseudo
|
||||
Create a depth 8 PseudoColor visual when running in depths 15, 16, 24,
|
||||
or 32, collectively known as TrueColor depths.
|
||||
Color map manipulation is not supported, so the PseudoColor visual will
|
||||
not have the correct colors.
|
||||
This option is intended to allow applications which only work with a depth 8
|
||||
visual to operate in TrueColor modes.
|
||||
|
||||
.SH LOG FILE
|
||||
As it runs \fIXWin\fP writes messages indicating the most relevant events
|
||||
to the console
|
||||
from which it was called and to a log file that by default is located at \fI
|
||||
@logdir@/XWin.0.log\fP. This file is mainly for debugging purposes.
|
||||
|
||||
|
||||
.SH PREFERENCES FILE
|
||||
On startup \fIXWin\fP looks for the file \fI$HOME/.XWinrc\fP or, if
|
||||
the previous file does not exist, \fI
|
||||
@sysconfdir@/X11/system.XWinrc\fP. \fI.XWinrc\fP allows setting
|
||||
preferences for the following:
|
||||
.br
|
||||
* To include items into the menu associated with the \fIXWin\fP icon
|
||||
which is in the \fIWindows\fP system tray. This functions in all
|
||||
modes that have a tray icon.
|
||||
.br
|
||||
* To include items in the system menu which is associated with the \fIWindows\fP
|
||||
window that \fIXWin -multiwindow\fP produces for each top-level X
|
||||
window, in both the generic case and for particular programs.
|
||||
.br
|
||||
* To change the icon that is associated to the \fIWindows\fP window that
|
||||
\fIXWin -multiwindow\fP produces for each top-level X-window.
|
||||
.br
|
||||
* To change the style that is associated to the \fIWindows\fP window that
|
||||
\fXWin I-multiwindow\fP produces for each top-level X window.
|
||||
.PP
|
||||
The format of the \fI.XWinrc\fP file is given in the XWinrc(5) manual page.
|
||||
|
||||
.SH EXAMPLES
|
||||
Need some examples
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
X(@miscmansuffix@), Xserver(1), xdm(1), xinit(1), XWinrc(@filemansuffix@),
|
||||
setxkbmap(1), xkeyboard-config(@miscmansuffix@).
|
||||
|
||||
|
||||
.SH BUGS
|
||||
.I XWin
|
||||
and this manual page still have many limitations.
|
||||
|
||||
The \fIXWin\fP software is continuously developing; it is therefore possible that
|
||||
this manual page is not up to date. It is always prudent to
|
||||
look also at the output of \fIXWin -help\fP in order to
|
||||
check the options that are operative.
|
||||
|
||||
|
||||
.SH AUTHORS
|
||||
This list is by no means complete, but direct contributors to the
|
||||
Cygwin/X project include (in alphabetical order by last name): Stuart
|
||||
Adamson, Michael Bax, Jehan Bing, Lev Bishop, Dr. Peter Busch, Biju G
|
||||
C, Robert Collins, Nick Crabtree, Early Ehlinger, Christopher Faylor,
|
||||
John Fortin, Brian Genisio, Fabrizio Gennari, Alexander Gottwald, Ralf
|
||||
Habacker, Colin Harrison, Matthieu Herrb, Alan Hourihane, Pierre A
|
||||
Humblet, Harold L Hunt II, Dakshinamurthy Karra, Joe Krahn,
|
||||
Paul Loewenstein, Kensuke Matsuzaki,
|
||||
Takuma Murakami, Earle F. Philhower III, Benjamin Riefenstahl, Yaakov Selkowitz,
|
||||
Suhaib Siddiqi, Jack Tanner, Jon Turney and Nicholas Wourms.
|
|
@ -1,256 +0,0 @@
|
|||
.TH XWIN @filemansuffix@ @vendorversion@
|
||||
|
||||
|
||||
.SH NAME
|
||||
XWinrc\- XWin Server Resource Configuration File.
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
The X Server for the X Window System on the Cygwin/X environment
|
||||
running on Microsoft Windows, \fIXWin\fP can be optionally configured
|
||||
with the \fIXWinrc\fP file. A system-wide configuration file should
|
||||
be placed in \fI
|
||||
@sysconfdir@/X11/system.XWinrc\fP, a per-user file
|
||||
should be put at \fI$HOME/.XWinrc\fP. The \fIsystem.XWinrc\fP file is
|
||||
read only if no \fI$HOME/.XWinrc\fP exist.
|
||||
.PP
|
||||
With the \fI.XWinrc\fP configuration file it is possible to do the
|
||||
following:
|
||||
.PP
|
||||
1- To include items into the menu associated with the \fIXWin\fP icon
|
||||
which is in the \fIWindows\fP system tray. This feature functions in
|
||||
all XWin modes that have such tray icon.
|
||||
.PP
|
||||
2- To include items into the menu which is associated with the
|
||||
\fIWindows\fP window that \fIXWin -multiwindow\fP produces for each
|
||||
top-level X-window. That can be done both for the generic case and
|
||||
for particular programs.
|
||||
.PP
|
||||
3- To change the icon that is associated to the \fIWindows\fP window
|
||||
that \fIXWin -multiwindow\fP produces for each top-level X-window.
|
||||
Again, that can be done both for the generic case and for particular
|
||||
programs. The new icons associated should be \fIWindows\fP format
|
||||
icons \fI.ico\fP.
|
||||
.PP
|
||||
4- To change the style that is associated to the \fIWindows\fP window
|
||||
that \fI-multiwindow\fP produces for each top-level X window. Again,
|
||||
that can be done both for the generic case and for particular programs.
|
||||
|
||||
|
||||
.SH FILE FORMAT
|
||||
.B Keywords
|
||||
are case insensitive, but in this document they will be written
|
||||
completely capitalized.
|
||||
.PP
|
||||
.B Comments
|
||||
are legal pretty much anywhere you can have an end-of-line; they
|
||||
begin with "#" or "//" and go to the end-of-line.
|
||||
.PP
|
||||
Quote marks in strings are optional unless the string has included spaces,
|
||||
or could be parsed, ambiguously, as a misplaced keyword.
|
||||
.PP
|
||||
There are four kinds of instructions: miscellaneous, menu, icon and style.
|
||||
|
||||
|
||||
.SH Miscellaneous instruction
|
||||
.TP 8
|
||||
.B DEBUG \fIString\fP
|
||||
The \fIString\fP is printed to the XWin log file.
|
||||
|
||||
.TP 8
|
||||
.B TRAYICON \fIicon-specifier\fB
|
||||
The \fBTRAYICON\fP keyword changes the icon \fIXWin\fP displays in the
|
||||
system tray area.
|
||||
|
||||
.TP 8
|
||||
.B SILENTEXIT
|
||||
The \fBSILENTEXIT\fP keyword, which takes no parameters, disables the
|
||||
exit confirmation dialog if no clients are connected.
|
||||
|
||||
.TP 8
|
||||
.B FORCEEXIT
|
||||
The \fBFORCEEXIT\fP keyword, which takes no parameters, disables the
|
||||
exit confirmation dialog always. Unsaved client work may be lost but
|
||||
this may be useful if you want no dialogs.
|
||||
|
||||
.SH Menu instructions
|
||||
.TP 8
|
||||
.B MENU \fIMenu_Name\fP {
|
||||
.br
|
||||
.B \fIMenu_Item_Line\fP
|
||||
.br
|
||||
.B \fIMenu_Item_Line\fP
|
||||
.br
|
||||
.B \fI...\fP
|
||||
.br
|
||||
.B }
|
||||
.br
|
||||
This instruction defines a menu and asigns a \fIMenu_Name\fP to it.
|
||||
\fIMenu_Item_Line\fP are lines of any of the following types:
|
||||
.TP 8
|
||||
.B SEPARATOR
|
||||
.TP 8
|
||||
.B \fIItem_Label\fP EXEC \fICommand\fP
|
||||
.TP 8
|
||||
.B \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP
|
||||
.TP 8
|
||||
.B \fIItem_Label\fP ALWAYSONTOP
|
||||
.TP 8
|
||||
.B \fIItem_Label\fP RELOAD
|
||||
.br
|
||||
The \fIItem_Label\fP is the string that is written in the menu item.
|
||||
.br
|
||||
\fICommand\fP is a string with the command that will be executed by /bin/sh.
|
||||
Here paths should be \fICYGWIN\fP style (e.g. /usr/local/bin/myprogram).
|
||||
A string "%display%" appearing in the \fICommand\fP will be replaced
|
||||
with the proper display variable (i.e. 127.0.0.1:<display>.0).
|
||||
.br
|
||||
\fBALWAYSONTOP\fP sets the window to which the menu is associated to
|
||||
display above all others.
|
||||
.br
|
||||
\fBRELOAD\fP causes the XWinrc file to be reloaded and icons and menus
|
||||
regenerated.
|
||||
.TP 8
|
||||
.B ROOTMENU \fIpreviously-defined-menu-name\fP
|
||||
Includes the items in the indicated menu into the menu associated with
|
||||
\fIXWin\fP that appears in the system tray.
|
||||
.TP 8
|
||||
.B DEFAULTSYSMENU \fIpreviously-defined-menu-name\fP ATSTART|ATEND
|
||||
Includes the items in the indicated menu into the menu associated with
|
||||
generic top-level X-Windows in the \fIXWin\fP \fImultiwindow\fP mode. The
|
||||
keywords \fBATSTART\fP and \fBATEND\fP indicate if such items should be
|
||||
included at the start or at the end of the menu.
|
||||
.TP 8
|
||||
.B SYSMENU {
|
||||
\fIclass-or-name-of-window\fP \fIdefined-menu-name\fP \fBATSTART|ATEND\fP
|
||||
.br
|
||||
\fI...\fP
|
||||
.br
|
||||
\fB}\fP
|
||||
.br
|
||||
Associates a specific menu to a specified window class or name
|
||||
in \fI-multiwindow\fP mode. The keywords ATSTART or ATEND indicate if
|
||||
such items should be included at the start or at the end of the menu.
|
||||
|
||||
|
||||
.SH Icon Instructions
|
||||
When specifying an \fIicon-specifier\fP in the following commands several different formats are allowed:
|
||||
.PP
|
||||
.IP \fI"NAME.ICO"\fP 16
|
||||
filename of an .ico format file
|
||||
.br
|
||||
(e.g. "cygwin.ico", "apple.ico", "C:\\icons\\cheese.ico", "/usr/share/icons/moon.ico")
|
||||
.IP \fI"NAME.DLL,nnn"\fP 16
|
||||
filename of a DLL with an index into its ICON resources
|
||||
.br
|
||||
(e.g. "c:\\windows\\system32\\shell32.dll,4", the default folder icon,
|
||||
"/usr/bin/cygicons-0.dll,10", the hippo icon)
|
||||
.IP \fI",nnn"\fP 16
|
||||
index into the XWin executable's internal ICON resources
|
||||
.br
|
||||
(e.g. ",101" is the 1st icon in \fIXWin\fP)
|
||||
.TP 8
|
||||
.B ICONDIRECTORY \fIWindows-path-to-icon-directory\fP
|
||||
Defines the default directory for the file when an \fIicon-specifier\fP doesn't
|
||||
contain an absolute path.
|
||||
It should be a \fIWindows\fP style path (e.g. C:\\cygwin\\usr\\local\\icons).
|
||||
.TP 8
|
||||
.B DEFAULTICON \fIicon-specifier\fP
|
||||
Defines a replacement for the standard X icon for applications without
|
||||
specified icons.
|
||||
.TP 8
|
||||
.B ICONS {
|
||||
.br
|
||||
\fIclass-or-name-of-window\fP \fIicon-specifier\fP
|
||||
.br
|
||||
\fI...\fP
|
||||
.br
|
||||
\fB}\fP
|
||||
.br
|
||||
Defines icon replacements windows matching the specified window class or names.
|
||||
If multiple name or class matches occur for a window, only the first one
|
||||
will be used.
|
||||
|
||||
.SH Style Instructions
|
||||
.TP 8
|
||||
.B STYLES {
|
||||
\fIclass-or-name-of-window\fP \fIstyle-keyword-1\fP \fIstyle-keyword-2\fP
|
||||
.br
|
||||
\fI...\fP
|
||||
.br
|
||||
\fB}\fP
|
||||
|
||||
Associates specific styles to a specified window class or name
|
||||
in \fI-multiwindow\fP mode. If multiple class or name matches occur,
|
||||
for a window, only the first one will be used.
|
||||
|
||||
The style keywords indicate the following:
|
||||
|
||||
\fIstyle-keyword-1\fP
|
||||
|
||||
\fBTOPMOST\fP
|
||||
.br
|
||||
Open the class or name above all NOTOPMOST Microsoft Windows
|
||||
.br
|
||||
\fBMAXIMIZE\fP
|
||||
.br
|
||||
Start the class or name fullscreen.
|
||||
.br
|
||||
\fBMINIMIZE\fP
|
||||
.br
|
||||
Start the class or name iconic.
|
||||
.br
|
||||
\fBBOTTOM\fP
|
||||
.br
|
||||
Open the class or name below all Windows windows.
|
||||
.br
|
||||
|
||||
\fIstyle-keyword-2\fP
|
||||
|
||||
\fBNOTITLE\fP
|
||||
.br
|
||||
No Windows title bar, for the class or name.
|
||||
.br
|
||||
\fBOUTLINE\fP
|
||||
.br
|
||||
No Windows title bar and just a thin-line border, for the class or name.
|
||||
.br
|
||||
\fBNOFRAME\fP
|
||||
.br
|
||||
No Windows title bar or border, for the class or name.
|
||||
|
||||
One keyword in \fIstyle-keyword-1\fP can be used with one keyword in \fIstyle-keyword-2\fP,
|
||||
or any keyword can be used singly.
|
||||
|
||||
|
||||
.SH EXAMPLE
|
||||
.TP 8
|
||||
This example adds an Xterm menu item to the system tray icon
|
||||
\fBMENU systray {
|
||||
.br
|
||||
\t xterm EXEC "xterm -display %display% -sb -sl 999"
|
||||
.br
|
||||
\t SEPARATOR
|
||||
.br
|
||||
}
|
||||
.br
|
||||
ROOTMENU systray
|
||||
\fP
|
||||
|
||||
.TP 8
|
||||
This example makes an oclock window frameless in \fI-multiwindow\fP mode
|
||||
\fBSTYLES {
|
||||
.br
|
||||
\t oclock NOFRAME
|
||||
.br
|
||||
}
|
||||
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
XWin(1)
|
||||
|
||||
|
||||
.SH AUTHOR
|
||||
The XWinrc feature of XWin was written primarily by Earle F. Philhower
|
||||
III. Extended for style configuration by Colin Harrison.
|
|
@ -1,184 +0,0 @@
|
|||
windows = import('windows')
|
||||
|
||||
windowsdri_dep = dependency('windowsdriproto', required: false)
|
||||
|
||||
build_windowsdri = windowsdri_dep.found()
|
||||
|
||||
xwin_sys_libs = []
|
||||
xwin_sys_libs += '-ldxguid'
|
||||
|
||||
if host_machine.system() == 'cygwin'
|
||||
server_name = 'XWin'
|
||||
else
|
||||
server_name = 'Xming'
|
||||
xwin_sys_libs += ['-lpthread', '-lws2_32']
|
||||
endif
|
||||
|
||||
xwin_c_args = []
|
||||
xwin_c_args += '-DHAVE_XWIN_CONFIG_H'
|
||||
xwin_c_args += '-Wno-bad-function-cast'
|
||||
|
||||
srcs_windows = [
|
||||
'winclipboardinit.c',
|
||||
'winclipboardwrappers.c',
|
||||
]
|
||||
subdir('winclipboard')
|
||||
|
||||
xwin_glx = []
|
||||
xwin_windowsdri = []
|
||||
if build_glx
|
||||
if build_windowsdri
|
||||
xwin_c_args += '-DXWIN_WINDOWS_DRI'
|
||||
subdir('dri')
|
||||
endif
|
||||
xwin_c_args += '-DXWIN_GLX_WINDOWS'
|
||||
xwin_sys_libs += '-lopengl32'
|
||||
subdir('glx')
|
||||
endif
|
||||
|
||||
srcs_windows += [
|
||||
'winmultiwindowshape.c',
|
||||
'winmultiwindowwindow.c',
|
||||
'winmultiwindowwm.c',
|
||||
'winmultiwindowwndproc.c',
|
||||
'propertystore.h',
|
||||
'winSetAppUserModelID.c',
|
||||
]
|
||||
xwin_sys_libs += ['-lshlwapi', '-lole32', '-ldwmapi']
|
||||
|
||||
srcs_windows += [
|
||||
'winrandr.c',
|
||||
]
|
||||
|
||||
srcs_windows += [
|
||||
'InitInput.c',
|
||||
'InitOutput.c',
|
||||
'winallpriv.c',
|
||||
'winauth.c',
|
||||
'winblock.c',
|
||||
'wincmap.c',
|
||||
'winconfig.c',
|
||||
'wincreatewnd.c',
|
||||
'wincursor.c',
|
||||
'windialogs.c',
|
||||
'winengine.c',
|
||||
'winerror.c',
|
||||
'winglobals.c',
|
||||
'winkeybd.c',
|
||||
'winkeyhook.c',
|
||||
'winmisc.c',
|
||||
'winmonitors.c',
|
||||
'winmouse.c',
|
||||
'winmsg.c',
|
||||
'winmsgwindow.c',
|
||||
'winmultiwindowclass.c',
|
||||
'winmultiwindowicons.c',
|
||||
'winos.c',
|
||||
'winprefs.c',
|
||||
'winprocarg.c',
|
||||
'winscrinit.c',
|
||||
'winshadddnl.c',
|
||||
'winshadgdi.c',
|
||||
'wintaskbar.c',
|
||||
'wintrayicon.c',
|
||||
'winvalargs.c',
|
||||
'winwakeup.c',
|
||||
'winwindow.c',
|
||||
'winwndproc.c',
|
||||
'ddraw.h',
|
||||
'winconfig.h',
|
||||
'win.h',
|
||||
'winglobals.h',
|
||||
'winkeybd.h',
|
||||
'winkeynames.h',
|
||||
'winlayouts.h',
|
||||
'winmessages.h',
|
||||
'winmonitors.h',
|
||||
'winmsg.h',
|
||||
'winms.h',
|
||||
'winmultiwindowclass.h',
|
||||
'winmultiwindowicons.h',
|
||||
'winprefs.h',
|
||||
'winresource.h',
|
||||
'winwindow.h',
|
||||
'windisplay.c',
|
||||
'windisplay.h',
|
||||
'../../mi/miinitext.c',
|
||||
'../../mi/miinitext.h',
|
||||
]
|
||||
|
||||
rsrc = windows.compile_resources('XWin.rc', include_directories: include_directories('../../include/'))
|
||||
srcs_windows += rsrc
|
||||
|
||||
flex = find_program('flex')
|
||||
bison = find_program('bison')
|
||||
|
||||
lgen = generator(
|
||||
flex,
|
||||
output : '@PLAINNAME@.yy.c',
|
||||
arguments : ['-i', '-o', '@OUTPUT@', '@INPUT@']
|
||||
)
|
||||
|
||||
lfiles = lgen.process('winprefslex.l')
|
||||
srcs_windows += lfiles
|
||||
|
||||
pgen = generator(
|
||||
bison,
|
||||
output : ['@BASENAME@.c', '@BASENAME@.h'],
|
||||
arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
|
||||
)
|
||||
|
||||
pfiles = pgen.process('winprefsyacc.y')
|
||||
srcs_windows += pfiles
|
||||
|
||||
xwin_dep = [
|
||||
common_dep,
|
||||
dependency('xcb-aux'),
|
||||
dependency('xcb-image'),
|
||||
dependency('xcb-ewmh'),
|
||||
dependency('xcb-icccm'),
|
||||
dependency('xcb-composite'),
|
||||
]
|
||||
|
||||
executable(
|
||||
server_name,
|
||||
srcs_windows,
|
||||
include_directories: [inc, top_dir_inc],
|
||||
dependencies: xwin_dep,
|
||||
link_with: [
|
||||
xwin_windowsdri,
|
||||
xwin_glx,
|
||||
xwin_clipboard,
|
||||
libxserver_fb,
|
||||
libxserver,
|
||||
libxserver_glx,
|
||||
libglxvnd,
|
||||
libxserver_xkb_stubs,
|
||||
libxserver_miext_shadow,
|
||||
libxserver_pseudoramix,
|
||||
libxserver_xi_stubs,
|
||||
],
|
||||
link_args: ['-Wl,--disable-stdcall-fixup', '-Wl,--export-all-symbols'] + xwin_sys_libs,
|
||||
c_args: xwin_c_args,
|
||||
gui_app: true,
|
||||
install: true,
|
||||
)
|
||||
|
||||
install_data(
|
||||
'system.XWinrc',
|
||||
install_dir: join_paths(get_option('sysconfdir'), 'X11')
|
||||
)
|
||||
|
||||
xwin_man = configure_file(
|
||||
input: 'man/XWin.man',
|
||||
output: 'XWin.1',
|
||||
configuration: manpage_config,
|
||||
)
|
||||
install_man(xwin_man)
|
||||
|
||||
xwinrc_man = configure_file(
|
||||
input: 'man/XWinrc.man',
|
||||
output: 'XWinrc.5',
|
||||
configuration: manpage_config,
|
||||
)
|
||||
install_man(xwinrc_man)
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Tobias Häußler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifndef PROPERTYSTORE_H
|
||||
#define PROPERTYSTORE_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __MINGW64_VERSION_MAJOR
|
||||
/* If we are using headers from mingw-w64 project, it provides the PSDK headers this needs ... */
|
||||
#include <propkey.h>
|
||||
#include <propsys.h>
|
||||
#else /* !__MINGW64_VERSION_MAJOR */
|
||||
/* ... otherwise, we need to define all this stuff ourselves */
|
||||
|
||||
typedef struct _tagpropertykey {
|
||||
GUID fmtid;
|
||||
DWORD pid;
|
||||
} PROPERTYKEY;
|
||||
|
||||
#define REFPROPERTYKEY const PROPERTYKEY *
|
||||
#define REFPROPVARIANT const PROPVARIANT *
|
||||
|
||||
WINOLEAPI PropVariantClear(PROPVARIANT *pvar);
|
||||
|
||||
#ifdef INTERFACE
|
||||
#undef INTERFACE
|
||||
#endif
|
||||
|
||||
#define INTERFACE IPropertyStore
|
||||
DECLARE_INTERFACE_(IPropertyStore, IUnknown)
|
||||
{
|
||||
STDMETHOD(QueryInterface) (THIS_ REFIID, PVOID *) PURE;
|
||||
STDMETHOD_(ULONG, AddRef) (THIS) PURE;
|
||||
STDMETHOD_(ULONG, Release) (THIS) PURE;
|
||||
STDMETHOD(GetCount) (THIS_ DWORD) PURE;
|
||||
STDMETHOD(GetAt) (THIS_ DWORD, PROPERTYKEY) PURE;
|
||||
STDMETHOD(GetValue) (THIS_ REFPROPERTYKEY, PROPVARIANT) PURE;
|
||||
STDMETHOD(SetValue) (THIS_ REFPROPERTYKEY, REFPROPVARIANT) PURE;
|
||||
STDMETHOD(Commit) (THIS) PURE;
|
||||
};
|
||||
|
||||
#undef INTERFACE
|
||||
typedef IPropertyStore *LPPROPERTYSTORE;
|
||||
|
||||
DEFINE_GUID(IID_IPropertyStore, 0x886d8eeb, 0x8cf2, 0x4446, 0x8d, 0x02, 0xcd,
|
||||
0xba, 0x1d, 0xbd, 0xcf, 0x99);
|
||||
|
||||
#ifdef INITGUID
|
||||
#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) GUID_EXT const PROPERTYKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
|
||||
#else
|
||||
#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) GUID_EXT const PROPERTYKEY name
|
||||
#endif
|
||||
|
||||
DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0,
|
||||
0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5);
|
||||
|
||||
#endif /* !__MINGW64_VERSION_MAJOR */
|
||||
|
||||
typedef HRESULT(__stdcall * SHGETPROPERTYSTOREFORWINDOWPROC) (HWND, REFIID,
|
||||
void **);
|
||||
|
||||
#endif
|
|
@ -1,124 +0,0 @@
|
|||
# XWin Server Resource File - EXAMPLE
|
||||
# Earle F. Philhower, III
|
||||
|
||||
# Place in ~/.XWinrc or in /etc/X11/system.XWinrc
|
||||
|
||||
# Keywords are case insensitive, comments legal pretty much anywhere
|
||||
# you can have an end-of-line
|
||||
|
||||
# Comments begin with "#" or "//" and go to the end-of-line
|
||||
|
||||
# Menus are defined as...
|
||||
# MENU <name> {
|
||||
# <Menu Text> EXEC <command>
|
||||
# ^^ This command will have any "%display%"
|
||||
# string replaced with the proper display
|
||||
# variable (i.e. 127.0.0.1:<display>.0)
|
||||
# (This should only rarely be needed as
|
||||
# the DISPLAY environment variable is also
|
||||
# set correctly)
|
||||
# or <Menu Text> MENU <name-of-some-prior-defined-menu>
|
||||
# or <Menu Text> ALWAYSONTOP
|
||||
# ^^ Sets the window to display above all others
|
||||
# or <Menu Text> RELOAD
|
||||
# ^^ Causes ~/.XWinrc or the system.XWinrc file
|
||||
# to be reloaded and icons and menus regenerated
|
||||
# or SEPARATOR
|
||||
# ...
|
||||
# }
|
||||
|
||||
# Set the taskmar menu with
|
||||
# ROOTMENU <name-of-some-prior-defined-menu>
|
||||
|
||||
# If you want a menu to be applied to all popup window's system menu
|
||||
# DEFAULTSYSMENU <name-of-some-prior-defined-menu> <atstart|atend>
|
||||
|
||||
# To choose a specific menu for a specific WM_CLASS or WM_NAME use ...
|
||||
# SYSMENU {
|
||||
# <class-or-name-of-window> <name-of-prior-defined-menu> <atstart|atend>
|
||||
# ...
|
||||
# }
|
||||
|
||||
# When specifying an ICONFILE in the following commands several different
|
||||
# formats are allowed:
|
||||
# 1. Name of a regular Windows .ico format file
|
||||
# (ex: "cygwin.ico", "apple.ico")
|
||||
# 2. Name and index into a Windows .DLL
|
||||
# (ex: "c:\windows\system32\shell32.dll,4" gives the default folder icon
|
||||
# "c:\windows\system32\shell32.dll,5" gives the floppy drive icon)
|
||||
# 3. Index into XWin.EXE internal ICON resource
|
||||
# (ex: ",101" is the 1st icon inside XWin.exe)
|
||||
|
||||
# To define where ICO files live (** Windows path**)
|
||||
# ICONDIRECTORY <windows-path i.e. c:\cygwin\usr\icons>
|
||||
# NOTE: If you specify an absolute path in Windows or Cygwin format to an ICON below
|
||||
# (i.e. "c:\icons\xxx.ico" or "/usr/share/icons/xxx.ico")
|
||||
# this ICONDIRECTORY will not be prepended
|
||||
|
||||
# To change the taskbar icon use...
|
||||
# TRAYICON <icon-specifier>
|
||||
|
||||
# To define a replacement for the standard X icon for apps w/o specified icons
|
||||
# DEFAULTICON <icon-specifier>
|
||||
|
||||
# To define substitute icons on a per-window basis use...
|
||||
# ICONS {
|
||||
# <class-or-name-of-window> <icon-file-name.ico>
|
||||
# ...
|
||||
# }
|
||||
# In the case where multiple matches occur, the first listed in the ICONS
|
||||
# section will be chosen.
|
||||
|
||||
# To disable exit confirmation dialog add the line containing SilentExit
|
||||
|
||||
# DEBUG <string> prints out the string to the XWin.log file
|
||||
|
||||
// Below are just some silly menus to demonstrate writing your
|
||||
// own configuration file.
|
||||
|
||||
// Make some menus...
|
||||
menu apps {
|
||||
xterm exec "xterm"
|
||||
"Emacs" exec "emacs"
|
||||
notepad exec notepad
|
||||
xload exec "xload -display %display%" # Comment
|
||||
}
|
||||
|
||||
menu root {
|
||||
// Comments fit here, too...
|
||||
"Reload .XWinrc" RELOAD
|
||||
"Applications" menu apps
|
||||
SEParATOR
|
||||
}
|
||||
|
||||
menu aot {
|
||||
Separator
|
||||
"Always on Top" alwaysontop
|
||||
}
|
||||
|
||||
menu xtermspecial {
|
||||
"Emacs" exec "emacs"
|
||||
"Always on Top" alwaysontop
|
||||
SepArAtor
|
||||
}
|
||||
|
||||
RootMenu root
|
||||
|
||||
DefaultSysMenu aot atend
|
||||
|
||||
SysMenu {
|
||||
"xterm" xtermspecial atstart
|
||||
}
|
||||
|
||||
# IconDirectory "c:\winnt\"
|
||||
|
||||
# DefaultIcon "reinstall.ico"
|
||||
|
||||
# Icons {
|
||||
# "xterm" "uninstall.ico"
|
||||
# }
|
||||
|
||||
SilentExit
|
||||
|
||||
DEBUG "Done parsing the configuration file..."
|
||||
|
1045
hw/xwin/win.h
1045
hw/xwin/win.h
File diff suppressed because it is too large
Load Diff
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Tobias Häußler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xwindows.h>
|
||||
#include <pthread.h>
|
||||
#include "winwindow.h"
|
||||
#include "os.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
#include <shlwapi.h>
|
||||
|
||||
#define INITGUID
|
||||
#include "initguid.h"
|
||||
#include "propertystore.h"
|
||||
#undef INITGUID
|
||||
|
||||
static HMODULE g_hmodShell32Dll = NULL;
|
||||
static SHGETPROPERTYSTOREFORWINDOWPROC g_pSHGetPropertyStoreForWindow = NULL;
|
||||
|
||||
void
|
||||
winPropertyStoreInit(void)
|
||||
{
|
||||
/*
|
||||
Load library and get function pointer to SHGetPropertyStoreForWindow()
|
||||
|
||||
SHGetPropertyStoreForWindow is only supported since Windows 7. On previous
|
||||
versions the pointer will be NULL and taskbar grouping is not supported.
|
||||
winSetAppUserModelID() will do nothing in this case.
|
||||
*/
|
||||
g_hmodShell32Dll = LoadLibrary("shell32.dll");
|
||||
if (g_hmodShell32Dll == NULL) {
|
||||
ErrorF("winPropertyStoreInit - Could not load shell32.dll\n");
|
||||
return;
|
||||
}
|
||||
|
||||
g_pSHGetPropertyStoreForWindow =
|
||||
(SHGETPROPERTYSTOREFORWINDOWPROC) GetProcAddress(g_hmodShell32Dll,
|
||||
"SHGetPropertyStoreForWindow");
|
||||
if (g_pSHGetPropertyStoreForWindow == NULL) {
|
||||
ErrorF
|
||||
("winPropertyStoreInit - Could not get SHGetPropertyStoreForWindow address\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
winPropertyStoreDestroy(void)
|
||||
{
|
||||
if (g_hmodShell32Dll != NULL) {
|
||||
FreeLibrary(g_hmodShell32Dll);
|
||||
g_hmodShell32Dll = NULL;
|
||||
g_pSHGetPropertyStoreForWindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
winSetAppUserModelID(HWND hWnd, const char *AppID)
|
||||
{
|
||||
PROPVARIANT pv;
|
||||
IPropertyStore *pps = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
if (g_pSHGetPropertyStoreForWindow == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
winDebug("winSetAppUserMOdelID - hwnd 0x%p appid '%s'\n", hWnd, AppID);
|
||||
|
||||
hr = g_pSHGetPropertyStoreForWindow(hWnd, &IID_IPropertyStore,
|
||||
(void **) &pps);
|
||||
if (SUCCEEDED(hr) && pps) {
|
||||
memset(&pv, 0, sizeof(PROPVARIANT));
|
||||
if (AppID) {
|
||||
pv.vt = VT_LPWSTR;
|
||||
hr = SHStrDupA(AppID, &pv.pwszVal);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
pps->lpVtbl->SetValue(pps, &PKEY_AppUserModel_ID, &pv);
|
||||
PropVariantClear(&pv);
|
||||
}
|
||||
pps->lpVtbl->Release(pps);
|
||||
}
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Keith Packard, MIT X Consortium
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/* See Porting Layer Definition - p. 58 */
|
||||
/*
|
||||
* Allocate indexes for the privates that we use.
|
||||
* Allocate memory directly for the screen privates.
|
||||
* Reserve space in GCs and Pixmaps for our privates.
|
||||
* Colormap privates are handled in winAllocateCmapPrivates ()
|
||||
*/
|
||||
|
||||
Bool
|
||||
winAllocatePrivates(ScreenPtr pScreen)
|
||||
{
|
||||
winPrivScreenPtr pScreenPriv;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winAllocateScreenPrivates - g_ulServerGeneration: %lu "
|
||||
"serverGeneration: %lu\n", g_ulServerGeneration, serverGeneration);
|
||||
#endif
|
||||
|
||||
/* We need a new slot for our privates if the screen gen has changed */
|
||||
if (g_ulServerGeneration != serverGeneration) {
|
||||
g_ulServerGeneration = serverGeneration;
|
||||
}
|
||||
|
||||
/* Allocate memory for the screen private structure */
|
||||
pScreenPriv = malloc(sizeof(winPrivScreenRec));
|
||||
if (!pScreenPriv) {
|
||||
ErrorF("winAllocateScreenPrivates - malloc () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize the memory of the private structure */
|
||||
ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec));
|
||||
|
||||
/* Initialize private structure members */
|
||||
pScreenPriv->fActive = TRUE;
|
||||
|
||||
/* Register our screen private */
|
||||
if (!dixRegisterPrivateKey(g_iScreenPrivateKey, PRIVATE_SCREEN, 0)) {
|
||||
ErrorF("winAllocatePrivates - AllocateScreenPrivate () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Save the screen private pointer */
|
||||
winSetScreenPriv(pScreen, pScreenPriv);
|
||||
|
||||
/* Reserve Pixmap memory for our privates */
|
||||
if (!dixRegisterPrivateKey
|
||||
(g_iPixmapPrivateKey, PRIVATE_PIXMAP, sizeof(winPrivPixmapRec))) {
|
||||
ErrorF("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Reserve Window memory for our privates */
|
||||
if (!dixRegisterPrivateKey
|
||||
(g_iWindowPrivateKey, PRIVATE_WINDOW, sizeof(winPrivWinRec))) {
|
||||
ErrorF("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Colormap privates may be allocated after the default colormap has
|
||||
* already been created for some screens. This initialization procedure
|
||||
* is called for each default colormap that is found.
|
||||
*/
|
||||
|
||||
Bool
|
||||
winInitCmapPrivates(ColormapPtr pcmap, int i)
|
||||
{
|
||||
#if CYGDEBUG
|
||||
winDebug("winInitCmapPrivates\n");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* I see no way that this function can do anything useful
|
||||
* with only a ColormapPtr. We don't have the index for
|
||||
* our dev privates yet, so we can't really initialize
|
||||
* anything. Perhaps I am misunderstanding the purpose
|
||||
* of this function.
|
||||
*/
|
||||
/* That's definitely true.
|
||||
* I therefore changed the API and added the index as argument.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate memory for our colormap privates
|
||||
*/
|
||||
|
||||
Bool
|
||||
winAllocateCmapPrivates(ColormapPtr pCmap)
|
||||
{
|
||||
winPrivCmapPtr pCmapPriv;
|
||||
static unsigned long s_ulPrivateGeneration = 0;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winAllocateCmapPrivates\n");
|
||||
#endif
|
||||
|
||||
/* Get a new privates index when the server generation changes */
|
||||
if (s_ulPrivateGeneration != serverGeneration) {
|
||||
/* Save the new server generation */
|
||||
s_ulPrivateGeneration = serverGeneration;
|
||||
}
|
||||
|
||||
/* Allocate memory for our private structure */
|
||||
pCmapPriv = malloc(sizeof(winPrivCmapRec));
|
||||
if (!pCmapPriv) {
|
||||
ErrorF("winAllocateCmapPrivates - malloc () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize the memory of the private structure */
|
||||
ZeroMemory(pCmapPriv, sizeof(winPrivCmapRec));
|
||||
|
||||
/* Register our colourmap private */
|
||||
if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0)) {
|
||||
ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Save the cmap private pointer */
|
||||
winSetCmapPriv(pCmap, pCmapPriv);
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winAllocateCmapPrivates - Returning\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "winauth.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
/* Includes for authorization */
|
||||
#include "securitysrv.h"
|
||||
#include "os/osdep.h"
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
||||
#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
|
||||
|
||||
/*
|
||||
* Locals
|
||||
*/
|
||||
|
||||
static XID g_authId = 0;
|
||||
static unsigned int g_uiAuthDataLen = 0;
|
||||
static char *g_pAuthData = NULL;
|
||||
static xcb_auth_info_t auth_info;
|
||||
|
||||
/*
|
||||
* Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
|
||||
*/
|
||||
|
||||
#ifndef XCSECURITY
|
||||
static XID
|
||||
GenerateAuthorization(unsigned name_length,
|
||||
const char *name,
|
||||
unsigned data_length,
|
||||
const char *data,
|
||||
unsigned *data_length_return, char **data_return)
|
||||
{
|
||||
return MitGenerateCookie(data_length, data,
|
||||
FakeClientID(0), data_length_return, data_return);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generate authorization cookie for internal server clients
|
||||
*/
|
||||
|
||||
BOOL
|
||||
winGenerateAuthorization(void)
|
||||
{
|
||||
#ifdef XCSECURITY
|
||||
SecurityAuthorizationPtr pAuth = NULL;
|
||||
#endif
|
||||
|
||||
/* Call OS layer to generate authorization key */
|
||||
g_authId = GenerateAuthorization(strlen(AUTH_NAME),
|
||||
AUTH_NAME,
|
||||
0, NULL, &g_uiAuthDataLen, &g_pAuthData);
|
||||
if ((XID) ~0L == g_authId) {
|
||||
ErrorF("winGenerateAuthorization - GenerateAuthorization failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
else {
|
||||
winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
|
||||
"AuthDataLen: %d AuthData: %s\n",
|
||||
g_uiAuthDataLen, g_pAuthData);
|
||||
}
|
||||
|
||||
auth_info.name = strdup(AUTH_NAME);
|
||||
auth_info.namelen = strlen(AUTH_NAME);
|
||||
auth_info.data = g_pAuthData;
|
||||
auth_info.datalen = g_uiAuthDataLen;
|
||||
|
||||
#ifdef XCSECURITY
|
||||
/* Allocate structure for additional auth information */
|
||||
pAuth = (SecurityAuthorizationPtr)
|
||||
malloc(sizeof(SecurityAuthorizationRec));
|
||||
if (!(pAuth)) {
|
||||
ErrorF("winGenerateAuthorization - Failed allocating "
|
||||
"SecurityAuthorizationPtr.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Fill in the auth fields */
|
||||
pAuth->id = g_authId;
|
||||
pAuth->timeout = 0; /* live for x seconds after refcnt == 0 */
|
||||
pAuth->group = None;
|
||||
pAuth->trustLevel = XSecurityClientTrusted;
|
||||
pAuth->refcnt = 1; /* this auth must stick around */
|
||||
pAuth->secondsRemaining = 0;
|
||||
pAuth->timer = NULL;
|
||||
pAuth->eventClients = NULL;
|
||||
|
||||
/* Add the authorization to the server's auth list */
|
||||
if (!AddResource(g_authId, SecurityAuthorizationResType, pAuth)) {
|
||||
ErrorF("winGenerateAuthorization - AddResource failed for auth.\n");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
xcb_auth_info_t *
|
||||
winGetXcbAuthInfo(void)
|
||||
{
|
||||
if (g_pAuthData)
|
||||
return &auth_info;
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <X11/Xmd.h> // for BOOL
|
||||
|
||||
BOOL winGenerateAuthorization(void);
|
||||
xcb_auth_info_t * winGetXcbAuthInfo(void);
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
/* See Porting Layer Definition - p. 6 */
|
||||
void
|
||||
winBlockHandler(ScreenPtr pScreen, void *pTimeout)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#ifndef HAS_DEVWINDOWS
|
||||
struct timeval **tvp = pTimeout;
|
||||
|
||||
if (*tvp != NULL) {
|
||||
if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) {
|
||||
/* If there are still messages to process on the Windows message
|
||||
queue, make sure select() just polls rather than blocking.
|
||||
*/
|
||||
(*tvp)->tv_sec = 0;
|
||||
(*tvp)->tv_usec = 0;
|
||||
}
|
||||
else {
|
||||
/* Otherwise, lacking /dev/windows, we must wake up again in
|
||||
a reasonable time to check the Windows message queue. without
|
||||
noticeable delay.
|
||||
*/
|
||||
(*tvp)->tv_sec = 0;
|
||||
(*tvp)->tv_usec = 100;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Signal threaded modules to begin */
|
||||
if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) {
|
||||
int iReturn;
|
||||
|
||||
winDebug("winBlockHandler - pthread_mutex_unlock()\n");
|
||||
|
||||
/* Flag that modules are to be started */
|
||||
pScreenPriv->fServerStarted = TRUE;
|
||||
|
||||
/* Unlock the mutex for threaded modules */
|
||||
iReturn = pthread_mutex_unlock(&pScreenPriv->pmServerStarted);
|
||||
if (iReturn != 0) {
|
||||
ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
|
||||
iReturn);
|
||||
}
|
||||
else {
|
||||
winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
At least one X client has asked to suspend the screensaver, so
|
||||
reset Windows' display idle timer
|
||||
*/
|
||||
#ifdef SCREENSAVER
|
||||
if (screenSaverSuspended)
|
||||
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
|
||||
#endif
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
//
|
||||
// Copyright © Jon TURNEY 2013
|
||||
//
|
||||
// This file is part of xwinclip.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice (including the next
|
||||
// paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
//
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if 1
|
||||
int
|
||||
winDebug(const char *format, ...)
|
||||
{
|
||||
int count;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
count = fprintf(stderr, "xwinclip: ");
|
||||
count += vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
ErrorF(const char *format, ...)
|
||||
{
|
||||
int count;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
count = vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
return count;
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifndef WINCLIPBOARD_INTERNAL_H
|
||||
#define WINCLIPBOARD_INTERNAL_H
|
||||
|
||||
#include <xcb/xproto.h>
|
||||
#include <X11/Xfuncproto.h> // for _X_ATTRIBUTE_PRINTF
|
||||
#include <X11/Xmd.h> // for BOOL
|
||||
|
||||
/* Windows headers */
|
||||
#include <X11/Xwindows.h>
|
||||
|
||||
#define WIN_XEVENTS_SUCCESS 0 // more like 'CONTINUE'
|
||||
#define WIN_XEVENTS_FAILED 1
|
||||
#define WIN_XEVENTS_NOTIFY_DATA 3
|
||||
#define WIN_XEVENTS_NOTIFY_TARGETS 4
|
||||
|
||||
#define WM_WM_QUIT (WM_USER + 2)
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
|
||||
|
||||
/*
|
||||
* References to external symbols
|
||||
*/
|
||||
|
||||
extern void winDebug(const char *format, ...) _X_ATTRIBUTE_PRINTF(1, 2);
|
||||
extern void ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1, 2);
|
||||
|
||||
/*
|
||||
* winclipboardtextconv.c
|
||||
*/
|
||||
|
||||
void
|
||||
winClipboardDOStoUNIX(char *pszData, int iLength);
|
||||
|
||||
void
|
||||
winClipboardUNIXtoDOS(char **ppszData, int iLength);
|
||||
|
||||
/*
|
||||
* winclipboardthread.c
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
xcb_atom_t atomClipboard;
|
||||
xcb_atom_t atomLocalProperty;
|
||||
xcb_atom_t atomUTF8String;
|
||||
xcb_atom_t atomCompoundText;
|
||||
xcb_atom_t atomTargets;
|
||||
xcb_atom_t atomIncr;
|
||||
} ClipboardAtoms;
|
||||
|
||||
/*
|
||||
* winclipboardwndproc.c
|
||||
*/
|
||||
|
||||
BOOL winClipboardFlushWindowsMessageQueue(HWND hwnd);
|
||||
|
||||
LRESULT CALLBACK
|
||||
winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
xcb_connection_t *pClipboardDisplay;
|
||||
xcb_window_t iClipboardWindow;
|
||||
ClipboardAtoms *atoms;
|
||||
} ClipboardWindowCreationParams;
|
||||
|
||||
/*
|
||||
* winclipboardxevents.c
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
xcb_atom_t *targetList;
|
||||
unsigned char *incr;
|
||||
unsigned long int incrsize;
|
||||
} ClipboardConversionData;
|
||||
|
||||
int
|
||||
winClipboardFlushXEvents(HWND hwnd,
|
||||
xcb_window_t iWindow, xcb_connection_t * pDisplay,
|
||||
ClipboardConversionData *data, ClipboardAtoms *atoms);
|
||||
|
||||
xcb_atom_t
|
||||
winClipboardGetLastOwnedSelectionAtom(ClipboardAtoms *atoms);
|
||||
|
||||
void
|
||||
winClipboardInitMonitoredSelections(void);
|
||||
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
srcs_windows_clipboard = [
|
||||
'winclipboard.h',
|
||||
'textconv.c',
|
||||
'thread.c',
|
||||
'wndproc.c',
|
||||
'xevents.c',
|
||||
]
|
||||
|
||||
xwin_clipboard = static_library(
|
||||
'XWinclipboard',
|
||||
srcs_windows_clipboard,
|
||||
include_directories: inc,
|
||||
c_args: '-DHAVE_XWIN_CONFIG_H',
|
||||
dependencies: [
|
||||
dependency('xcb'),
|
||||
dependency('xcb-aux'),
|
||||
dependency('xcb-icccm'),
|
||||
dependency('xcb-xfixes'),
|
||||
socket_dep,
|
||||
],
|
||||
)
|
||||
|
||||
srcs_xwinclip = [
|
||||
'xwinclip.c',
|
||||
'debug.c',
|
||||
]
|
||||
|
||||
executable(
|
||||
'xwinclip',
|
||||
srcs_xwinclip,
|
||||
link_with: xwin_clipboard,
|
||||
link_args: ['-lgdi32', '-lpthread'],
|
||||
install: true,
|
||||
)
|
||||
|
||||
xwinclip_man = configure_file(
|
||||
input: 'xwinclip.man',
|
||||
output: 'xwinclip.1',
|
||||
configuration: manpage_config,
|
||||
)
|
||||
install_man(xwinclip_man)
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "internal.h"
|
||||
|
||||
/*
|
||||
* Convert \r\n to \n
|
||||
*
|
||||
* NOTE: This was heavily inspired by, Cygwin's
|
||||
* winsup/cygwin/fhandler.cc/fhandler_base::read ()
|
||||
*/
|
||||
|
||||
void
|
||||
winClipboardDOStoUNIX(char *pszSrc, int iLength)
|
||||
{
|
||||
char *pszDest = pszSrc;
|
||||
char *pszEnd = pszSrc + iLength;
|
||||
|
||||
/* Loop until the last character */
|
||||
while (pszSrc < pszEnd) {
|
||||
/* Copy the current source character to current destination character */
|
||||
*pszDest = *pszSrc;
|
||||
|
||||
/* Advance to the next source character */
|
||||
pszSrc++;
|
||||
|
||||
/* Don't advance the destination character if we need to drop an \r */
|
||||
if (*pszDest != '\r' || *pszSrc != '\n')
|
||||
pszDest++;
|
||||
}
|
||||
|
||||
/* Move the terminating null */
|
||||
*pszDest = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert \n to \r\n
|
||||
*/
|
||||
|
||||
void
|
||||
winClipboardUNIXtoDOS(char **ppszData, int iLength)
|
||||
{
|
||||
int iNewlineCount = 0;
|
||||
char *pszSrc = *ppszData;
|
||||
char *pszEnd = pszSrc + iLength;
|
||||
char *pszDest = NULL, *pszDestBegin = NULL;
|
||||
|
||||
winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData);
|
||||
|
||||
/* Count \n characters without leading \r */
|
||||
while (pszSrc < pszEnd) {
|
||||
/* Skip ahead two character if found set of \r\n */
|
||||
if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n') {
|
||||
pszSrc += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Increment the count if found naked \n */
|
||||
if (*pszSrc == '\n') {
|
||||
iNewlineCount++;
|
||||
}
|
||||
|
||||
pszSrc++;
|
||||
}
|
||||
|
||||
/* Return if no naked \n's */
|
||||
if (iNewlineCount == 0)
|
||||
return;
|
||||
|
||||
/* Allocate a new string */
|
||||
pszDestBegin = pszDest = malloc(iLength + iNewlineCount + 1);
|
||||
|
||||
/* Set source pointer to beginning of data string */
|
||||
pszSrc = *ppszData;
|
||||
|
||||
/* Loop through all characters in source string */
|
||||
while (pszSrc < pszEnd) {
|
||||
/* Copy line endings that are already valid */
|
||||
if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n') {
|
||||
*pszDest = *pszSrc;
|
||||
*(pszDest + 1) = *(pszSrc + 1);
|
||||
pszDest += 2;
|
||||
pszSrc += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add \r to naked \n's */
|
||||
if (*pszSrc == '\n') {
|
||||
*pszDest = '\r';
|
||||
*(pszDest + 1) = *pszSrc;
|
||||
pszDest += 2;
|
||||
pszSrc += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Copy normal characters */
|
||||
*pszDest = *pszSrc;
|
||||
pszSrc++;
|
||||
pszDest++;
|
||||
}
|
||||
|
||||
/* Put terminating null at end of new string */
|
||||
*pszDest = '\0';
|
||||
|
||||
/* Swap string pointers */
|
||||
free(*ppszData);
|
||||
*ppszData = pszDestBegin;
|
||||
|
||||
winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin);
|
||||
}
|
|
@ -1,439 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 copyright holder(s)
|
||||
*and author(s) 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 copyright holder(s) and author(s).
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#else
|
||||
#define HAS_WINSOCK 1
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/param.h> // for MAX() macro
|
||||
|
||||
#ifdef HAS_WINSOCK
|
||||
#include <X11/Xwinsock.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_aux.h>
|
||||
#include <xcb/xcb_icccm.h>
|
||||
#include <xcb/xfixes.h>
|
||||
|
||||
#include "winclipboard.h"
|
||||
#include "internal.h"
|
||||
|
||||
#define WIN_CONNECT_RETRIES 40
|
||||
#define WIN_CONNECT_DELAY 4
|
||||
|
||||
#define WIN_CLIPBOARD_WINDOW_CLASS "xwinclip"
|
||||
#define WIN_CLIPBOARD_WINDOW_TITLE "xwinclip"
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
#define WIN_MSG_QUEUE_FNAME "/dev/windows"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
|
||||
static HWND g_hwndClipboard = NULL;
|
||||
|
||||
int xfixes_event_base;
|
||||
int xfixes_error_base;
|
||||
|
||||
/*
|
||||
* Local function prototypes
|
||||
*/
|
||||
|
||||
static HWND
|
||||
winClipboardCreateMessagingWindow(xcb_connection_t *conn, xcb_window_t iWindow, ClipboardAtoms *atoms);
|
||||
|
||||
static xcb_atom_t
|
||||
intern_atom(xcb_connection_t *conn, const char *atomName)
|
||||
{
|
||||
xcb_intern_atom_reply_t *atom_reply;
|
||||
xcb_intern_atom_cookie_t atom_cookie;
|
||||
xcb_atom_t atom = XCB_ATOM_NONE;
|
||||
|
||||
atom_cookie = xcb_intern_atom(conn, 0, strlen(atomName), atomName);
|
||||
atom_reply = xcb_intern_atom_reply(conn, atom_cookie, NULL);
|
||||
if (atom_reply) {
|
||||
atom = atom_reply->atom;
|
||||
free(atom_reply);
|
||||
}
|
||||
return atom;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create X11 and Win32 messaging windows, and run message processing loop
|
||||
*
|
||||
* returns TRUE if shutdown was signalled to loop, FALSE if some error occurred
|
||||
*/
|
||||
|
||||
BOOL
|
||||
winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info)
|
||||
{
|
||||
ClipboardAtoms atoms;
|
||||
int iReturn;
|
||||
HWND hwnd = NULL;
|
||||
int iConnectionNumber = 0;
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
int fdMessageQueue = 0;
|
||||
#else
|
||||
struct timeval tvTimeout;
|
||||
#endif
|
||||
fd_set fdsRead;
|
||||
int iMaxDescriptor;
|
||||
xcb_connection_t *conn;
|
||||
xcb_window_t iWindow = XCB_NONE;
|
||||
int iSelectError;
|
||||
BOOL fShutdown = FALSE;
|
||||
ClipboardConversionData data;
|
||||
int screen;
|
||||
|
||||
winDebug("winClipboardProc - Hello\n");
|
||||
|
||||
/* Make sure that the display opened */
|
||||
conn = xcb_connect_to_display_with_auth_info(szDisplay, auth_info, &screen);
|
||||
if (xcb_connection_has_error(conn)) {
|
||||
ErrorF("winClipboardProc - Failed opening the display, giving up\n");
|
||||
goto winClipboardProc_Done;
|
||||
}
|
||||
|
||||
ErrorF("winClipboardProc - xcb_connect () returned and "
|
||||
"successfully opened the display.\n");
|
||||
|
||||
/* Get our connection number */
|
||||
iConnectionNumber = xcb_get_file_descriptor(conn);
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
/* Open a file descriptor for the windows message queue */
|
||||
fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
|
||||
if (fdMessageQueue == -1) {
|
||||
ErrorF("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
|
||||
goto winClipboardProc_Done;
|
||||
}
|
||||
|
||||
/* Find max of our file descriptors */
|
||||
iMaxDescriptor = MAX(fdMessageQueue, iConnectionNumber) + 1;
|
||||
#else
|
||||
iMaxDescriptor = iConnectionNumber + 1;
|
||||
#endif
|
||||
|
||||
const xcb_query_extension_reply_t *xfixes_query;
|
||||
xfixes_query = xcb_get_extension_data(conn, &xcb_xfixes_id);
|
||||
if (!xfixes_query->present)
|
||||
ErrorF ("winClipboardProc - XFixes extension not present\n");
|
||||
xfixes_event_base = xfixes_query->first_event;
|
||||
xfixes_error_base = xfixes_query->first_error;
|
||||
/* Must advise server of XFIXES version we require */
|
||||
xcb_xfixes_query_version_unchecked(conn, 1, 0);
|
||||
|
||||
/* Create atoms */
|
||||
atoms.atomClipboard = intern_atom(conn, "CLIPBOARD");
|
||||
atoms.atomLocalProperty = intern_atom(conn, "CYGX_CUT_BUFFER");
|
||||
atoms.atomUTF8String = intern_atom(conn, "UTF8_STRING");
|
||||
atoms.atomCompoundText = intern_atom(conn, "COMPOUND_TEXT");
|
||||
atoms.atomTargets = intern_atom(conn, "TARGETS");
|
||||
atoms.atomIncr = intern_atom(conn, "INCR");
|
||||
|
||||
xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screen);
|
||||
xcb_window_t root_window_id = root_screen->root;
|
||||
|
||||
/* Create a messaging window */
|
||||
iWindow = xcb_generate_id(conn);
|
||||
xcb_void_cookie_t cookie = xcb_create_window_checked(conn,
|
||||
XCB_COPY_FROM_PARENT,
|
||||
iWindow,
|
||||
root_window_id,
|
||||
1, 1,
|
||||
500, 500,
|
||||
0,
|
||||
XCB_WINDOW_CLASS_INPUT_ONLY,
|
||||
XCB_COPY_FROM_PARENT,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
xcb_generic_error_t *error;
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardProc - Could not create an X window.\n");
|
||||
free(error);
|
||||
goto winClipboardProc_Done;
|
||||
}
|
||||
|
||||
xcb_icccm_set_wm_name(conn, iWindow, XCB_ATOM_STRING, 8, strlen("xwinclip"), "xwinclip");
|
||||
|
||||
/* Select event types to watch */
|
||||
const static uint32_t values[] = { XCB_EVENT_MASK_PROPERTY_CHANGE };
|
||||
cookie = xcb_change_window_attributes_checked(conn, iWindow, XCB_CW_EVENT_MASK, values);
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardProc - Could not set event mask on messaging window\n");
|
||||
free(error);
|
||||
}
|
||||
|
||||
xcb_xfixes_select_selection_input(conn,
|
||||
iWindow,
|
||||
XCB_ATOM_PRIMARY,
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE);
|
||||
|
||||
xcb_xfixes_select_selection_input(conn,
|
||||
iWindow,
|
||||
atoms.atomClipboard,
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |
|
||||
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE);
|
||||
|
||||
/* Initialize monitored selection state */
|
||||
winClipboardInitMonitoredSelections();
|
||||
/* Create Windows messaging window */
|
||||
hwnd = winClipboardCreateMessagingWindow(conn, iWindow, &atoms);
|
||||
|
||||
/* Save copy of HWND */
|
||||
g_hwndClipboard = hwnd;
|
||||
|
||||
/* Assert ownership of selections if Win32 clipboard is owned */
|
||||
if (NULL != GetClipboardOwner()) {
|
||||
/* PRIMARY */
|
||||
cookie = xcb_set_selection_owner_checked(conn, iWindow, XCB_ATOM_PRIMARY, XCB_CURRENT_TIME);
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardProc - Could not set PRIMARY owner\n");
|
||||
free(error);
|
||||
goto winClipboardProc_Done;
|
||||
}
|
||||
|
||||
/* CLIPBOARD */
|
||||
cookie = xcb_set_selection_owner_checked(conn, iWindow, atoms.atomClipboard, XCB_CURRENT_TIME);
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardProc - Could not set CLIPBOARD owner\n");
|
||||
free(error);
|
||||
goto winClipboardProc_Done;
|
||||
}
|
||||
}
|
||||
|
||||
data.incr = NULL;
|
||||
data.incrsize = 0;
|
||||
|
||||
/* Loop for events */
|
||||
while (1) {
|
||||
|
||||
/* Process X events */
|
||||
winClipboardFlushXEvents(hwnd, iWindow, conn, &data, &atoms);
|
||||
|
||||
/* Process Windows messages */
|
||||
if (!winClipboardFlushWindowsMessageQueue(hwnd)) {
|
||||
ErrorF("winClipboardProc - winClipboardFlushWindowsMessageQueue trapped "
|
||||
"WM_QUIT message, exiting main loop.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* We need to ensure that all pending requests are sent */
|
||||
xcb_flush(conn);
|
||||
|
||||
/* Setup the file descriptor set */
|
||||
/*
|
||||
* NOTE: You have to do this before every call to select
|
||||
* because select modifies the mask to indicate
|
||||
* which descriptors are ready.
|
||||
*/
|
||||
FD_ZERO(&fdsRead);
|
||||
FD_SET(iConnectionNumber, &fdsRead);
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
FD_SET(fdMessageQueue, &fdsRead);
|
||||
#else
|
||||
tvTimeout.tv_sec = 0;
|
||||
tvTimeout.tv_usec = 100;
|
||||
#endif
|
||||
|
||||
/* Wait for a Windows event or an X event */
|
||||
iReturn = select(iMaxDescriptor, /* Highest fds number */
|
||||
&fdsRead, /* Read mask */
|
||||
NULL, /* No write mask */
|
||||
NULL, /* No exception mask */
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
NULL /* No timeout */
|
||||
#else
|
||||
&tvTimeout /* Set timeout */
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifndef HAS_WINSOCK
|
||||
iSelectError = errno;
|
||||
#else
|
||||
iSelectError = WSAGetLastError();
|
||||
#endif
|
||||
|
||||
if (iReturn < 0) {
|
||||
#ifndef HAS_WINSOCK
|
||||
if (iSelectError == EINTR)
|
||||
#else
|
||||
if (iSelectError == WSAEINTR)
|
||||
#endif
|
||||
continue;
|
||||
|
||||
ErrorF("winClipboardProc - Call to select () failed: %d. "
|
||||
"Bailing.\n", iReturn);
|
||||
break;
|
||||
}
|
||||
|
||||
if (FD_ISSET(iConnectionNumber, &fdsRead)) {
|
||||
winDebug
|
||||
("winClipboardProc - X connection ready, pumping X event queue\n");
|
||||
}
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
/* Check for Windows event ready */
|
||||
if (FD_ISSET(fdMessageQueue, &fdsRead))
|
||||
#else
|
||||
if (1)
|
||||
#endif
|
||||
{
|
||||
winDebug
|
||||
("winClipboardProc - /dev/windows ready, pumping Windows message queue\n");
|
||||
}
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
if (!(FD_ISSET(iConnectionNumber, &fdsRead)) &&
|
||||
!(FD_ISSET(fdMessageQueue, &fdsRead))) {
|
||||
winDebug("winClipboardProc - Spurious wake, select() returned %d\n", iReturn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* broke out of while loop on a shutdown message */
|
||||
fShutdown = TRUE;
|
||||
|
||||
winClipboardProc_Done:
|
||||
/* Close our Windows window */
|
||||
if (g_hwndClipboard) {
|
||||
DestroyWindow(g_hwndClipboard);
|
||||
}
|
||||
|
||||
/* Close our X window */
|
||||
if (!xcb_connection_has_error(conn) && iWindow) {
|
||||
cookie = xcb_destroy_window_checked(conn, iWindow);
|
||||
if ((error = xcb_request_check(conn, cookie)))
|
||||
ErrorF("winClipboardProc - XDestroyWindow failed.\n");
|
||||
else
|
||||
ErrorF("winClipboardProc - XDestroyWindow succeeded.\n");
|
||||
free(error);
|
||||
}
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
/* Close our Win32 message handle */
|
||||
if (fdMessageQueue)
|
||||
close(fdMessageQueue);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* xcb_disconnect() does not sync, so is safe to call even when we are built
|
||||
* into the server. Unlike XCloseDisplay() there will be no deadlock if the
|
||||
* server is in the process of exiting and waiting for this thread to exit.
|
||||
*/
|
||||
if (!xcb_connection_has_error(conn)) {
|
||||
/* Close our X display */
|
||||
xcb_disconnect(conn);
|
||||
}
|
||||
|
||||
/* global clipboard variable reset */
|
||||
g_hwndClipboard = NULL;
|
||||
|
||||
return fShutdown;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the Windows window that we use to receive Windows messages
|
||||
*/
|
||||
|
||||
static HWND
|
||||
winClipboardCreateMessagingWindow(xcb_connection_t *conn, xcb_window_t iWindow, ClipboardAtoms *atoms)
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
ClipboardWindowCreationParams cwcp;
|
||||
HWND hwnd;
|
||||
|
||||
/* Setup our window class */
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = winClipboardWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandle(NULL);
|
||||
wc.hIcon = 0;
|
||||
wc.hCursor = 0;
|
||||
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = WIN_CLIPBOARD_WINDOW_CLASS;
|
||||
wc.hIconSm = 0;
|
||||
RegisterClassEx(&wc);
|
||||
|
||||
/* Information to be passed to WM_CREATE */
|
||||
cwcp.pClipboardDisplay = conn;
|
||||
cwcp.iClipboardWindow = iWindow;
|
||||
cwcp.atoms = atoms;
|
||||
|
||||
/* Create the window */
|
||||
hwnd = CreateWindowExA(0, /* Extended styles */
|
||||
WIN_CLIPBOARD_WINDOW_CLASS, /* Class name */
|
||||
WIN_CLIPBOARD_WINDOW_TITLE, /* Window name */
|
||||
WS_OVERLAPPED, /* Not visible anyway */
|
||||
CW_USEDEFAULT, /* Horizontal position */
|
||||
CW_USEDEFAULT, /* Vertical position */
|
||||
CW_USEDEFAULT, /* Right edge */
|
||||
CW_USEDEFAULT, /* Bottom edge */
|
||||
(HWND) NULL, /* No parent or owner window */
|
||||
(HMENU) NULL, /* No menu */
|
||||
GetModuleHandle(NULL), /* Instance handle */
|
||||
&cwcp); /* Creation data */
|
||||
assert(hwnd != NULL);
|
||||
|
||||
/* I'm not sure, but we may need to call this to start message processing */
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
|
||||
/* Similarly, we may need a call to this even though we don't paint */
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
void
|
||||
winClipboardWindowDestroy(void)
|
||||
{
|
||||
if (g_hwndClipboard) {
|
||||
SendMessage(g_hwndClipboard, WM_WM_QUIT, 0, 0);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// Copyright © Jon TURNEY 2013
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice (including the next
|
||||
// paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
//
|
||||
// File: winclipboard.h
|
||||
// Purpose: public interface to winclipboard library
|
||||
//
|
||||
|
||||
#ifndef WINCLIPBOARD_H
|
||||
#define WINCLIPBOARD_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <X11/Xmd.h> // for BOOL type
|
||||
|
||||
BOOL winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info);
|
||||
|
||||
void winFixClipboardChain(void);
|
||||
|
||||
void winClipboardWindowDestroy(void);
|
||||
|
||||
extern BOOL fPrimarySelection;
|
||||
|
||||
#endif
|
|
@ -1,462 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 copyright holder(s)
|
||||
*and author(s) 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 copyright holder(s) and author(s).
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#define WINVER 0x0600
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <xcb/xproto.h>
|
||||
#include <xcb/xcb_aux.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "winclipboard.h"
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
||||
#define WIN_POLL_TIMEOUT 1
|
||||
|
||||
/*
|
||||
* Process X events up to specified timeout
|
||||
*/
|
||||
|
||||
static int
|
||||
winProcessXEventsTimeout(HWND hwnd, xcb_window_t iWindow, xcb_connection_t *conn,
|
||||
ClipboardConversionData *data, ClipboardAtoms *atoms, int iTimeoutSec)
|
||||
{
|
||||
int iConnNumber;
|
||||
struct timeval tv;
|
||||
int iReturn;
|
||||
|
||||
winDebug("winProcessXEventsTimeout () - pumping X events, timeout %d seconds\n",
|
||||
iTimeoutSec);
|
||||
|
||||
/* Get our connection number */
|
||||
iConnNumber = xcb_get_file_descriptor(conn);
|
||||
|
||||
/* Loop for X events */
|
||||
while (1) {
|
||||
fd_set fdsRead;
|
||||
long remainingTime;
|
||||
|
||||
/* Process X events */
|
||||
iReturn = winClipboardFlushXEvents(hwnd, iWindow, conn, data, atoms);
|
||||
|
||||
winDebug("winProcessXEventsTimeout () - winClipboardFlushXEvents returned %d\n", iReturn);
|
||||
|
||||
if ((WIN_XEVENTS_NOTIFY_DATA == iReturn) || (WIN_XEVENTS_NOTIFY_TARGETS == iReturn) || (WIN_XEVENTS_FAILED == iReturn)) {
|
||||
/* Bail out */
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
/* We need to ensure that all pending requests are sent */
|
||||
xcb_flush(conn);
|
||||
|
||||
/* Setup the file descriptor set */
|
||||
FD_ZERO(&fdsRead);
|
||||
FD_SET(iConnNumber, &fdsRead);
|
||||
|
||||
/* Adjust timeout */
|
||||
remainingTime = iTimeoutSec * 1000;
|
||||
tv.tv_sec = remainingTime / 1000;
|
||||
tv.tv_usec = (remainingTime % 1000) * 1000;
|
||||
|
||||
/* Break out if no time left */
|
||||
if (remainingTime <= 0)
|
||||
return WIN_XEVENTS_SUCCESS;
|
||||
|
||||
/* Wait for an X event */
|
||||
iReturn = select(iConnNumber + 1, /* Highest fds number */
|
||||
&fdsRead, /* Read mask */
|
||||
NULL, /* No write mask */
|
||||
NULL, /* No exception mask */
|
||||
&tv); /* Timeout */
|
||||
if (iReturn < 0) {
|
||||
ErrorF("winProcessXEventsTimeout - Call to select () failed: %d. "
|
||||
"Bailing.\n", iReturn);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!FD_ISSET(iConnNumber, &fdsRead)) {
|
||||
winDebug("winProcessXEventsTimeout - Spurious wake, select() returned %d\n", iReturn);
|
||||
}
|
||||
}
|
||||
|
||||
return WIN_XEVENTS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a given Windows message
|
||||
*/
|
||||
|
||||
LRESULT CALLBACK
|
||||
winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static xcb_connection_t *conn;
|
||||
static xcb_window_t iWindow;
|
||||
static ClipboardAtoms *atoms;
|
||||
static BOOL fRunning;
|
||||
|
||||
/* Branch on message type */
|
||||
switch (message) {
|
||||
case WM_DESTROY:
|
||||
{
|
||||
winDebug("winClipboardWindowProc - WM_DESTROY\n");
|
||||
|
||||
/* Remove clipboard listener */
|
||||
RemoveClipboardFormatListener(hwnd);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_WM_QUIT:
|
||||
{
|
||||
winDebug("winClipboardWindowProc - WM_WM_QUIT\n");
|
||||
fRunning = FALSE;
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
ClipboardWindowCreationParams *cwcp = (ClipboardWindowCreationParams *)((CREATESTRUCT *)lParam)->lpCreateParams;
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_CREATE\n");
|
||||
|
||||
conn = cwcp->pClipboardDisplay;
|
||||
iWindow = cwcp->iClipboardWindow;
|
||||
atoms = cwcp->atoms;
|
||||
fRunning = TRUE;
|
||||
|
||||
AddClipboardFormatListener(hwnd);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CLIPBOARDUPDATE:
|
||||
{
|
||||
xcb_generic_error_t *error;
|
||||
xcb_void_cookie_t cookie_set;
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Enter\n");
|
||||
|
||||
/*
|
||||
* NOTE: We cannot bail out when NULL == GetClipboardOwner ()
|
||||
* because some applications deal with the clipboard in a manner
|
||||
* that causes the clipboard owner to be NULL when they are in
|
||||
* fact taking ownership. One example of this is the Win32
|
||||
* native compile of emacs.
|
||||
*/
|
||||
|
||||
/* Bail when we still own the clipboard */
|
||||
if (hwnd == GetClipboardOwner()) {
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"We own the clipboard, returning.\n");
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Exit\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Bail when shutting down */
|
||||
if (!fRunning)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Do not take ownership of the X11 selections when something
|
||||
* other than CF_TEXT or CF_UNICODETEXT has been copied
|
||||
* into the Win32 clipboard.
|
||||
*/
|
||||
if (!IsClipboardFormatAvailable(CF_TEXT)
|
||||
&& !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
|
||||
|
||||
xcb_get_selection_owner_cookie_t cookie_get;
|
||||
xcb_get_selection_owner_reply_t *reply;
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"Clipboard does not contain CF_TEXT nor "
|
||||
"CF_UNICODETEXT.\n");
|
||||
|
||||
/*
|
||||
* We need to make sure that the X Server has processed
|
||||
* previous XSetSelectionOwner messages.
|
||||
*/
|
||||
xcb_aux_sync(conn);
|
||||
|
||||
winDebug("winClipboardWindowProc - XSync done.\n");
|
||||
|
||||
/* Release PRIMARY selection if owned */
|
||||
cookie_get = xcb_get_selection_owner(conn, XCB_ATOM_PRIMARY);
|
||||
reply = xcb_get_selection_owner_reply(conn, cookie_get, NULL);
|
||||
if (reply) {
|
||||
if (reply->owner == iWindow) {
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"PRIMARY selection is owned by us, releasing.\n");
|
||||
xcb_set_selection_owner(conn, XCB_NONE, XCB_ATOM_PRIMARY, XCB_CURRENT_TIME);
|
||||
}
|
||||
free(reply);
|
||||
}
|
||||
|
||||
/* Release CLIPBOARD selection if owned */
|
||||
cookie_get = xcb_get_selection_owner(conn, atoms->atomClipboard);
|
||||
reply = xcb_get_selection_owner_reply(conn, cookie_get, NULL);
|
||||
if (reply) {
|
||||
if (reply->owner == iWindow) {
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"CLIPBOARD selection is owned by us, releasing\n");
|
||||
xcb_set_selection_owner(conn, XCB_NONE, atoms->atomClipboard, XCB_CURRENT_TIME);
|
||||
}
|
||||
free(reply);
|
||||
}
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Exit\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reassert ownership of PRIMARY */
|
||||
cookie_set = xcb_set_selection_owner_checked(conn, iWindow, XCB_ATOM_PRIMARY, XCB_CURRENT_TIME);
|
||||
error = xcb_request_check(conn, cookie_set);
|
||||
if (error) {
|
||||
ErrorF("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"Could not reassert ownership of PRIMARY\n");
|
||||
free(error);
|
||||
} else {
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"Reasserted ownership of PRIMARY\n");
|
||||
}
|
||||
|
||||
/* Reassert ownership of the CLIPBOARD */
|
||||
cookie_set = xcb_set_selection_owner_checked(conn, iWindow, atoms->atomClipboard, XCB_CURRENT_TIME);
|
||||
error = xcb_request_check(conn, cookie_set);
|
||||
if (error) {
|
||||
ErrorF("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"Could not reassert ownership of CLIPBOARD\n");
|
||||
free(error);
|
||||
}
|
||||
else {
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - "
|
||||
"Reasserted ownership of CLIPBOARD\n");
|
||||
}
|
||||
|
||||
/* Flush the pending SetSelectionOwner event now */
|
||||
xcb_flush(conn);
|
||||
}
|
||||
winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Exit\n");
|
||||
return 0;
|
||||
|
||||
case WM_DESTROYCLIPBOARD:
|
||||
/*
|
||||
* NOTE: Intentionally do nothing.
|
||||
* Changes in the Win32 clipboard are handled by WM_CLIPBOARDUPDATE
|
||||
* above. We only process this message to conform to the specs
|
||||
* for delayed clipboard rendering in Win32. You might think
|
||||
* that we need to release ownership of the X11 selections, but
|
||||
* we do not, because a WM_CLIPBOARDUPDATE message will closely
|
||||
* follow this message and reassert ownership of the X11
|
||||
* selections, handling the issue for us.
|
||||
*/
|
||||
winDebug("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
|
||||
return 0;
|
||||
|
||||
case WM_RENDERALLFORMATS:
|
||||
winDebug("winClipboardWindowProc - WM_RENDERALLFORMATS - Hello.\n");
|
||||
|
||||
/*
|
||||
WM_RENDERALLFORMATS is sent as we are shutting down, to render the
|
||||
clipboard so its contents remains available to other applications.
|
||||
|
||||
Unfortunately, this can't work without major changes. The server is
|
||||
already waiting for us to stop, so we can't ask for the rendering of
|
||||
clipboard text now.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
|
||||
case WM_RENDERFORMAT:
|
||||
{
|
||||
int iReturn;
|
||||
BOOL pasted = FALSE;
|
||||
xcb_atom_t selection;
|
||||
ClipboardConversionData data;
|
||||
int best_target = 0;
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_RENDERFORMAT %d - Hello.\n",
|
||||
(int)wParam);
|
||||
|
||||
selection = winClipboardGetLastOwnedSelectionAtom(atoms);
|
||||
if (selection == XCB_NONE) {
|
||||
ErrorF("winClipboardWindowProc - no monitored selection is owned\n");
|
||||
goto fake_paste;
|
||||
}
|
||||
|
||||
winDebug("winClipboardWindowProc - requesting targets for selection from owner\n");
|
||||
|
||||
/* Request the selection's supported conversion targets */
|
||||
xcb_convert_selection(conn, iWindow, selection, atoms->atomTargets,
|
||||
atoms->atomLocalProperty, XCB_CURRENT_TIME);
|
||||
|
||||
/* Process X events */
|
||||
data.incr = NULL;
|
||||
data.incrsize = 0;
|
||||
|
||||
iReturn = winProcessXEventsTimeout(hwnd,
|
||||
iWindow,
|
||||
conn,
|
||||
&data,
|
||||
atoms,
|
||||
WIN_POLL_TIMEOUT);
|
||||
|
||||
if (WIN_XEVENTS_NOTIFY_TARGETS != iReturn) {
|
||||
ErrorF
|
||||
("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY_TARGETS\n");
|
||||
goto fake_paste;
|
||||
}
|
||||
|
||||
/* Choose the most preferred target */
|
||||
{
|
||||
struct target_priority
|
||||
{
|
||||
xcb_atom_t target;
|
||||
unsigned int priority;
|
||||
};
|
||||
|
||||
struct target_priority target_priority_table[] =
|
||||
{
|
||||
{ atoms->atomUTF8String, 0 },
|
||||
// { atoms->atomCompoundText, 1 }, not implemented (yet?)
|
||||
{ XCB_ATOM_STRING, 2 },
|
||||
};
|
||||
|
||||
int best_priority = INT_MAX;
|
||||
|
||||
int i,j;
|
||||
for (i = 0 ; data.targetList[i] != 0; i++)
|
||||
{
|
||||
for (j = 0; j < ARRAY_SIZE(target_priority_table); j ++)
|
||||
{
|
||||
if ((data.targetList[i] == target_priority_table[j].target) &&
|
||||
(target_priority_table[j].priority < best_priority))
|
||||
{
|
||||
best_target = target_priority_table[j].target;
|
||||
best_priority = target_priority_table[j].priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(data.targetList);
|
||||
data.targetList = 0;
|
||||
|
||||
winDebug("winClipboardWindowProc - best target is %d\n", best_target);
|
||||
|
||||
/* No useful targets found */
|
||||
if (best_target == 0)
|
||||
goto fake_paste;
|
||||
|
||||
winDebug("winClipboardWindowProc - requesting selection from owner\n");
|
||||
|
||||
/* Request the selection contents */
|
||||
xcb_convert_selection(conn, iWindow, selection, best_target,
|
||||
atoms->atomLocalProperty, XCB_CURRENT_TIME);
|
||||
|
||||
/* Process X events */
|
||||
iReturn = winProcessXEventsTimeout(hwnd,
|
||||
iWindow,
|
||||
conn,
|
||||
&data,
|
||||
atoms,
|
||||
WIN_POLL_TIMEOUT);
|
||||
|
||||
/*
|
||||
* winProcessXEventsTimeout had better have seen a notify event,
|
||||
* or else we are dealing with a buggy or old X11 app.
|
||||
*/
|
||||
if (WIN_XEVENTS_NOTIFY_DATA != iReturn) {
|
||||
ErrorF
|
||||
("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY_DATA\n");
|
||||
}
|
||||
else {
|
||||
pasted = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we couldn't get the data from the X clipboard, we
|
||||
* have to paste some fake data to the Win32 clipboard to
|
||||
* satisfy the requirement that we write something to it.
|
||||
*/
|
||||
fake_paste:
|
||||
if (!pasted)
|
||||
{
|
||||
/* Paste no data, to satisfy required call to SetClipboardData */
|
||||
SetClipboardData(CF_UNICODETEXT, NULL);
|
||||
SetClipboardData(CF_TEXT, NULL);
|
||||
}
|
||||
|
||||
winDebug("winClipboardWindowProc - WM_RENDERFORMAT - Returning.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Let Windows perform default processing for unhandled messages */
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process any pending Windows messages
|
||||
*/
|
||||
|
||||
BOOL
|
||||
winClipboardFlushWindowsMessageQueue(HWND hwnd)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
/* Flush the messaging window queue */
|
||||
/* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
|
||||
* as this will filter out many non-window-specific messages that
|
||||
* are sent to our thread, such as WM_QUIT.
|
||||
*/
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
/* Dispatch the message if not WM_QUIT */
|
||||
if (msg.message == WM_QUIT)
|
||||
return FALSE;
|
||||
else
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,829 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 copyright holder(s)
|
||||
*and author(s) 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 copyright holder(s) and author(s).
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xfixes.h>
|
||||
|
||||
#include "winclipboard.h"
|
||||
#include "internal.h"
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
||||
#define CLIP_NUM_SELECTIONS 2
|
||||
#define CLIP_OWN_NONE -1
|
||||
#define CLIP_OWN_PRIMARY 0
|
||||
#define CLIP_OWN_CLIPBOARD 1
|
||||
|
||||
#define CP_ISO_8559_1 28591
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
|
||||
extern int xfixes_event_base;
|
||||
BOOL fPrimarySelection = TRUE;
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
|
||||
static xcb_window_t s_iOwners[CLIP_NUM_SELECTIONS] = { XCB_NONE, XCB_NONE };
|
||||
static const char *szSelectionNames[CLIP_NUM_SELECTIONS] =
|
||||
{ "PRIMARY", "CLIPBOARD" };
|
||||
|
||||
static unsigned int lastOwnedSelectionIndex = CLIP_OWN_NONE;
|
||||
|
||||
static void
|
||||
MonitorSelection(xcb_xfixes_selection_notify_event_t * e, unsigned int i)
|
||||
{
|
||||
/* Look for owned -> not owned transition */
|
||||
if ((XCB_NONE == e->owner) && (XCB_NONE != s_iOwners[i])) {
|
||||
unsigned int other_index;
|
||||
|
||||
winDebug("MonitorSelection - %s - Going from owned to not owned.\n",
|
||||
szSelectionNames[i]);
|
||||
|
||||
/* If this selection is not owned, the other monitored selection must be the most
|
||||
recently owned, if it is owned at all */
|
||||
if (i == CLIP_OWN_PRIMARY)
|
||||
other_index = CLIP_OWN_CLIPBOARD;
|
||||
if (i == CLIP_OWN_CLIPBOARD)
|
||||
other_index = CLIP_OWN_PRIMARY;
|
||||
if (XCB_NONE != s_iOwners[other_index])
|
||||
lastOwnedSelectionIndex = other_index;
|
||||
else
|
||||
lastOwnedSelectionIndex = CLIP_OWN_NONE;
|
||||
}
|
||||
|
||||
/* Save last owned selection */
|
||||
if (XCB_NONE != e->owner) {
|
||||
lastOwnedSelectionIndex = i;
|
||||
}
|
||||
|
||||
/* Save new selection owner or None */
|
||||
s_iOwners[i] = e->owner;
|
||||
winDebug("MonitorSelection - %s - Now owned by XID %x\n",
|
||||
szSelectionNames[i], e->owner);
|
||||
}
|
||||
|
||||
xcb_atom_t
|
||||
winClipboardGetLastOwnedSelectionAtom(ClipboardAtoms *atoms)
|
||||
{
|
||||
if (lastOwnedSelectionIndex == CLIP_OWN_NONE)
|
||||
return XCB_NONE;
|
||||
|
||||
if (lastOwnedSelectionIndex == CLIP_OWN_PRIMARY)
|
||||
return XCB_ATOM_PRIMARY;
|
||||
|
||||
if (lastOwnedSelectionIndex == CLIP_OWN_CLIPBOARD)
|
||||
return atoms->atomClipboard;
|
||||
|
||||
return XCB_NONE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
winClipboardInitMonitoredSelections(void)
|
||||
{
|
||||
/* Initialize static variables */
|
||||
int i;
|
||||
for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
|
||||
s_iOwners[i] = XCB_NONE;
|
||||
|
||||
lastOwnedSelectionIndex = CLIP_OWN_NONE;
|
||||
}
|
||||
|
||||
static char *get_atom_name(xcb_connection_t *conn, xcb_atom_t atom)
|
||||
{
|
||||
char *ret;
|
||||
xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(conn, atom);
|
||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(conn, cookie, NULL);
|
||||
if (!reply)
|
||||
return NULL;
|
||||
ret = malloc(xcb_get_atom_name_name_length(reply) + 1);
|
||||
if (ret) {
|
||||
memcpy(ret, xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
||||
ret[xcb_get_atom_name_name_length(reply)] = '\0';
|
||||
}
|
||||
free(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
winClipboardSelectionNotifyTargets(HWND hwnd, xcb_window_t iWindow, xcb_connection_t *conn, ClipboardConversionData *data, ClipboardAtoms *atoms)
|
||||
{
|
||||
/* Retrieve the selection data and delete the property */
|
||||
xcb_get_property_cookie_t cookie = xcb_get_property(conn,
|
||||
TRUE,
|
||||
iWindow,
|
||||
atoms->atomLocalProperty,
|
||||
XCB_GET_PROPERTY_TYPE_ANY,
|
||||
0,
|
||||
INT_MAX);
|
||||
xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL);
|
||||
if (!reply) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionNotify - "
|
||||
"XGetWindowProperty () failed\n");
|
||||
} else {
|
||||
xcb_atom_t *prop = xcb_get_property_value(reply);
|
||||
int nitems = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t);
|
||||
int i;
|
||||
data->targetList = malloc((nitems+1)*sizeof(xcb_atom_t));
|
||||
|
||||
for (i = 0; i < nitems; i++)
|
||||
{
|
||||
xcb_atom_t atom = prop[i];
|
||||
char *pszAtomName = get_atom_name(conn, atom);
|
||||
data->targetList[i] = atom;
|
||||
winDebug("winClipboardFlushXEvents - SelectionNotify - target[%d] %d = %s\n", i, atom, pszAtomName);
|
||||
free(pszAtomName);
|
||||
}
|
||||
|
||||
data->targetList[nitems] = 0;
|
||||
|
||||
free(reply);
|
||||
}
|
||||
|
||||
return WIN_XEVENTS_NOTIFY_TARGETS;
|
||||
}
|
||||
|
||||
static int
|
||||
winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_t *conn, ClipboardConversionData *data, ClipboardAtoms *atoms)
|
||||
{
|
||||
xcb_atom_t encoding;
|
||||
int format;
|
||||
unsigned long int nitems;
|
||||
unsigned long int after;
|
||||
unsigned char *value;
|
||||
|
||||
unsigned char *xtpText_value;
|
||||
xcb_atom_t xtpText_encoding;
|
||||
int xtpText_nitems;
|
||||
|
||||
BOOL fSetClipboardData = TRUE;
|
||||
char *pszReturnData = NULL;
|
||||
UINT codepage;
|
||||
wchar_t *pwszUnicodeStr = NULL;
|
||||
HGLOBAL hGlobal = NULL;
|
||||
char *pszGlobalData = NULL;
|
||||
|
||||
/* Retrieve the selection data and delete the property */
|
||||
xcb_get_property_cookie_t cookie = xcb_get_property(conn,
|
||||
TRUE,
|
||||
iWindow,
|
||||
atoms->atomLocalProperty,
|
||||
XCB_GET_PROPERTY_TYPE_ANY,
|
||||
0,
|
||||
INT_MAX);
|
||||
xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL);
|
||||
if (!reply) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionNotify - "
|
||||
"XGetWindowProperty () failed\n");
|
||||
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
||||
} else {
|
||||
nitems = xcb_get_property_value_length(reply);
|
||||
value = xcb_get_property_value(reply);
|
||||
after = reply->bytes_after;
|
||||
encoding = reply->type;
|
||||
format = reply->format;
|
||||
// We assume format == 8 (i.e. data is a sequence of bytes). It's not
|
||||
// clear how anything else should be handled.
|
||||
if (format != 8)
|
||||
ErrorF("SelectionNotify: format is %d, proceeding as if it was 8\n", format);
|
||||
}
|
||||
|
||||
{
|
||||
char *pszAtomName;
|
||||
winDebug("SelectionNotify - returned data %lu left %lu\n", nitems, after);
|
||||
pszAtomName = get_atom_name(conn, encoding);
|
||||
winDebug("Notify atom name %s\n", pszAtomName);
|
||||
free(pszAtomName);
|
||||
}
|
||||
|
||||
/* INCR reply indicates the start of a incremental transfer */
|
||||
if (encoding == atoms->atomIncr) {
|
||||
winDebug("winClipboardSelectionNotifyData: starting INCR, anticipated size %d\n", *(int *)value);
|
||||
data->incrsize = 0;
|
||||
data->incr = malloc(*(int *)value);
|
||||
// XXX: if malloc failed, we have an error
|
||||
return WIN_XEVENTS_SUCCESS;
|
||||
}
|
||||
else if (data->incr) {
|
||||
/* If an INCR transfer is in progress ... */
|
||||
if (nitems == 0) {
|
||||
winDebug("winClipboardSelectionNotifyData: ending INCR, actual size %ld\n", data->incrsize);
|
||||
/* a zero-length property indicates the end of the data */
|
||||
xtpText_value = data->incr;
|
||||
xtpText_encoding = encoding;
|
||||
// XXX: The type of the converted selection is the type of the first
|
||||
// partial property. The remaining partial properties must have the
|
||||
// same type.
|
||||
xtpText_nitems = data->incrsize;
|
||||
}
|
||||
else {
|
||||
/* Otherwise, continue appending the INCR data */
|
||||
winDebug("winClipboardSelectionNotifyData: INCR, %ld bytes\n", nitems);
|
||||
data->incr = realloc(data->incr, data->incrsize + nitems);
|
||||
memcpy(data->incr + data->incrsize, value, nitems);
|
||||
data->incrsize = data->incrsize + nitems;
|
||||
return WIN_XEVENTS_SUCCESS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Otherwise, the data is just contained in the property */
|
||||
winDebug("winClipboardSelectionNotifyData: non-INCR, %ld bytes\n", nitems);
|
||||
xtpText_value = value;
|
||||
xtpText_encoding = encoding;
|
||||
xtpText_nitems = nitems;
|
||||
}
|
||||
|
||||
if (xtpText_encoding == atoms->atomUTF8String) {
|
||||
pszReturnData = malloc(xtpText_nitems + 1);
|
||||
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
||||
pszReturnData[xtpText_nitems] = 0;
|
||||
codepage = CP_UTF8; // code page identifier for utf8
|
||||
} else if (xtpText_encoding == XCB_ATOM_STRING) {
|
||||
// STRING encoding is Latin1 (ISO8859-1) plus tab and newline
|
||||
pszReturnData = malloc(xtpText_nitems + 1);
|
||||
memcpy(pszReturnData, xtpText_value, xtpText_nitems);
|
||||
pszReturnData[xtpText_nitems] = 0;
|
||||
codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1
|
||||
} else if (xtpText_encoding == atoms->atomCompoundText) {
|
||||
// COMPOUND_TEXT is complex, based on ISO 2022
|
||||
ErrorF("SelectionNotify: data in COMPOUND_TEXT encoding which is not implemented, discarding\n");
|
||||
pszReturnData = malloc(1);
|
||||
pszReturnData[0] = '\0';
|
||||
} else { // shouldn't happen as we accept no other encodings
|
||||
pszReturnData = malloc(1);
|
||||
pszReturnData[0] = '\0';
|
||||
}
|
||||
|
||||
/* Free the data returned from xcb_get_property */
|
||||
free(reply);
|
||||
|
||||
/* Free any INCR data */
|
||||
if (data->incr) {
|
||||
free(data->incr);
|
||||
data->incr = NULL;
|
||||
data->incrsize = 0;
|
||||
}
|
||||
|
||||
/* Convert the X clipboard string to DOS format */
|
||||
winClipboardUNIXtoDOS(&pszReturnData, strlen(pszReturnData));
|
||||
|
||||
/* Find out how much space needed when converted to UTF-16 */
|
||||
int iUnicodeLen = MultiByteToWideChar(codepage, 0,
|
||||
pszReturnData, -1, NULL, 0);
|
||||
|
||||
/* NOTE: iUnicodeLen includes space for null terminator */
|
||||
pwszUnicodeStr = malloc(sizeof(wchar_t) * iUnicodeLen);
|
||||
if (!pwszUnicodeStr) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionNotify "
|
||||
"malloc failed for pwszUnicodeStr, aborting.\n");
|
||||
|
||||
/* Abort */
|
||||
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
||||
}
|
||||
|
||||
/* Do the actual conversion */
|
||||
MultiByteToWideChar(codepage, 0,
|
||||
pszReturnData, -1, pwszUnicodeStr, iUnicodeLen);
|
||||
|
||||
/* Allocate global memory for the X clipboard data */
|
||||
hGlobal = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * iUnicodeLen);
|
||||
|
||||
free(pszReturnData);
|
||||
|
||||
/* Check that global memory was allocated */
|
||||
if (!hGlobal) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionNotify "
|
||||
"GlobalAlloc failed, aborting: %08x\n", (unsigned int)GetLastError());
|
||||
|
||||
/* Abort */
|
||||
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
||||
}
|
||||
|
||||
/* Obtain a pointer to the global memory */
|
||||
pszGlobalData = GlobalLock(hGlobal);
|
||||
if (pszGlobalData == NULL) {
|
||||
ErrorF("winClipboardFlushXEvents - Could not lock global "
|
||||
"memory for clipboard transfer\n");
|
||||
|
||||
/* Abort */
|
||||
goto winClipboardFlushXEvents_SelectionNotify_Done;
|
||||
}
|
||||
|
||||
/* Copy the returned string into the global memory */
|
||||
wcscpy((wchar_t *)pszGlobalData, pwszUnicodeStr);
|
||||
free(pwszUnicodeStr);
|
||||
pwszUnicodeStr = NULL;
|
||||
|
||||
/* Release the pointer to the global memory */
|
||||
GlobalUnlock(hGlobal);
|
||||
pszGlobalData = NULL;
|
||||
|
||||
/* Push the selection data to the Windows clipboard */
|
||||
SetClipboardData(CF_UNICODETEXT, hGlobal);
|
||||
|
||||
/* Flag that SetClipboardData has been called */
|
||||
fSetClipboardData = FALSE;
|
||||
|
||||
/*
|
||||
* NOTE: Do not try to free pszGlobalData, it is owned by
|
||||
* Windows after the call to SetClipboardData ().
|
||||
*/
|
||||
|
||||
winClipboardFlushXEvents_SelectionNotify_Done:
|
||||
/* Free allocated resources */
|
||||
free(pwszUnicodeStr);
|
||||
if (hGlobal && pszGlobalData)
|
||||
GlobalUnlock(hGlobal);
|
||||
if (fSetClipboardData) {
|
||||
SetClipboardData(CF_UNICODETEXT, NULL);
|
||||
SetClipboardData(CF_TEXT, NULL);
|
||||
}
|
||||
return WIN_XEVENTS_NOTIFY_DATA;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process any pending X events
|
||||
*/
|
||||
|
||||
int
|
||||
winClipboardFlushXEvents(HWND hwnd,
|
||||
xcb_window_t iWindow, xcb_connection_t *conn,
|
||||
ClipboardConversionData *data, ClipboardAtoms *atoms)
|
||||
{
|
||||
xcb_atom_t atomClipboard = atoms->atomClipboard;
|
||||
xcb_atom_t atomUTF8String = atoms->atomUTF8String;
|
||||
xcb_atom_t atomCompoundText = atoms->atomCompoundText;
|
||||
xcb_atom_t atomTargets = atoms->atomTargets;
|
||||
|
||||
/* Process all pending events */
|
||||
xcb_generic_event_t *event;
|
||||
while ((event = xcb_poll_for_event(conn))) {
|
||||
const char *pszGlobalData = NULL;
|
||||
HGLOBAL hGlobal = NULL;
|
||||
char *pszConvertData = NULL;
|
||||
BOOL fAbort = FALSE;
|
||||
BOOL fCloseClipboard = FALSE;
|
||||
|
||||
/* Branch on the event type */
|
||||
switch (event->response_type & ~0x80) {
|
||||
case XCB_SELECTION_REQUEST:
|
||||
{
|
||||
char *xtpText_value = NULL;
|
||||
int xtpText_nitems;
|
||||
UINT codepage;
|
||||
|
||||
xcb_selection_request_event_t *selection_request = (xcb_selection_request_event_t *)event;
|
||||
{
|
||||
char *pszAtomName = NULL;
|
||||
|
||||
winDebug("SelectionRequest - target %d\n", selection_request->target);
|
||||
|
||||
pszAtomName = get_atom_name(conn, selection_request->target);
|
||||
winDebug("SelectionRequest - Target atom name %s\n", pszAtomName);
|
||||
free(pszAtomName);
|
||||
}
|
||||
|
||||
/* Abort if invalid target type */
|
||||
if (selection_request->target != XCB_ATOM_STRING
|
||||
&& selection_request->target != atomUTF8String
|
||||
&& selection_request->target != atomCompoundText
|
||||
&& selection_request->target != atomTargets) {
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
|
||||
/* Handle targets type of request */
|
||||
if (selection_request->target == atomTargets) {
|
||||
xcb_atom_t atomTargetArr[] =
|
||||
{
|
||||
atomTargets,
|
||||
atomUTF8String,
|
||||
XCB_ATOM_STRING,
|
||||
// atomCompoundText, not implemented (yet?)
|
||||
};
|
||||
|
||||
/* Try to change the property */
|
||||
xcb_void_cookie_t cookie = xcb_change_property_checked(conn,
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
selection_request->requestor,
|
||||
selection_request->property,
|
||||
XCB_ATOM_ATOM,
|
||||
32,
|
||||
ARRAY_SIZE(atomTargetArr),
|
||||
(unsigned char *) atomTargetArr);
|
||||
xcb_generic_error_t *error;
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"xcb_change_property failed");
|
||||
free(error);
|
||||
}
|
||||
|
||||
/* Setup selection notify xevent */
|
||||
xcb_selection_notify_event_t eventSelection;
|
||||
eventSelection.response_type = XCB_SELECTION_NOTIFY;
|
||||
eventSelection.requestor = selection_request->requestor;
|
||||
eventSelection.selection = selection_request->selection;
|
||||
eventSelection.target = selection_request->target;
|
||||
eventSelection.property = selection_request->property;
|
||||
eventSelection.time = selection_request->time;
|
||||
|
||||
/*
|
||||
* Notify the requesting window that
|
||||
* the operation has completed
|
||||
*/
|
||||
cookie = xcb_send_event_checked(conn, FALSE,
|
||||
eventSelection.requestor,
|
||||
0, (char *) &eventSelection);
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"xcb_send_event() failed\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Close clipboard if we have it open already */
|
||||
if (GetOpenClipboardWindow() == hwnd) {
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
/* Access the clipboard */
|
||||
if (!OpenClipboard(hwnd)) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"OpenClipboard () failed: %08x\n", (unsigned int)GetLastError());
|
||||
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
|
||||
/* Indicate that clipboard was opened */
|
||||
fCloseClipboard = TRUE;
|
||||
|
||||
/* Check that clipboard format is available */
|
||||
if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) {
|
||||
static int count; /* Hack to stop acroread spamming the log */
|
||||
static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
|
||||
|
||||
if (hwnd != lasthwnd)
|
||||
count = 0;
|
||||
count++;
|
||||
if (count < 6)
|
||||
ErrorF("winClipboardFlushXEvents - CF_UNICODETEXT is not "
|
||||
"available from Win32 clipboard. Aborting %d.\n",
|
||||
count);
|
||||
lasthwnd = hwnd;
|
||||
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
|
||||
/* Get a pointer to the clipboard text, in desired format */
|
||||
/* Retrieve clipboard data */
|
||||
hGlobal = GetClipboardData(CF_UNICODETEXT);
|
||||
|
||||
if (!hGlobal) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"GetClipboardData () failed: %08x\n", (unsigned int)GetLastError());
|
||||
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
pszGlobalData = (char *) GlobalLock(hGlobal);
|
||||
|
||||
/* Convert to target string style */
|
||||
if (selection_request->target == XCB_ATOM_STRING) {
|
||||
codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1
|
||||
} else if (selection_request->target == atomUTF8String) {
|
||||
codepage = CP_UTF8; // code page identifier for utf8
|
||||
} else if (selection_request->target == atomCompoundText) {
|
||||
// COMPOUND_TEXT is complex, not (yet) implemented
|
||||
pszGlobalData = "COMPOUND_TEXT not implemented";
|
||||
codepage = CP_UTF8; // code page identifier for utf8
|
||||
}
|
||||
|
||||
/* Convert the UTF16 string to required encoding */
|
||||
int iConvertDataLen = WideCharToMultiByte(codepage, 0,
|
||||
(LPCWSTR) pszGlobalData, -1,
|
||||
NULL, 0, NULL, NULL);
|
||||
/* NOTE: iConvertDataLen includes space for null terminator */
|
||||
pszConvertData = malloc(iConvertDataLen);
|
||||
WideCharToMultiByte(codepage, 0,
|
||||
(LPCWSTR) pszGlobalData, -1,
|
||||
pszConvertData, iConvertDataLen, NULL, NULL);
|
||||
|
||||
/* Convert DOS string to UNIX string */
|
||||
winClipboardDOStoUNIX(pszConvertData, strlen(pszConvertData));
|
||||
|
||||
xtpText_value = strdup(pszConvertData);
|
||||
xtpText_nitems = strlen(pszConvertData);
|
||||
|
||||
/* data will fit into a single X request? (INCR not yet supported) */
|
||||
{
|
||||
uint32_t maxreqsize = xcb_get_maximum_request_length(conn);
|
||||
|
||||
/* covert to bytes and allow for allow for X_ChangeProperty request */
|
||||
maxreqsize = maxreqsize*4 - 24;
|
||||
|
||||
if (xtpText_nitems > maxreqsize) {
|
||||
ErrorF("winClipboardFlushXEvents - clipboard data size %d greater than maximum %u\n", xtpText_nitems, maxreqsize);
|
||||
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the clipboard text to the requesting window */
|
||||
xcb_void_cookie_t cookie = xcb_change_property_checked(conn,
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
selection_request->requestor,
|
||||
selection_request->property,
|
||||
selection_request->target,
|
||||
8,
|
||||
xtpText_nitems, xtpText_value);
|
||||
xcb_generic_error_t *error;
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"xcb_change_property failed\n");
|
||||
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
|
||||
/* Free the converted string */
|
||||
free(pszConvertData);
|
||||
pszConvertData = NULL;
|
||||
|
||||
/* Release the clipboard data */
|
||||
GlobalUnlock(hGlobal);
|
||||
pszGlobalData = NULL;
|
||||
fCloseClipboard = FALSE;
|
||||
CloseClipboard();
|
||||
|
||||
/* Clean up */
|
||||
free(xtpText_value);
|
||||
xtpText_value = NULL;
|
||||
|
||||
/* Setup selection notify event */
|
||||
xcb_selection_notify_event_t eventSelection;
|
||||
eventSelection.response_type = XCB_SELECTION_NOTIFY;
|
||||
eventSelection.requestor = selection_request->requestor;
|
||||
eventSelection.selection = selection_request->selection;
|
||||
eventSelection.target = selection_request->target;
|
||||
eventSelection.property = selection_request->property;
|
||||
eventSelection.time = selection_request->time;
|
||||
|
||||
/* Notify the requesting window that the operation has completed */
|
||||
cookie = xcb_send_event_checked(conn, FALSE,
|
||||
eventSelection.requestor,
|
||||
0, (char *) &eventSelection);
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"xcb_send_event() failed\n");
|
||||
|
||||
/* Abort */
|
||||
fAbort = TRUE;
|
||||
goto winClipboardFlushXEvents_SelectionRequest_Done;
|
||||
}
|
||||
|
||||
winClipboardFlushXEvents_SelectionRequest_Done:
|
||||
/* Free allocated resources */
|
||||
if (xtpText_value) {
|
||||
free(xtpText_value);
|
||||
}
|
||||
if (pszConvertData)
|
||||
free(pszConvertData);
|
||||
if (hGlobal && pszGlobalData)
|
||||
GlobalUnlock(hGlobal);
|
||||
|
||||
/*
|
||||
* Send a SelectionNotify event to the requesting
|
||||
* client when we abort.
|
||||
*/
|
||||
if (fAbort) {
|
||||
/* Setup selection notify event */
|
||||
eventSelection.response_type = XCB_SELECTION_NOTIFY;
|
||||
eventSelection.requestor = selection_request->requestor;
|
||||
eventSelection.selection = selection_request->selection;
|
||||
eventSelection.target = selection_request->target;
|
||||
eventSelection.property = XCB_NONE;
|
||||
eventSelection.time = selection_request->time;
|
||||
|
||||
/* Notify the requesting window that the operation is complete */
|
||||
cookie = xcb_send_event_checked(conn, FALSE,
|
||||
eventSelection.requestor,
|
||||
0, (char *) &eventSelection);
|
||||
if ((error = xcb_request_check(conn, cookie))) {
|
||||
/*
|
||||
* Should not be a problem if XSendEvent fails because
|
||||
* the client may simply have exited.
|
||||
*/
|
||||
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
|
||||
"xcb_send_event() failed for abort event.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Close clipboard if it was opened */
|
||||
if (fCloseClipboard) {
|
||||
fCloseClipboard = FALSE;
|
||||
CloseClipboard();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case XCB_SELECTION_NOTIFY:
|
||||
{
|
||||
xcb_selection_notify_event_t *selection_notify = (xcb_selection_notify_event_t *)event;
|
||||
winDebug("winClipboardFlushXEvents - SelectionNotify\n");
|
||||
{
|
||||
char *pszAtomName;
|
||||
pszAtomName = get_atom_name(conn, selection_notify->selection);
|
||||
winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n", pszAtomName);
|
||||
free(pszAtomName);
|
||||
}
|
||||
|
||||
/*
|
||||
SelectionNotify with property of XCB_NONE indicates either:
|
||||
|
||||
(i) Generated by the X server if no owner for the specified selection exists
|
||||
(perhaps it's disappeared on us mid-transaction), or
|
||||
(ii) Sent by the selection owner when the requested selection conversion could
|
||||
not be performed or server errors prevented the conversion data being returned
|
||||
*/
|
||||
if (selection_notify->property == XCB_NONE) {
|
||||
ErrorF("winClipboardFlushXEvents - SelectionNotify - "
|
||||
"Conversion to format %d refused.\n",
|
||||
selection_notify->target);
|
||||
return WIN_XEVENTS_FAILED;
|
||||
}
|
||||
|
||||
if (selection_notify->target == atomTargets) {
|
||||
return winClipboardSelectionNotifyTargets(hwnd, iWindow, conn, data, atoms);
|
||||
}
|
||||
|
||||
return winClipboardSelectionNotifyData(hwnd, iWindow, conn, data, atoms);
|
||||
}
|
||||
|
||||
case XCB_SELECTION_CLEAR:
|
||||
winDebug("SelectionClear - doing nothing\n");
|
||||
break;
|
||||
|
||||
case XCB_PROPERTY_NOTIFY:
|
||||
{
|
||||
xcb_property_notify_event_t *property_notify = (xcb_property_notify_event_t *)event;
|
||||
|
||||
/* If INCR is in progress, collect the data */
|
||||
if (data->incr &&
|
||||
(property_notify->atom == atoms->atomLocalProperty) &&
|
||||
(property_notify->state == XCB_PROPERTY_NEW_VALUE))
|
||||
return winClipboardSelectionNotifyData(hwnd, iWindow, conn, data, atoms);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case XCB_MAPPING_NOTIFY:
|
||||
break;
|
||||
|
||||
case 0:
|
||||
/* This is just laziness rather than making sure we used _checked everywhere */
|
||||
{
|
||||
xcb_generic_error_t *err = (xcb_generic_error_t *)event;
|
||||
ErrorF("winClipboardFlushXEvents - Error code: %i, ID: 0x%08x, "
|
||||
"Major opcode: %i, Minor opcode: %i\n",
|
||||
err->error_code, err->resource_id,
|
||||
err->major_code, err->minor_code);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((event->response_type & ~0x80) == XCB_XFIXES_SELECTION_EVENT_SET_SELECTION_OWNER + xfixes_event_base) {
|
||||
xcb_xfixes_selection_notify_event_t *e = (xcb_xfixes_selection_notify_event_t *)event;
|
||||
winDebug("winClipboardFlushXEvents - XFixesSetSelectionOwnerNotify\n");
|
||||
|
||||
/* Save selection owners for monitored selections, ignore other selections */
|
||||
if ((e->selection == XCB_ATOM_PRIMARY) && fPrimarySelection) {
|
||||
MonitorSelection(e, CLIP_OWN_PRIMARY);
|
||||
}
|
||||
else if (e->selection == atomClipboard) {
|
||||
MonitorSelection(e, CLIP_OWN_CLIPBOARD);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
/* Selection is being disowned */
|
||||
if (e->owner == XCB_NONE) {
|
||||
winDebug("winClipboardFlushXEvents - No window, returning.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
XXX: there are all kinds of wacky edge cases we might need here:
|
||||
- we own windows clipboard, but neither PRIMARY nor CLIPBOARD have an owner, so we should disown it?
|
||||
- root window is taking ownership?
|
||||
*/
|
||||
|
||||
/* If we are the owner of the most recently owned selection, don't go all recursive :) */
|
||||
if ((lastOwnedSelectionIndex != CLIP_OWN_NONE) &&
|
||||
(s_iOwners[lastOwnedSelectionIndex] == iWindow)) {
|
||||
winDebug("winClipboardFlushXEvents - Ownership changed to us, aborting.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Close clipboard if we have it open already (possible? correct??) */
|
||||
if (GetOpenClipboardWindow() == hwnd) {
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
/* Access the Windows clipboard */
|
||||
if (!OpenClipboard(hwnd)) {
|
||||
ErrorF("winClipboardFlushXEvents - OpenClipboard () failed: %08x\n",
|
||||
(int) GetLastError());
|
||||
break;
|
||||
}
|
||||
|
||||
/* Take ownership of the Windows clipboard */
|
||||
if (!EmptyClipboard()) {
|
||||
ErrorF("winClipboardFlushXEvents - EmptyClipboard () failed: %08x\n",
|
||||
(int) GetLastError());
|
||||
break;
|
||||
}
|
||||
|
||||
/* Advertise regular text and unicode */
|
||||
SetClipboardData(CF_UNICODETEXT, NULL);
|
||||
SetClipboardData(CF_TEXT, NULL);
|
||||
|
||||
/* Release the clipboard */
|
||||
if (!CloseClipboard()) {
|
||||
ErrorF("winClipboardFlushXEvents - CloseClipboard () failed: %08x\n",
|
||||
(int) GetLastError());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* XCB_XFIXES_SELECTION_EVENT_SELECTION_WINDOW_DESTROY */
|
||||
/* XCB_XFIXES_SELECTION_EVENT_SELECTION_CLIENT_CLOSE */
|
||||
else {
|
||||
ErrorF("winClipboardFlushXEvents - unexpected event type %d\n",
|
||||
event->response_type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* I/O errors etc. */
|
||||
{
|
||||
int e = xcb_connection_has_error(conn);
|
||||
if (e) {
|
||||
ErrorF("winClipboardFlushXEvents - Fatal error %d on xcb connection\n", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WIN_XEVENTS_SUCCESS;
|
||||
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 AUTHORS OR COPYRIGHT HOLDERS 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 copyright holder(s)
|
||||
*and author(s) 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 copyright holder(s) and author(s).
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "winclipboard.h"
|
||||
|
||||
/*
|
||||
* Main function
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *pszDisplay = NULL;
|
||||
|
||||
/* Parse command-line parameters */
|
||||
for (i = 1; i < argc; ++i)
|
||||
{
|
||||
/* Look for -display "display_name" or --display "display_name" */
|
||||
if (i < argc - 1
|
||||
&& (!strcmp (argv[i], "-display")
|
||||
|| !strcmp (argv[i], "--display")))
|
||||
{
|
||||
/* Grab a pointer to the display parameter */
|
||||
pszDisplay = argv[i + 1];
|
||||
|
||||
/* Skip the display argument */
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Look for -noprimary */
|
||||
if (!strcmp (argv[i], "-noprimary"))
|
||||
{
|
||||
fPrimarySelection = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Yack when we find a parameter that we don't know about */
|
||||
printf ("Unknown parameter: %s\nExiting.\n", argv[i]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
winClipboardProc(pszDisplay, NULL /* Use XAUTHORITY for auth data */);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
.TH xwinclip 1 @xorgversion@
|
||||
.SH NAME
|
||||
xwinclip - An X11 and Windows clipboard integration tool
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B xwinclip [OPTION]...
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIxwinclip\fP is a tool for copying and pasting text between the Windows and X11 clipboard systems.
|
||||
|
||||
\fIxwinclip\fP watches for updates to either clipboard and copies data between them when either one is updated.
|
||||
|
||||
\fIxwinclip\fP monitors the X PRIMARY and CLIBPOARD selections for changes in ownership, and makes
|
||||
the contents of the most recent one to change available to paste from the Windows clipboard.
|
||||
|
||||
It also monitors the contents of the Windows clipboard for changes, taking ownership of the PRIMARY and
|
||||
CLIPBOARD selections, and making the contents of the Windows clipboard available in them.
|
||||
|
||||
.B Note well:
|
||||
The \fIXWin(1)\fP X server has internal clipboard integration that is enabled by default.
|
||||
Do \fINOT\fP run \fIxwinclip\fP unless \fIXWin(1)\fP has been started with the -noclipboard option.
|
||||
|
||||
.SH OPTIONS
|
||||
\fIxwinclip\fP accepts the following optional command line switches:
|
||||
|
||||
.TP 8
|
||||
.B \-display [display]
|
||||
Specifies the X server display to connect to.
|
||||
.TP 8
|
||||
.B \-noprimary
|
||||
Do not monitor the PRIMARY selection.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
XWin(1)
|
||||
|
||||
.SH BUGS
|
||||
Only text clipboard contents are supported.
|
||||
|
||||
The INCR (Incremental transfer) clipboard protocol for clipboard contents larger than the maximum size of an X
|
||||
request (approximately 256K) is only supported for X -> Windows clipboard transfers.
|
||||
|
||||
Some X clients, notably ones written in Tcl/Tk, do not re-assert ownership of the PRIMARY selection or update
|
||||
its timestamp when its contents change, which currently prevents \fIxwinclip\fP from correctly noticing that
|
||||
the PRIMARY selection's contents have changed.
|
||||
|
||||
Windows clipboard rendering is synchronous in the WM_RENDER*FORMAT message (that is, we must have placed the
|
||||
contents onto the clipboard by the time we return from processing this message), but we must wait for the X
|
||||
client which owns the selection to convert the selection to our requested format. This is currently achieved
|
||||
using a fixed timeout. After requesting conversion of the selection, if no events are received from the X
|
||||
client which owns the selection for one second, the conversion is assumed to have failed.
|
||||
|
||||
The XWin(1) server should indicate somehow (by placing an atom on the root window?) that it is running with its
|
||||
internal clipboard integration enabled, and xwinclip should notice this and exit with an appropriate error.
|
||||
|
||||
Probably many other bugs.
|
||||
|
||||
.SH "CONFORMING TO"
|
||||
ICCCM (Inter-Client Communication Conventions Manual) 2.0
|
||||
|
||||
.SH AUTHORS
|
||||
Contributors to xwinclip include Benjamin Riefenstahl, Roland Cassard, Brian Genisio, Colin Harrison,
|
||||
Harold L Hunt II, Matsuzaki Kensuke, Jon Turney, Chris Twiner and Jeremy Wilkins.
|
|
@ -1,144 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "win.h"
|
||||
#include "winclipboard/winclipboard.h"
|
||||
#include "windisplay.h"
|
||||
#include "winauth.h"
|
||||
|
||||
#define WIN_CLIPBOARD_RETRIES 40
|
||||
#define WIN_CLIPBOARD_DELAY 1
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
|
||||
static pthread_t g_ptClipboardProc;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
static void *
|
||||
winClipboardThreadProc(void *arg)
|
||||
{
|
||||
char szDisplay[512];
|
||||
xcb_auth_info_t *auth_info;
|
||||
int clipboardRestarts = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
Bool fShutdown;
|
||||
|
||||
++clipboardRestarts;
|
||||
|
||||
/* Setup the display connection string */
|
||||
/*
|
||||
* NOTE: Always connect to screen 0 since we require that screen
|
||||
* numbers start at 0 and increase without gaps. We only need
|
||||
* to connect to one screen on the display to get events
|
||||
* for all screens on the display. That is why there is only
|
||||
* one clipboard client thread.
|
||||
*/
|
||||
winGetDisplayName(szDisplay, 0);
|
||||
|
||||
/* Print the display connection string */
|
||||
ErrorF("winClipboardThreadProc - DISPLAY=%s\n", szDisplay);
|
||||
|
||||
/* Flag that clipboard client has been launched */
|
||||
g_fClipboardStarted = TRUE;
|
||||
|
||||
/* Use our generated cookie for authentication */
|
||||
auth_info = winGetXcbAuthInfo();
|
||||
|
||||
fShutdown = winClipboardProc(szDisplay, auth_info);
|
||||
|
||||
/* Flag that clipboard client has stopped */
|
||||
g_fClipboardStarted = FALSE;
|
||||
|
||||
if (fShutdown)
|
||||
break;
|
||||
|
||||
/* checking if we need to restart */
|
||||
if (clipboardRestarts >= WIN_CLIPBOARD_RETRIES) {
|
||||
/* terminates clipboard thread but the main server still lives */
|
||||
ErrorF("winClipboardProc - the clipboard thread has restarted %d times and seems to be unstable, disabling clipboard integration\n", clipboardRestarts);
|
||||
g_fClipboard = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(WIN_CLIPBOARD_DELAY);
|
||||
ErrorF("winClipboardProc - trying to restart clipboard thread \n");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the Clipboard module
|
||||
*/
|
||||
|
||||
Bool
|
||||
winInitClipboard(void)
|
||||
{
|
||||
winDebug("winInitClipboard ()\n");
|
||||
|
||||
/* Spawn a thread for the Clipboard module */
|
||||
if (pthread_create(&g_ptClipboardProc, NULL, winClipboardThreadProc, NULL)) {
|
||||
/* Bail if thread creation failed */
|
||||
ErrorF("winInitClipboard - pthread_create failed.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
winClipboardShutdown(void)
|
||||
{
|
||||
/* Close down clipboard resources */
|
||||
if (g_fClipboard && g_fClipboardStarted) {
|
||||
/* Synchronously destroy the clipboard window */
|
||||
winClipboardWindowDestroy();
|
||||
|
||||
/* Wait for the clipboard thread to exit */
|
||||
pthread_join(g_ptClipboardProc, NULL);
|
||||
|
||||
g_fClipboardStarted = FALSE;
|
||||
|
||||
winDebug("winClipboardShutdown - Clipboard thread has exited.\n");
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 copyright holder(s)
|
||||
*and author(s) 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 copyright holder(s) and author(s).
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "win.h"
|
||||
#include "dixstruct.h"
|
||||
|
||||
/*
|
||||
* Local function prototypes
|
||||
*/
|
||||
|
||||
DISPATCH_PROC(winProcEstablishConnection);
|
||||
|
||||
/*
|
||||
* Wrapper for internal EstablishConnection function.
|
||||
* Initializes internal clients that must not be started until
|
||||
* an external client has connected.
|
||||
*/
|
||||
|
||||
int
|
||||
winProcEstablishConnection(ClientPtr client)
|
||||
{
|
||||
int iReturn;
|
||||
static int s_iCallCount = 0;
|
||||
static unsigned long s_ulServerGeneration = 0;
|
||||
|
||||
if (s_iCallCount == 0)
|
||||
winDebug("winProcEstablishConnection - Hello\n");
|
||||
|
||||
/* Do nothing if clipboard is not enabled */
|
||||
if (!g_fClipboard) {
|
||||
ErrorF("winProcEstablishConnection - Clipboard is not enabled, "
|
||||
"returning.\n");
|
||||
|
||||
/* Unwrap the original function, call it, and return */
|
||||
InitialVector[2] = winProcEstablishConnectionOrig;
|
||||
iReturn = (*winProcEstablishConnectionOrig) (client);
|
||||
winProcEstablishConnectionOrig = NULL;
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
/* Watch for server reset */
|
||||
if (s_ulServerGeneration != serverGeneration) {
|
||||
/* Save new generation number */
|
||||
s_ulServerGeneration = serverGeneration;
|
||||
|
||||
/* Reset call count */
|
||||
s_iCallCount = 0;
|
||||
}
|
||||
|
||||
/* Increment call count */
|
||||
++s_iCallCount;
|
||||
|
||||
/*
|
||||
* This procedure is only used for initialization.
|
||||
* We can unwrap the original procedure at this point
|
||||
* so that this function is no longer called until the
|
||||
* server resets and the function is wrapped again.
|
||||
*/
|
||||
InitialVector[2] = winProcEstablishConnectionOrig;
|
||||
|
||||
/*
|
||||
* Call original function and bail if it fails.
|
||||
* NOTE: We must do this first, since we need XdmcpOpenDisplay
|
||||
* to be called before we initialize our clipboard client.
|
||||
*/
|
||||
iReturn = (*winProcEstablishConnectionOrig) (client);
|
||||
if (iReturn != 0) {
|
||||
ErrorF("winProcEstablishConnection - ProcEstablishConnection "
|
||||
"failed, bailing.\n");
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
/* Clear original function pointer */
|
||||
winProcEstablishConnectionOrig = NULL;
|
||||
|
||||
/* Startup the clipboard client if clipboard mode is being used */
|
||||
if (g_fClipboard) {
|
||||
/*
|
||||
* NOTE: The clipboard client is started here for a reason:
|
||||
* 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
|
||||
* 2) If the clipboard client attaches during X Server startup,
|
||||
* then it becomes the "magic client" that causes the X Server
|
||||
* to reset if it exits.
|
||||
* 3) XDMCP calls KillAllClients when it starts up.
|
||||
* 4) The clipboard client is a client, so it is killed.
|
||||
* 5) The clipboard client is the "magic client", so the X Server
|
||||
* resets itself.
|
||||
* 6) This repeats ad infinitum.
|
||||
* 7) We avoid this by waiting until at least one client (could
|
||||
* be XDM, could be another client) connects, which makes it
|
||||
* almost certain that the clipboard client will not connect
|
||||
* until after XDM when using XDMCP.
|
||||
*/
|
||||
|
||||
/* Create the clipboard client thread */
|
||||
if (!winInitClipboard()) {
|
||||
ErrorF("winProcEstablishConnection - winClipboardInit "
|
||||
"failed.\n");
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
ErrorF("winProcEstablishConnection - winInitClipboard returned.\n");
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
}
|
|
@ -1,602 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Dakshinamurthy Karra
|
||||
* Suhaib M Siddiqi
|
||||
* Peter Busch
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* Local prototypes
|
||||
*/
|
||||
|
||||
static int
|
||||
winListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps);
|
||||
|
||||
static void
|
||||
winStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs);
|
||||
|
||||
static void
|
||||
winInstallColormap(ColormapPtr pmap);
|
||||
|
||||
static void
|
||||
winUninstallColormap(ColormapPtr pmap);
|
||||
|
||||
static void
|
||||
|
||||
winResolveColor(unsigned short *pred,
|
||||
unsigned short *pgreen,
|
||||
unsigned short *pblue, VisualPtr pVisual);
|
||||
|
||||
static Bool
|
||||
winCreateColormap(ColormapPtr pmap);
|
||||
|
||||
static void
|
||||
winDestroyColormap(ColormapPtr pmap);
|
||||
|
||||
static Bool
|
||||
winGetPaletteDIB(ScreenPtr pScreen, ColormapPtr pcmap);
|
||||
|
||||
static Bool
|
||||
winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap);
|
||||
|
||||
/*
|
||||
* Set screen functions for colormaps
|
||||
*/
|
||||
|
||||
void
|
||||
winSetColormapFunctions(ScreenPtr pScreen)
|
||||
{
|
||||
pScreen->CreateColormap = winCreateColormap;
|
||||
pScreen->DestroyColormap = winDestroyColormap;
|
||||
pScreen->InstallColormap = winInstallColormap;
|
||||
pScreen->UninstallColormap = winUninstallColormap;
|
||||
pScreen->ListInstalledColormaps = winListInstalledColormaps;
|
||||
pScreen->StoreColors = winStoreColors;
|
||||
pScreen->ResolveColor = winResolveColor;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 30 */
|
||||
/*
|
||||
* Walk the list of installed colormaps, filling the pmaps list
|
||||
* with the resource ids of the installed maps, and return
|
||||
* a count of the total number of installed maps.
|
||||
*/
|
||||
static int
|
||||
winListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
/*
|
||||
* There will only be one installed colormap, so we only need
|
||||
* to return one id, and the count of installed maps will always
|
||||
* be one.
|
||||
*/
|
||||
*pmaps = pScreenPriv->pcmapInstalled->mid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 30 */
|
||||
/* See Programming Windows - p. 663 */
|
||||
static void
|
||||
winInstallColormap(ColormapPtr pColormap)
|
||||
{
|
||||
ScreenPtr pScreen = pColormap->pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winInstallColormap\n");
|
||||
#endif
|
||||
|
||||
/* Did the colormap actually change? */
|
||||
if (pColormap != oldpmap) {
|
||||
#if CYGDEBUG
|
||||
winDebug("winInstallColormap - Colormap has changed, attempt "
|
||||
"to install.\n");
|
||||
#endif
|
||||
|
||||
/* Was there a previous colormap? */
|
||||
if (oldpmap != (ColormapPtr) None) {
|
||||
/* There was a previous colormap; tell clients it is gone */
|
||||
WalkTree(pColormap->pScreen, TellLostMap, (char *) &oldpmap->mid);
|
||||
}
|
||||
|
||||
/* Install new colormap */
|
||||
pScreenPriv->pcmapInstalled = pColormap;
|
||||
WalkTree(pColormap->pScreen, TellGainedMap, (char *) &pColormap->mid);
|
||||
|
||||
/* Call the engine specific colormap install procedure */
|
||||
if (!((*pScreenPriv->pwinInstallColormap) (pColormap))) {
|
||||
winErrorFVerb(2,
|
||||
"winInstallColormap - Screen specific colormap install "
|
||||
"procedure failed. Continuing, but colors may be "
|
||||
"messed up from now on.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Save a pointer to the newly installed colormap */
|
||||
pScreenPriv->pcmapInstalled = pColormap;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 30 */
|
||||
static void
|
||||
winUninstallColormap(ColormapPtr pmap)
|
||||
{
|
||||
winScreenPriv(pmap->pScreen);
|
||||
ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winUninstallColormap\n");
|
||||
#endif
|
||||
|
||||
/* Is the colormap currently installed? */
|
||||
if (pmap != curpmap) {
|
||||
/* Colormap not installed, nothing to do */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Clear the installed colormap flag */
|
||||
pScreenPriv->pcmapInstalled = NULL;
|
||||
|
||||
/*
|
||||
* NOTE: The default colormap does not get "uninstalled" before
|
||||
* it is destroyed.
|
||||
*/
|
||||
|
||||
/* Install the default cmap in place of the cmap to be uninstalled */
|
||||
if (pmap->mid != pmap->pScreen->defColormap) {
|
||||
dixLookupResourceByType((void *) &curpmap, pmap->pScreen->defColormap,
|
||||
RT_COLORMAP, NullClient, DixUnknownAccess);
|
||||
(*pmap->pScreen->InstallColormap) (curpmap);
|
||||
}
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 30 */
|
||||
static void
|
||||
winStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
|
||||
{
|
||||
ScreenPtr pScreen = pmap->pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
winCmapPriv(pmap);
|
||||
int i;
|
||||
unsigned short nRed, nGreen, nBlue;
|
||||
|
||||
#if CYGDEBUG
|
||||
if (ndef != 1)
|
||||
winDebug("winStoreColors - ndef: %d\n", ndef);
|
||||
#endif
|
||||
|
||||
/* Save the new colors in the colormap privates */
|
||||
for (i = 0; i < ndef; ++i) {
|
||||
/* Adjust the colors from the X color spec to the Windows color spec */
|
||||
nRed = pdefs[i].red >> 8;
|
||||
nGreen = pdefs[i].green >> 8;
|
||||
nBlue = pdefs[i].blue >> 8;
|
||||
|
||||
/* Copy the colors to a palette entry table */
|
||||
pCmapPriv->peColors[pdefs[0].pixel + i].peRed = nRed;
|
||||
pCmapPriv->peColors[pdefs[0].pixel + i].peGreen = nGreen;
|
||||
pCmapPriv->peColors[pdefs[0].pixel + i].peBlue = nBlue;
|
||||
|
||||
/* Copy the colors to a RGBQUAD table */
|
||||
pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbRed = nRed;
|
||||
pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
|
||||
pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winStoreColors - nRed %d nGreen %d nBlue %d\n",
|
||||
nRed, nGreen, nBlue);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Call the engine specific store colors procedure */
|
||||
if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs))) {
|
||||
winErrorFVerb(2,
|
||||
"winStoreColors - Engine cpecific color storage procedure "
|
||||
"failed. Continuing, but colors may be messed up from now "
|
||||
"on.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 30 */
|
||||
static void
|
||||
winResolveColor(unsigned short *pred,
|
||||
unsigned short *pgreen,
|
||||
unsigned short *pblue, VisualPtr pVisual)
|
||||
{
|
||||
#if CYGDEBUG
|
||||
winDebug("winResolveColor ()\n");
|
||||
#endif
|
||||
|
||||
miResolveColor(pred, pgreen, pblue, pVisual);
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 29 */
|
||||
static Bool
|
||||
winCreateColormap(ColormapPtr pmap)
|
||||
{
|
||||
winPrivCmapPtr pCmapPriv = NULL;
|
||||
ScreenPtr pScreen = pmap->pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateColormap\n");
|
||||
#endif
|
||||
|
||||
/* Allocate colormap privates */
|
||||
if (!winAllocateCmapPrivates(pmap)) {
|
||||
ErrorF("winCreateColorma - Couldn't allocate cmap privates\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get a pointer to the newly allocated privates */
|
||||
pCmapPriv = winGetCmapPriv(pmap);
|
||||
|
||||
/*
|
||||
* FIXME: This is some evil hackery to help in handling some X clients
|
||||
* that expect the top pixel to be white. This "help" only lasts until
|
||||
* some client overwrites the top colormap entry.
|
||||
*
|
||||
* We don't want to actually allocate the top entry, as that causes
|
||||
* problems with X clients that need 7 planes (128 colors) in the default
|
||||
* colormap, such as Magic 7.1.
|
||||
*/
|
||||
pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbRed = 255;
|
||||
pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbGreen = 255;
|
||||
pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbBlue = 255;
|
||||
pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peRed = 255;
|
||||
pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peGreen = 255;
|
||||
pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peBlue = 255;
|
||||
|
||||
/* Call the engine specific colormap initialization procedure */
|
||||
if (!((*pScreenPriv->pwinCreateColormap) (pmap))) {
|
||||
ErrorF("winCreateColormap - Engine specific colormap creation "
|
||||
"procedure failed. Aborting.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 29, 30 */
|
||||
static void
|
||||
winDestroyColormap(ColormapPtr pColormap)
|
||||
{
|
||||
winScreenPriv(pColormap->pScreen);
|
||||
winCmapPriv(pColormap);
|
||||
|
||||
/* Call the engine specific colormap destruction procedure */
|
||||
if (!((*pScreenPriv->pwinDestroyColormap) (pColormap))) {
|
||||
winErrorFVerb(2,
|
||||
"winDestroyColormap - Engine specific colormap destruction "
|
||||
"procedure failed. Continuing, but it is possible that memory "
|
||||
"was leaked, or that colors will be messed up from now on.\n");
|
||||
}
|
||||
|
||||
/* Free the colormap privates */
|
||||
free(pCmapPriv);
|
||||
winSetCmapPriv(pColormap, NULL);
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winDestroyColormap - Returning\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal function to load the palette used by the Shadow DIB
|
||||
*/
|
||||
|
||||
static Bool
|
||||
winGetPaletteDIB(ScreenPtr pScreen, ColormapPtr pcmap)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
int i;
|
||||
Pixel pixel; /* Pixel == CARD32 */
|
||||
CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
|
||||
UINT uiColorsRetrieved = 0;
|
||||
RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
|
||||
|
||||
/* Get the color table for the screen */
|
||||
uiColorsRetrieved = GetDIBColorTable(pScreenPriv->hdcScreen,
|
||||
0, WIN_NUM_PALETTE_ENTRIES, rgbColors);
|
||||
if (uiColorsRetrieved == 0) {
|
||||
ErrorF("winGetPaletteDIB - Could not retrieve screen color table\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winGetPaletteDIB - Retrieved %d colors from DIB\n",
|
||||
uiColorsRetrieved);
|
||||
#endif
|
||||
|
||||
/* Set the DIB color table to the default screen palette */
|
||||
if (SetDIBColorTable(pScreenPriv->hdcShadow,
|
||||
0, uiColorsRetrieved, rgbColors) == 0) {
|
||||
ErrorF("winGetPaletteDIB - SetDIBColorTable () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Alloc each color in the DIB color table */
|
||||
for (i = 0; i < uiColorsRetrieved; ++i) {
|
||||
pixel = i;
|
||||
|
||||
/* Extract the color values for current palette entry */
|
||||
nRed = rgbColors[i].rgbRed << 8;
|
||||
nGreen = rgbColors[i].rgbGreen << 8;
|
||||
nBlue = rgbColors[i].rgbBlue << 8;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winGetPaletteDIB - Allocating a color: %u; "
|
||||
"%d %d %d\n", (unsigned int)pixel, nRed, nGreen, nBlue);
|
||||
#endif
|
||||
|
||||
/* Allocate a entry in the X colormap */
|
||||
if (AllocColor(pcmap, &nRed, &nGreen, &nBlue, &pixel, 0) != Success) {
|
||||
ErrorF("winGetPaletteDIB - AllocColor () failed, pixel %d\n", i);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (i != pixel
|
||||
|| nRed != rgbColors[i].rgbRed
|
||||
|| nGreen != rgbColors[i].rgbGreen
|
||||
|| nBlue != rgbColors[i].rgbBlue) {
|
||||
winDebug("winGetPaletteDIB - Got: %d; "
|
||||
"%d %d %d\n", (int) pixel, nRed, nGreen, nBlue);
|
||||
}
|
||||
|
||||
/* FIXME: Not sure that this bit is needed at all */
|
||||
pcmap->red[i].co.local.red = nRed;
|
||||
pcmap->red[i].co.local.green = nGreen;
|
||||
pcmap->red[i].co.local.blue = nBlue;
|
||||
}
|
||||
|
||||
/* System is using a colormap */
|
||||
/* Set the black and white pixel indices */
|
||||
pScreen->whitePixel = uiColorsRetrieved - 1;
|
||||
pScreen->blackPixel = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal function to load the standard system palette being used by DD
|
||||
*/
|
||||
|
||||
static Bool
|
||||
winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
|
||||
{
|
||||
int i;
|
||||
Pixel pixel; /* Pixel == CARD32 */
|
||||
CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
|
||||
UINT uiSystemPaletteEntries;
|
||||
LPPALETTEENTRY ppeColors = NULL;
|
||||
HDC hdc = NULL;
|
||||
|
||||
/* Get a DC to obtain the default palette */
|
||||
hdc = GetDC(NULL);
|
||||
if (hdc == NULL) {
|
||||
ErrorF("winGetPaletteDD - Couldn't get a DC\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get the number of entries in the system palette */
|
||||
uiSystemPaletteEntries = GetSystemPaletteEntries(hdc, 0, 0, NULL);
|
||||
if (uiSystemPaletteEntries == 0) {
|
||||
ErrorF("winGetPaletteDD - Unable to determine number of "
|
||||
"system palette entries\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winGetPaletteDD - uiSystemPaletteEntries %d\n",
|
||||
uiSystemPaletteEntries);
|
||||
#endif
|
||||
|
||||
/* Allocate palette entries structure */
|
||||
ppeColors = malloc(uiSystemPaletteEntries * sizeof(PALETTEENTRY));
|
||||
if (ppeColors == NULL) {
|
||||
ErrorF("winGetPaletteDD - malloc () for colormap failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get system palette entries */
|
||||
GetSystemPaletteEntries(hdc, 0, uiSystemPaletteEntries, ppeColors);
|
||||
|
||||
/* Allocate an X colormap entry for every system palette entry */
|
||||
for (i = 0; i < uiSystemPaletteEntries; ++i) {
|
||||
pixel = i;
|
||||
|
||||
/* Extract the color values for current palette entry */
|
||||
nRed = ppeColors[i].peRed << 8;
|
||||
nGreen = ppeColors[i].peGreen << 8;
|
||||
nBlue = ppeColors[i].peBlue << 8;
|
||||
#if CYGDEBUG
|
||||
winDebug("winGetPaletteDD - Allocating a color: %u; "
|
||||
"%d %d %d\n", (unsigned int)pixel, nRed, nGreen, nBlue);
|
||||
#endif
|
||||
if (AllocColor(pcmap, &nRed, &nGreen, &nBlue, &pixel, 0) != Success) {
|
||||
ErrorF("winGetPaletteDD - AllocColor () failed, pixel %d\n", i);
|
||||
free(ppeColors);
|
||||
ppeColors = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pcmap->red[i].co.local.red = nRed;
|
||||
pcmap->red[i].co.local.green = nGreen;
|
||||
pcmap->red[i].co.local.blue = nBlue;
|
||||
}
|
||||
|
||||
/* System is using a colormap */
|
||||
/* Set the black and white pixel indices */
|
||||
pScreen->whitePixel = uiSystemPaletteEntries - 1;
|
||||
pScreen->blackPixel = 0;
|
||||
|
||||
/* Free colormap */
|
||||
free(ppeColors);
|
||||
ppeColors = NULL;
|
||||
|
||||
/* Free the DC */
|
||||
if (hdc != NULL) {
|
||||
ReleaseDC(NULL, hdc);
|
||||
hdc = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Install the standard fb colormap, or the GDI colormap,
|
||||
* depending on the current screen depth.
|
||||
*/
|
||||
|
||||
Bool
|
||||
winCreateDefColormap(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
unsigned short zero = 0, ones = 0xFFFF;
|
||||
VisualPtr pVisual = pScreenPriv->pRootVisual;
|
||||
ColormapPtr pcmap = NULL;
|
||||
Pixel wp, bp;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateDefColormap\n");
|
||||
#endif
|
||||
|
||||
/* Use standard fb colormaps for non palettized color modes */
|
||||
if (pScreenInfo->dwBPP > 8) {
|
||||
winDebug("winCreateDefColormap - Deferring to "
|
||||
"fbCreateDefColormap ()\n");
|
||||
return fbCreateDefColormap(pScreen);
|
||||
}
|
||||
|
||||
/*
|
||||
* AllocAll for non-Dynamic visual classes,
|
||||
* AllocNone for Dynamic visual classes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Dynamic visual classes allow the colors of the color map
|
||||
* to be changed by clients.
|
||||
*/
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateDefColormap - defColormap: %lu\n", pScreen->defColormap);
|
||||
#endif
|
||||
|
||||
/* Allocate an X colormap, owned by client 0 */
|
||||
if (CreateColormap(pScreen->defColormap,
|
||||
pScreen,
|
||||
pVisual,
|
||||
&pcmap,
|
||||
(pVisual->class & DynamicClass) ? AllocNone : AllocAll,
|
||||
0) != Success) {
|
||||
ErrorF("winCreateDefColormap - CreateColormap failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (pcmap == NULL) {
|
||||
ErrorF("winCreateDefColormap - Colormap could not be created\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateDefColormap - Created a colormap\n");
|
||||
#endif
|
||||
|
||||
/* Branch on the visual class */
|
||||
if (!(pVisual->class & DynamicClass)) {
|
||||
/* Branch on engine type */
|
||||
if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI) {
|
||||
/* Load the colors being used by the Shadow DIB */
|
||||
if (!winGetPaletteDIB(pScreen, pcmap)) {
|
||||
ErrorF("winCreateDefColormap - Couldn't get DIB colors\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Load the colors from the default system palette */
|
||||
if (!winGetPaletteDD(pScreen, pcmap)) {
|
||||
ErrorF("winCreateDefColormap - Couldn't get colors "
|
||||
"for DD\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
wp = pScreen->whitePixel;
|
||||
bp = pScreen->blackPixel;
|
||||
|
||||
/* Allocate a black and white pixel */
|
||||
if ((AllocColor(pcmap, &ones, &ones, &ones, &wp, 0) != Success)
|
||||
|| (AllocColor(pcmap, &zero, &zero, &zero, &bp, 0) != Success)) {
|
||||
ErrorF("winCreateDefColormap - Couldn't allocate bp or wp\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pScreen->whitePixel = wp;
|
||||
pScreen->blackPixel = bp;
|
||||
|
||||
#if 0
|
||||
/* Have to reserve first 10 and last ten pixels in DirectDraw windowed */
|
||||
if (pScreenInfo->dwEngine != WIN_SERVER_SHADOW_GDI) {
|
||||
int k;
|
||||
Pixel p;
|
||||
|
||||
for (k = 1; k < 10; ++k) {
|
||||
p = k;
|
||||
if (AllocColor(pcmap, &ones, &ones, &ones, &p, 0) != Success)
|
||||
FatalError("Foo!\n");
|
||||
}
|
||||
|
||||
for (k = 245; k < 255; ++k) {
|
||||
p = k;
|
||||
if (AllocColor(pcmap, &zero, &zero, &zero, &p, 0) != Success)
|
||||
FatalError("Baz!\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Install the created colormap */
|
||||
(*pScreen->InstallColormap) (pcmap);
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateDefColormap - Returning\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
1020
hw/xwin/winconfig.c
1020
hw/xwin/winconfig.c
File diff suppressed because it is too large
Load Diff
|
@ -1,263 +0,0 @@
|
|||
#ifndef __WIN_CONFIG_H__
|
||||
#define __WIN_CONFIG_H__
|
||||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Alexander Gottwald
|
||||
*/
|
||||
|
||||
#include "win.h"
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
#include "../xfree86/parser/xf86Parser.h"
|
||||
#endif
|
||||
|
||||
/* These are taken from hw/xfree86/common/xf86str.h */
|
||||
|
||||
typedef struct {
|
||||
CARD32 red, green, blue;
|
||||
} rgb;
|
||||
|
||||
typedef struct {
|
||||
float red, green, blue;
|
||||
} Gamma;
|
||||
|
||||
typedef struct {
|
||||
char *identifier;
|
||||
char *vendor;
|
||||
char *board;
|
||||
char *chipset;
|
||||
char *ramdac;
|
||||
char *driver;
|
||||
struct _confscreenrec *myScreenSection;
|
||||
Bool claimed;
|
||||
Bool active;
|
||||
Bool inUse;
|
||||
int videoRam;
|
||||
void *options;
|
||||
int screen; /* For multi-CRTC cards */
|
||||
} GDevRec, *GDevPtr;
|
||||
|
||||
typedef struct {
|
||||
char *identifier;
|
||||
char *driver;
|
||||
void *commonOptions;
|
||||
void *extraOptions;
|
||||
} IDevRec, *IDevPtr;
|
||||
|
||||
typedef struct {
|
||||
int frameX0;
|
||||
int frameY0;
|
||||
int virtualX;
|
||||
int virtualY;
|
||||
int depth;
|
||||
int fbbpp;
|
||||
rgb weight;
|
||||
rgb blackColour;
|
||||
rgb whiteColour;
|
||||
int defaultVisual;
|
||||
char **modes;
|
||||
void *options;
|
||||
} DispRec, *DispPtr;
|
||||
|
||||
typedef struct _confxvportrec {
|
||||
char *identifier;
|
||||
void *options;
|
||||
} confXvPortRec, *confXvPortPtr;
|
||||
|
||||
typedef struct _confxvadaptrec {
|
||||
char *identifier;
|
||||
int numports;
|
||||
confXvPortPtr ports;
|
||||
void *options;
|
||||
} confXvAdaptorRec, *confXvAdaptorPtr;
|
||||
|
||||
typedef struct _confscreenrec {
|
||||
char *id;
|
||||
int screennum;
|
||||
int defaultdepth;
|
||||
int defaultbpp;
|
||||
int defaultfbbpp;
|
||||
GDevPtr device;
|
||||
int numdisplays;
|
||||
DispPtr displays;
|
||||
int numxvadaptors;
|
||||
confXvAdaptorPtr xvadaptors;
|
||||
void *options;
|
||||
} confScreenRec, *confScreenPtr;
|
||||
|
||||
typedef enum {
|
||||
PosObsolete = -1,
|
||||
PosAbsolute = 0,
|
||||
PosRightOf,
|
||||
PosLeftOf,
|
||||
PosAbove,
|
||||
PosBelow,
|
||||
PosRelative
|
||||
} PositionType;
|
||||
|
||||
typedef struct _screenlayoutrec {
|
||||
confScreenPtr screen;
|
||||
char *topname;
|
||||
confScreenPtr top;
|
||||
char *bottomname;
|
||||
confScreenPtr bottom;
|
||||
char *leftname;
|
||||
confScreenPtr left;
|
||||
char *rightname;
|
||||
confScreenPtr right;
|
||||
PositionType where;
|
||||
int x;
|
||||
int y;
|
||||
char *refname;
|
||||
confScreenPtr refscreen;
|
||||
} screenLayoutRec, *screenLayoutPtr;
|
||||
|
||||
typedef struct _serverlayoutrec {
|
||||
char *id;
|
||||
screenLayoutPtr screens;
|
||||
GDevPtr inactives;
|
||||
IDevPtr inputs;
|
||||
void *options;
|
||||
} serverLayoutRec, *serverLayoutPtr;
|
||||
|
||||
/*
|
||||
* winconfig.c
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
/* Files */
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
char *configFile;
|
||||
char *configDir;
|
||||
#endif
|
||||
char *fontPath;
|
||||
/* input devices - keyboard */
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
char *keyboard;
|
||||
#endif
|
||||
char *xkbRules;
|
||||
char *xkbModel;
|
||||
char *xkbLayout;
|
||||
char *xkbVariant;
|
||||
char *xkbOptions;
|
||||
/* layout */
|
||||
char *screenname;
|
||||
/* mouse settings */
|
||||
char *mouse;
|
||||
Bool emulate3buttons;
|
||||
long emulate3timeout;
|
||||
} WinCmdlineRec, *WinCmdlinePtr;
|
||||
|
||||
extern WinCmdlineRec g_cmdline;
|
||||
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
extern XF86ConfigPtr g_xf86configptr;
|
||||
#endif
|
||||
extern serverLayoutRec g_winConfigLayout;
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
Bool winReadConfigfile(void);
|
||||
Bool winConfigFiles(void);
|
||||
Bool winConfigOptions(void);
|
||||
Bool winConfigScreens(void);
|
||||
Bool winConfigKeyboard(DeviceIntPtr pDevice);
|
||||
Bool winConfigMouse(DeviceIntPtr pDevice);
|
||||
|
||||
typedef struct {
|
||||
double freq;
|
||||
int units;
|
||||
} OptFrequency;
|
||||
|
||||
typedef union {
|
||||
unsigned long num;
|
||||
char *str;
|
||||
double realnum;
|
||||
Bool boolean;
|
||||
OptFrequency freq;
|
||||
} ValueUnion;
|
||||
|
||||
typedef enum {
|
||||
OPTV_NONE = 0,
|
||||
OPTV_INTEGER,
|
||||
OPTV_STRING, /* a non-empty string */
|
||||
OPTV_ANYSTR, /* Any string, including an empty one */
|
||||
OPTV_REAL,
|
||||
OPTV_BOOLEAN,
|
||||
OPTV_PERCENT,
|
||||
OPTV_FREQ
|
||||
} OptionValueType;
|
||||
|
||||
typedef enum {
|
||||
OPTUNITS_HZ = 1,
|
||||
OPTUNITS_KHZ,
|
||||
OPTUNITS_MHZ
|
||||
} OptFreqUnits;
|
||||
|
||||
typedef struct {
|
||||
int token;
|
||||
const char *name;
|
||||
OptionValueType type;
|
||||
ValueUnion value;
|
||||
Bool found;
|
||||
} OptionInfoRec, *OptionInfoPtr;
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
char *winSetStrOption(void *optlist, const char *name, char *deflt);
|
||||
int winSetBoolOption(void *optlist, const char *name, int deflt);
|
||||
int winSetIntOption(void *optlist, const char *name, int deflt);
|
||||
double winSetRealOption(void *optlist, const char *name, double deflt);
|
||||
double winSetPercentOption(void *optlist, const char *name, double deflt);
|
||||
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
XF86OptionPtr winFindOption(XF86OptionPtr list, const char *name);
|
||||
char *winFindOptionValue(XF86OptionPtr list, const char *name);
|
||||
#endif
|
||||
int winNameCompare(const char *s1, const char *s2);
|
||||
char *winNormalizeName(const char *s);
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
long leds;
|
||||
long delay;
|
||||
long rate;
|
||||
} keyboard;
|
||||
XkbRMLVOSet xkb;
|
||||
struct {
|
||||
Bool emulate3Buttons;
|
||||
long emulate3Timeout;
|
||||
} pointer;
|
||||
} winInfoRec, *winInfoPtr;
|
||||
|
||||
extern winInfoRec g_winInfo;
|
||||
|
||||
#endif
|
|
@ -1,590 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "shellapi.h"
|
||||
|
||||
/*
|
||||
* Local function prototypes
|
||||
*/
|
||||
|
||||
static Bool
|
||||
winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo);
|
||||
|
||||
static Bool
|
||||
winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo);
|
||||
|
||||
/*
|
||||
* Create a full screen window
|
||||
*/
|
||||
|
||||
Bool
|
||||
winCreateBoundingWindowFullScreen(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
int iX = pScreenInfo->dwInitialX;
|
||||
int iY = pScreenInfo->dwInitialY;
|
||||
int iWidth = pScreenInfo->dwWidth;
|
||||
int iHeight = pScreenInfo->dwHeight;
|
||||
HWND *phwnd = &pScreenPriv->hwndScreen;
|
||||
WNDCLASSEX wc;
|
||||
char szTitle[256];
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateBoundingWindowFullScreen\n");
|
||||
#endif
|
||||
|
||||
/* Setup our window class */
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = winWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = g_hInstance;
|
||||
wc.hIcon = pScreenInfo->hIcon;
|
||||
wc.hCursor = 0;
|
||||
wc.hbrBackground = 0;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = WINDOW_CLASS;
|
||||
wc.hIconSm = pScreenInfo->hIconSm;
|
||||
RegisterClassEx(&wc);
|
||||
|
||||
/* Set display and screen-specific tooltip text */
|
||||
if (g_pszQueryHost != NULL)
|
||||
snprintf(szTitle,
|
||||
sizeof(szTitle),
|
||||
WINDOW_TITLE_XDMCP,
|
||||
g_pszQueryHost, display, (int) pScreenInfo->dwScreen);
|
||||
else
|
||||
snprintf(szTitle,
|
||||
sizeof(szTitle),
|
||||
WINDOW_TITLE, display, (int) pScreenInfo->dwScreen);
|
||||
|
||||
/* Create the window */
|
||||
*phwnd = CreateWindowExA(0, /* Extended styles */
|
||||
WINDOW_CLASS, /* Class name */
|
||||
szTitle, /* Window name */
|
||||
WS_POPUP, iX, /* Horizontal position */
|
||||
iY, /* Vertical position */
|
||||
iWidth, /* Right edge */
|
||||
iHeight, /* Bottom edge */
|
||||
(HWND) NULL, /* No parent or owner window */
|
||||
(HMENU) NULL, /* No menu */
|
||||
GetModuleHandle(NULL), /* Instance handle */
|
||||
pScreenPriv); /* ScreenPrivates */
|
||||
|
||||
/* Hide the window */
|
||||
ShowWindow(*phwnd, SW_SHOWNORMAL);
|
||||
|
||||
/* Send first paint message */
|
||||
UpdateWindow(*phwnd);
|
||||
|
||||
/* Attempt to bring our window to the top of the display */
|
||||
BringWindowToTop(*phwnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create our primary Windows display window
|
||||
*/
|
||||
|
||||
Bool
|
||||
winCreateBoundingWindowWindowed(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
int iWidth = pScreenInfo->dwUserWidth;
|
||||
int iHeight = pScreenInfo->dwUserHeight;
|
||||
int iPosX;
|
||||
int iPosY;
|
||||
HWND *phwnd = &pScreenPriv->hwndScreen;
|
||||
WNDCLASSEX wc;
|
||||
RECT rcClient, rcWorkArea;
|
||||
DWORD dwWindowStyle;
|
||||
BOOL fForceShowWindow = FALSE;
|
||||
char szTitle[256];
|
||||
|
||||
winDebug("winCreateBoundingWindowWindowed - User w: %d h: %d\n",
|
||||
(int) pScreenInfo->dwUserWidth, (int) pScreenInfo->dwUserHeight);
|
||||
winDebug("winCreateBoundingWindowWindowed - Current w: %d h: %d\n",
|
||||
(int) pScreenInfo->dwWidth, (int) pScreenInfo->dwHeight);
|
||||
|
||||
/* Set the common window style flags */
|
||||
dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||
|
||||
/* Decorated or undecorated window */
|
||||
if (pScreenInfo->fDecoration
|
||||
&& !pScreenInfo->fRootless
|
||||
&& !pScreenInfo->fMultiWindow
|
||||
) {
|
||||
/* Try to handle startup via run.exe. run.exe instructs Windows to
|
||||
* hide all created windows. Detect this case and make sure the
|
||||
* window is shown nevertheless */
|
||||
STARTUPINFO startupInfo;
|
||||
|
||||
GetStartupInfo(&startupInfo);
|
||||
if (startupInfo.dwFlags & STARTF_USESHOWWINDOW &&
|
||||
startupInfo.wShowWindow == SW_HIDE) {
|
||||
fForceShowWindow = TRUE;
|
||||
}
|
||||
dwWindowStyle |= WS_CAPTION;
|
||||
if (pScreenInfo->iResizeMode != resizeNotAllowed)
|
||||
dwWindowStyle |= WS_THICKFRAME | WS_MAXIMIZEBOX;
|
||||
}
|
||||
else
|
||||
dwWindowStyle |= WS_POPUP;
|
||||
|
||||
/* Setup our window class */
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = winWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = g_hInstance;
|
||||
wc.hIcon = pScreenInfo->hIcon;
|
||||
wc.hCursor = 0;
|
||||
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = WINDOW_CLASS;
|
||||
wc.hIconSm = pScreenInfo->hIconSm;
|
||||
RegisterClassEx(&wc);
|
||||
|
||||
/* Get size of work area */
|
||||
winGetWorkArea(&rcWorkArea, pScreenInfo);
|
||||
|
||||
/* Adjust for auto-hide taskbars */
|
||||
winAdjustForAutoHide(&rcWorkArea, pScreenInfo);
|
||||
|
||||
/* Did the user specify a position? */
|
||||
if (pScreenInfo->fUserGavePosition) {
|
||||
iPosX = pScreenInfo->dwInitialX;
|
||||
iPosY = pScreenInfo->dwInitialY;
|
||||
}
|
||||
else {
|
||||
iPosX = rcWorkArea.left;
|
||||
iPosY = rcWorkArea.top;
|
||||
}
|
||||
|
||||
/* Clean up the scrollbars flag, if necessary */
|
||||
if ((!pScreenInfo->fDecoration
|
||||
|| pScreenInfo->fRootless
|
||||
|| pScreenInfo->fMultiWindow
|
||||
)
|
||||
&& (pScreenInfo->iResizeMode == resizeWithScrollbars)) {
|
||||
/* We cannot have scrollbars if we do not have a window border */
|
||||
pScreenInfo->iResizeMode = resizeNotAllowed;
|
||||
}
|
||||
|
||||
/* Did the user specify a height and width? */
|
||||
if (pScreenInfo->fUserGaveHeightAndWidth) {
|
||||
/* User gave a desired height and width, try to accommodate */
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateBoundingWindowWindowed - User gave height "
|
||||
"and width\n");
|
||||
#endif
|
||||
|
||||
/* Adjust the window width and height for borders and title bar */
|
||||
if (pScreenInfo->fDecoration
|
||||
&& !pScreenInfo->fRootless
|
||||
&& !pScreenInfo->fMultiWindow
|
||||
) {
|
||||
#if CYGDEBUG
|
||||
winDebug
|
||||
("winCreateBoundingWindowWindowed - Window has decoration\n");
|
||||
#endif
|
||||
|
||||
/* Are we resizable */
|
||||
if (pScreenInfo->iResizeMode != resizeNotAllowed) {
|
||||
#if CYGDEBUG
|
||||
winDebug
|
||||
("winCreateBoundingWindowWindowed - Window is resizable\n");
|
||||
#endif
|
||||
|
||||
iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
|
||||
iHeight += 2 * GetSystemMetrics(SM_CYSIZEFRAME)
|
||||
+ GetSystemMetrics(SM_CYCAPTION);
|
||||
}
|
||||
else {
|
||||
#if CYGDEBUG
|
||||
winDebug
|
||||
("winCreateBoundingWindowWindowed - Window is not resizable\n");
|
||||
#endif
|
||||
|
||||
iWidth += 2 * GetSystemMetrics(SM_CXFIXEDFRAME);
|
||||
iHeight += 2 * GetSystemMetrics(SM_CYFIXEDFRAME)
|
||||
+ GetSystemMetrics(SM_CYCAPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* By default, we are creating a window that is as large as possible */
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateBoundingWindowWindowed - User did not give "
|
||||
"height and width\n");
|
||||
#endif
|
||||
/* Defaults are wrong if we have multiple monitors */
|
||||
if (pScreenInfo->fMultipleMonitors) {
|
||||
iWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
iHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure window is no bigger than work area */
|
||||
if (TRUE
|
||||
&& !pScreenInfo->fMultiWindow
|
||||
) {
|
||||
/* Trim window width to fit work area */
|
||||
if (iWidth > (rcWorkArea.right - rcWorkArea.left))
|
||||
iWidth = rcWorkArea.right - rcWorkArea.left;
|
||||
|
||||
/* Trim window height to fit work area */
|
||||
if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
|
||||
iHeight = rcWorkArea.bottom - rcWorkArea.top;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateBoundingWindowWindowed - Adjusted width: %d "
|
||||
"height: %d\n", iWidth, iHeight);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set display and screen-specific tooltip text */
|
||||
if (g_pszQueryHost != NULL)
|
||||
snprintf(szTitle,
|
||||
sizeof(szTitle),
|
||||
WINDOW_TITLE_XDMCP,
|
||||
g_pszQueryHost, display, (int) pScreenInfo->dwScreen);
|
||||
else
|
||||
snprintf(szTitle,
|
||||
sizeof(szTitle),
|
||||
WINDOW_TITLE, display, (int) pScreenInfo->dwScreen);
|
||||
|
||||
/* Create the window */
|
||||
*phwnd = CreateWindowExA(0, /* Extended styles */
|
||||
WINDOW_CLASS, /* Class name */
|
||||
szTitle, /* Window name */
|
||||
dwWindowStyle, iPosX, /* Horizontal position */
|
||||
iPosY, /* Vertical position */
|
||||
iWidth, /* Right edge */
|
||||
iHeight, /* Bottom edge */
|
||||
(HWND) NULL, /* No parent or owner window */
|
||||
(HMENU) NULL, /* No menu */
|
||||
GetModuleHandle(NULL), /* Instance handle */
|
||||
pScreenPriv); /* ScreenPrivates */
|
||||
if (*phwnd == NULL) {
|
||||
ErrorF("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n");
|
||||
#endif
|
||||
|
||||
if (fForceShowWindow) {
|
||||
ErrorF
|
||||
("winCreateBoundingWindowWindowed - Setting normal windowstyle\n");
|
||||
ShowWindow(*phwnd, SW_SHOW);
|
||||
}
|
||||
|
||||
/* Get the client area coordinates */
|
||||
if (!GetClientRect(*phwnd, &rcClient)) {
|
||||
ErrorF("winCreateBoundingWindowWindowed - GetClientRect () "
|
||||
"failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
winDebug("winCreateBoundingWindowWindowed - WindowClient "
|
||||
"w %d h %d r %d l %d b %d t %d\n",
|
||||
(int)(rcClient.right - rcClient.left),
|
||||
(int)(rcClient.bottom - rcClient.top),
|
||||
(int)rcClient.right, (int)rcClient.left,
|
||||
(int)rcClient.bottom, (int)rcClient.top);
|
||||
|
||||
/* We adjust the visual size if the user did not specify it */
|
||||
if (!
|
||||
((pScreenInfo->iResizeMode == resizeWithScrollbars) &&
|
||||
pScreenInfo->fUserGaveHeightAndWidth)) {
|
||||
/*
|
||||
* User did not give a height and width with scrollbars enabled,
|
||||
* so we will resize the underlying visual to be as large as
|
||||
* the initial view port (page size). This way scrollbars will
|
||||
* not appear until the user shrinks the window, if they ever do.
|
||||
*
|
||||
* NOTE: We have to store the viewport size here because
|
||||
* the user may have an autohide taskbar, which would
|
||||
* cause the viewport size to be one less in one dimension
|
||||
* than the viewport size that we calculated by subtracting
|
||||
* the size of the borders and caption.
|
||||
*/
|
||||
pScreenInfo->dwWidth = rcClient.right - rcClient.left;
|
||||
pScreenInfo->dwHeight = rcClient.bottom - rcClient.top;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* NOTE: For the uninitiated, the page size is the number of pixels
|
||||
* that we can display in the x or y direction at a time and the
|
||||
* range is the total number of pixels in the x or y direction that we
|
||||
* have available to display. In other words, the page size is the
|
||||
* size of the window area minus the space the caption, borders, and
|
||||
* scrollbars (if any) occupy, and the range is the size of the
|
||||
* underlying X visual. Notice that, contrary to what some of the
|
||||
* MSDN Library arcticles lead you to believe, the windows
|
||||
* ``client area'' size does not include the scrollbars. In other words,
|
||||
* the whole client area size that is reported to you is drawable by
|
||||
* you; you do not have to subtract the size of the scrollbars from
|
||||
* the client area size, and if you did it would result in the size
|
||||
* of the scrollbars being double counted.
|
||||
*/
|
||||
|
||||
/* Setup scrollbar page and range, if scrollbars are enabled */
|
||||
if (pScreenInfo->fScrollbars) {
|
||||
SCROLLINFO si;
|
||||
|
||||
/* Initialize the scrollbar info structure */
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE;
|
||||
si.nMin = 0;
|
||||
|
||||
/* Setup the width range and page size */
|
||||
si.nMax = pScreenInfo->dwWidth - 1;
|
||||
si.nPage = rcClient.right - rcClient.left;
|
||||
winDebug("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n",
|
||||
si.nMax, si.nPage);
|
||||
SetScrollInfo(*phwnd, SB_HORZ, &si, TRUE);
|
||||
|
||||
/* Setup the height range and page size */
|
||||
si.nMax = pScreenInfo->dwHeight - 1;
|
||||
si.nPage = rcClient.bottom - rcClient.top;
|
||||
winDebug("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n",
|
||||
si.nMax, si.nPage);
|
||||
SetScrollInfo(*phwnd, SB_VERT, &si, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Show the window */
|
||||
if (FALSE
|
||||
|| pScreenInfo->fMultiWindow
|
||||
) {
|
||||
pScreenPriv->fRootWindowShown = FALSE;
|
||||
ShowWindow(*phwnd, SW_HIDE);
|
||||
}
|
||||
else
|
||||
ShowWindow(*phwnd, SW_SHOWNORMAL);
|
||||
if (!UpdateWindow(*phwnd)) {
|
||||
ErrorF("winCreateBoundingWindowWindowed - UpdateWindow () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Attempt to bring our window to the top of the display */
|
||||
if (TRUE
|
||||
&& !pScreenInfo->fRootless
|
||||
&& !pScreenInfo->fMultiWindow
|
||||
) {
|
||||
if (!BringWindowToTop(*phwnd)) {
|
||||
ErrorF("winCreateBoundingWindowWindowed - BringWindowToTop () "
|
||||
"failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
winDebug("winCreateBoundingWindowWindowed - Returning\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the work area of all attached monitors
|
||||
*/
|
||||
|
||||
static Bool
|
||||
winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
|
||||
{
|
||||
int iPrimaryWidth, iPrimaryHeight;
|
||||
int iWidth, iHeight;
|
||||
int iLeft, iTop;
|
||||
int iPrimaryNonWorkAreaWidth, iPrimaryNonWorkAreaHeight;
|
||||
|
||||
/* Use GetMonitorInfo to get work area for monitor */
|
||||
if (!pScreenInfo->fMultipleMonitors) {
|
||||
MONITORINFO mi;
|
||||
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
if (GetMonitorInfo(pScreenInfo->hMonitor, &mi)) {
|
||||
*prcWorkArea = mi.rcWork;
|
||||
|
||||
winDebug("winGetWorkArea - Monitor %d WorkArea: %d %d %d %d\n",
|
||||
pScreenInfo->iMonitor,
|
||||
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
||||
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
||||
}
|
||||
else {
|
||||
ErrorF("winGetWorkArea - GetMonitorInfo() failed for monitor %d\n",
|
||||
pScreenInfo->iMonitor);
|
||||
}
|
||||
|
||||
/* Bail out here if we aren't using multiple monitors */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* SPI_GETWORKAREA only gets the work area of the primary screen. */
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, prcWorkArea, 0);
|
||||
|
||||
winDebug("winGetWorkArea - Primary Monitor WorkArea: %d %d %d %d\n",
|
||||
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
||||
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
||||
|
||||
/* Get size of full virtual screen */
|
||||
iWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
iHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
|
||||
winDebug("winGetWorkArea - Virtual screen is %d x %d\n", iWidth, iHeight);
|
||||
|
||||
/* Get origin of full virtual screen */
|
||||
iLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
iTop = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
|
||||
winDebug("winGetWorkArea - Virtual screen origin is %d, %d\n", iLeft, iTop);
|
||||
|
||||
/* Get size of primary screen */
|
||||
iPrimaryWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
iPrimaryHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
winDebug("winGetWorkArea - Primary screen is %d x %d\n",
|
||||
iPrimaryWidth, iPrimaryHeight);
|
||||
|
||||
/* Work out how much of the primary screen we aren't using */
|
||||
iPrimaryNonWorkAreaWidth = iPrimaryWidth - (prcWorkArea->right -
|
||||
prcWorkArea->left);
|
||||
iPrimaryNonWorkAreaHeight = iPrimaryHeight - (prcWorkArea->bottom
|
||||
- prcWorkArea->top);
|
||||
|
||||
/* Update the rectangle to include all monitors */
|
||||
if (iLeft < 0) {
|
||||
prcWorkArea->left = iLeft;
|
||||
}
|
||||
if (iTop < 0) {
|
||||
prcWorkArea->top = iTop;
|
||||
}
|
||||
prcWorkArea->right = prcWorkArea->left + iWidth - iPrimaryNonWorkAreaWidth;
|
||||
prcWorkArea->bottom = prcWorkArea->top + iHeight -
|
||||
iPrimaryNonWorkAreaHeight;
|
||||
|
||||
winDebug("winGetWorkArea - Adjusted WorkArea for multiple "
|
||||
"monitors: %d %d %d %d\n",
|
||||
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
||||
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
|
||||
{
|
||||
APPBARDATA abd;
|
||||
HWND hwndAutoHide;
|
||||
|
||||
ZeroMemory(&abd, sizeof(abd));
|
||||
abd.cbSize = sizeof(abd);
|
||||
abd.uEdge = uEdge;
|
||||
|
||||
hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
|
||||
if (hwndAutoHide != NULL) {
|
||||
/*
|
||||
Found an autohide taskbar on that edge, but is it on the
|
||||
same monitor as the screen window?
|
||||
*/
|
||||
if (pScreenInfo->fMultipleMonitors ||
|
||||
(MonitorFromWindow(hwndAutoHide, MONITOR_DEFAULTTONULL) ==
|
||||
pScreenInfo->hMonitor))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust the client area so that any auto-hide toolbars
|
||||
* will work correctly.
|
||||
*/
|
||||
|
||||
static Bool
|
||||
winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
|
||||
{
|
||||
APPBARDATA abd;
|
||||
|
||||
winDebug("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
|
||||
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
||||
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
||||
|
||||
/* Find out if the Windows taskbar is set to auto-hide */
|
||||
ZeroMemory(&abd, sizeof(abd));
|
||||
abd.cbSize = sizeof(abd);
|
||||
if (SHAppBarMessage(ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
|
||||
winDebug("winAdjustForAutoHide - Taskbar is auto hide\n");
|
||||
|
||||
/*
|
||||
Despite the forgoing, we are checking for any AppBar
|
||||
hiding along a monitor edge, not just the Windows TaskBar.
|
||||
*/
|
||||
|
||||
/* Look for a TOP auto-hide taskbar */
|
||||
if (winTaskbarOnScreenEdge(ABE_TOP, pScreenInfo)) {
|
||||
winDebug("winAdjustForAutoHide - Found TOP auto-hide taskbar\n");
|
||||
prcWorkArea->top += 1;
|
||||
}
|
||||
|
||||
/* Look for a LEFT auto-hide taskbar */
|
||||
if (winTaskbarOnScreenEdge(ABE_LEFT, pScreenInfo)) {
|
||||
winDebug("winAdjustForAutoHide - Found LEFT auto-hide taskbar\n");
|
||||
prcWorkArea->left += 1;
|
||||
}
|
||||
|
||||
/* Look for a BOTTOM auto-hide taskbar */
|
||||
if (winTaskbarOnScreenEdge(ABE_BOTTOM, pScreenInfo)) {
|
||||
winDebug("winAdjustForAutoHide - Found BOTTOM auto-hide taskbar\n");
|
||||
prcWorkArea->bottom -= 1;
|
||||
}
|
||||
|
||||
/* Look for a RIGHT auto-hide taskbar */
|
||||
if (winTaskbarOnScreenEdge(ABE_RIGHT, pScreenInfo)) {
|
||||
winDebug("winAdjustForAutoHide - Found RIGHT auto-hide taskbar\n");
|
||||
prcWorkArea->right -= 1;
|
||||
}
|
||||
|
||||
winDebug("winAdjustForAutoHide - Adjusted WorkArea: %d %d %d %d\n",
|
||||
(int) prcWorkArea->top, (int) prcWorkArea->left,
|
||||
(int) prcWorkArea->bottom, (int) prcWorkArea->right);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,611 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Dakshinamurthy Karra
|
||||
* Suhaib M Siddiqi
|
||||
* Peter Busch
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winmsg.h"
|
||||
#include <cursorstr.h>
|
||||
#include <mipointrst.h>
|
||||
#include <servermd.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
|
||||
|
||||
#if 0
|
||||
#define WIN_DEBUG_MSG winDebug
|
||||
#else
|
||||
#define WIN_DEBUG_MSG(...)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local function prototypes
|
||||
*/
|
||||
|
||||
static void
|
||||
winPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
|
||||
|
||||
static Bool
|
||||
winCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y);
|
||||
|
||||
static void
|
||||
winCrossScreen(ScreenPtr pScreen, Bool fEntering);
|
||||
|
||||
miPointerScreenFuncRec g_winPointerCursorFuncs = {
|
||||
winCursorOffScreen,
|
||||
winCrossScreen,
|
||||
winPointerWarpCursor
|
||||
};
|
||||
|
||||
static void
|
||||
winPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
RECT rcClient;
|
||||
static Bool s_fInitialWarp = TRUE;
|
||||
|
||||
/* Discard first warp call */
|
||||
if (s_fInitialWarp) {
|
||||
/* First warp moves mouse to center of window, just ignore it */
|
||||
|
||||
/* Don't ignore subsequent warps */
|
||||
s_fInitialWarp = FALSE;
|
||||
|
||||
winErrorFVerb(2,
|
||||
"winPointerWarpCursor - Discarding first warp: %d %d\n",
|
||||
x, y);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Only update the Windows cursor position if root window is active,
|
||||
or we are in a rootless mode
|
||||
*/
|
||||
if ((pScreenPriv->hwndScreen == GetForegroundWindow())
|
||||
|| pScreenPriv->pScreenInfo->fRootless
|
||||
|| pScreenPriv->pScreenInfo->fMultiWindow
|
||||
) {
|
||||
/* Get the client area coordinates */
|
||||
GetClientRect(pScreenPriv->hwndScreen, &rcClient);
|
||||
|
||||
/* Translate the client area coords to screen coords */
|
||||
MapWindowPoints(pScreenPriv->hwndScreen,
|
||||
HWND_DESKTOP, (LPPOINT) &rcClient, 2);
|
||||
|
||||
/*
|
||||
* Update the Windows cursor position so that we don't
|
||||
* immediately warp back to the current position.
|
||||
*/
|
||||
SetCursorPos(rcClient.left + x, rcClient.top + y);
|
||||
}
|
||||
|
||||
/* Call the mi warp procedure to do the actual warping in X. */
|
||||
miPointerWarpCursor(pDev, pScreen, x, y);
|
||||
}
|
||||
|
||||
static Bool
|
||||
winCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
winCrossScreen(ScreenPtr pScreen, Bool fEntering)
|
||||
{
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
reverse(unsigned char c)
|
||||
{
|
||||
int i;
|
||||
unsigned char ret = 0;
|
||||
|
||||
for (i = 0; i < 8; ++i) {
|
||||
ret |= ((c >> i) & 1) << (7 - i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert X cursor to Windows cursor
|
||||
* FIXME: Perhaps there are more smart code
|
||||
*/
|
||||
static HCURSOR
|
||||
winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
HCURSOR hCursor = NULL;
|
||||
unsigned char *pAnd;
|
||||
unsigned char *pXor;
|
||||
int nCX, nCY;
|
||||
int nBytes;
|
||||
double dForeY, dBackY;
|
||||
BOOL fReverse;
|
||||
HBITMAP hAnd, hXor;
|
||||
ICONINFO ii;
|
||||
unsigned char *pCur;
|
||||
unsigned char bit;
|
||||
HDC hDC;
|
||||
BITMAPV4HEADER bi;
|
||||
BITMAPINFO *pbmi;
|
||||
uint32_t *lpBits;
|
||||
|
||||
WIN_DEBUG_MSG("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
|
||||
pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
|
||||
pCursor->bits->width, pCursor->bits->height,
|
||||
pCursor->bits->xhot, pCursor->bits->yhot);
|
||||
|
||||
/* We can use only White and Black, so calc brightness of color
|
||||
* Also check if the cursor is inverted */
|
||||
dForeY = BRIGHTNESS(pCursor->fore);
|
||||
dBackY = BRIGHTNESS(pCursor->back);
|
||||
fReverse = dForeY < dBackY;
|
||||
|
||||
/* Check whether the X11 cursor is bigger than the win32 cursor */
|
||||
if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
|
||||
pScreenPriv->cursor.sm_cy < pCursor->bits->height) {
|
||||
winErrorFVerb(3,
|
||||
"winLoadCursor - Windows requires %dx%d cursor but X requires %dx%d\n",
|
||||
pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
|
||||
pCursor->bits->width, pCursor->bits->height);
|
||||
}
|
||||
|
||||
/* Get the number of bytes required to store the whole cursor image
|
||||
* This is roughly (sm_cx * sm_cy) / 8
|
||||
* round up to 8 pixel boundary so we can convert whole bytes */
|
||||
nBytes =
|
||||
bits_to_bytes(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
|
||||
|
||||
/* Get the effective width and height */
|
||||
nCX = min(pScreenPriv->cursor.sm_cx, pCursor->bits->width);
|
||||
nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
|
||||
|
||||
/* Allocate memory for the bitmaps */
|
||||
pAnd = malloc(nBytes);
|
||||
memset(pAnd, 0xFF, nBytes);
|
||||
pXor = calloc(1, nBytes);
|
||||
|
||||
/* Convert the X11 bitmap to a win32 bitmap
|
||||
* The first is for an empty mask */
|
||||
if (pCursor->bits->emptyMask) {
|
||||
int x, y, xmax = bits_to_bytes(nCX);
|
||||
|
||||
for (y = 0; y < nCY; ++y)
|
||||
for (x = 0; x < xmax; ++x) {
|
||||
int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
|
||||
int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
|
||||
|
||||
pAnd[nWinPix] = 0;
|
||||
if (fReverse)
|
||||
pXor[nWinPix] = reverse(~pCursor->bits->source[nXPix]);
|
||||
else
|
||||
pXor[nWinPix] = reverse(pCursor->bits->source[nXPix]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int x, y, xmax = bits_to_bytes(nCX);
|
||||
|
||||
for (y = 0; y < nCY; ++y)
|
||||
for (x = 0; x < xmax; ++x) {
|
||||
int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
|
||||
int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
|
||||
|
||||
unsigned char mask = pCursor->bits->mask[nXPix];
|
||||
|
||||
pAnd[nWinPix] = reverse(~mask);
|
||||
if (fReverse)
|
||||
pXor[nWinPix] =
|
||||
reverse(~pCursor->bits->source[nXPix] & mask);
|
||||
else
|
||||
pXor[nWinPix] =
|
||||
reverse(pCursor->bits->source[nXPix] & mask);
|
||||
}
|
||||
}
|
||||
|
||||
/* prepare the pointers */
|
||||
hCursor = NULL;
|
||||
lpBits = NULL;
|
||||
|
||||
/* We have a truecolor alpha-blended cursor and can use it! */
|
||||
if (pCursor->bits->argb) {
|
||||
WIN_DEBUG_MSG("winLoadCursor: Trying truecolor alphablended cursor\n");
|
||||
memset(&bi, 0, sizeof(BITMAPV4HEADER));
|
||||
bi.bV4Size = sizeof(BITMAPV4HEADER);
|
||||
bi.bV4Width = pScreenPriv->cursor.sm_cx;
|
||||
bi.bV4Height = -(pScreenPriv->cursor.sm_cy); /* right-side up */
|
||||
bi.bV4Planes = 1;
|
||||
bi.bV4BitCount = 32;
|
||||
bi.bV4V4Compression = BI_BITFIELDS;
|
||||
bi.bV4RedMask = 0x00FF0000;
|
||||
bi.bV4GreenMask = 0x0000FF00;
|
||||
bi.bV4BlueMask = 0x000000FF;
|
||||
bi.bV4AlphaMask = 0xFF000000;
|
||||
|
||||
lpBits = calloc(pScreenPriv->cursor.sm_cx * pScreenPriv->cursor.sm_cy,
|
||||
sizeof(uint32_t));
|
||||
|
||||
if (lpBits) {
|
||||
int y;
|
||||
for (y = 0; y < nCY; y++) {
|
||||
void *src, *dst;
|
||||
src = &(pCursor->bits->argb[y * pCursor->bits->width]);
|
||||
dst = &(lpBits[y * pScreenPriv->cursor.sm_cx]);
|
||||
memcpy(dst, src, 4 * nCX);
|
||||
}
|
||||
}
|
||||
} /* End if-truecolor-icon */
|
||||
|
||||
if (!lpBits) {
|
||||
RGBQUAD *pbmiColors;
|
||||
/* Bicolor, use a palettized DIB */
|
||||
WIN_DEBUG_MSG("winLoadCursor: Trying two color cursor\n");
|
||||
pbmi = (BITMAPINFO *) &bi;
|
||||
pbmiColors = &(pbmi->bmiColors[0]);
|
||||
|
||||
memset(pbmi, 0, sizeof(BITMAPINFOHEADER));
|
||||
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
|
||||
pbmi->bmiHeader.biHeight = -abs(pScreenPriv->cursor.sm_cy); /* right-side up */
|
||||
pbmi->bmiHeader.biPlanes = 1;
|
||||
pbmi->bmiHeader.biBitCount = 8;
|
||||
pbmi->bmiHeader.biCompression = BI_RGB;
|
||||
pbmi->bmiHeader.biSizeImage = 0;
|
||||
pbmi->bmiHeader.biClrUsed = 3;
|
||||
pbmi->bmiHeader.biClrImportant = 3;
|
||||
|
||||
pbmiColors[0].rgbRed = 0; /* Empty */
|
||||
pbmiColors[0].rgbGreen = 0;
|
||||
pbmiColors[0].rgbBlue = 0;
|
||||
pbmiColors[0].rgbReserved = 0;
|
||||
pbmiColors[1].rgbRed = pCursor->backRed >> 8; /* Background */
|
||||
pbmiColors[1].rgbGreen = pCursor->backGreen >> 8;
|
||||
pbmiColors[1].rgbBlue = pCursor->backBlue >> 8;
|
||||
pbmiColors[1].rgbReserved = 0;
|
||||
pbmiColors[2].rgbRed = pCursor->foreRed >> 8; /* Foreground */
|
||||
pbmiColors[2].rgbGreen = pCursor->foreGreen >> 8;
|
||||
pbmiColors[2].rgbBlue = pCursor->foreBlue >> 8;
|
||||
pbmiColors[2].rgbReserved = 0;
|
||||
|
||||
lpBits = calloc(pScreenPriv->cursor.sm_cx * pScreenPriv->cursor.sm_cy, 1);
|
||||
|
||||
pCur = (unsigned char *) lpBits;
|
||||
if (lpBits) {
|
||||
int x, y;
|
||||
for (y = 0; y < pScreenPriv->cursor.sm_cy; y++) {
|
||||
for (x = 0; x < pScreenPriv->cursor.sm_cx; x++) {
|
||||
if (x >= nCX || y >= nCY) /* Outside of X11 icon bounds */
|
||||
(*pCur++) = 0;
|
||||
else { /* Within X11 icon bounds */
|
||||
|
||||
int nWinPix =
|
||||
bits_to_bytes(pScreenPriv->cursor.sm_cx) * y +
|
||||
(x / 8);
|
||||
|
||||
bit = pAnd[nWinPix];
|
||||
bit = bit & (1 << (7 - (x & 7)));
|
||||
if (!bit) { /* Within the cursor mask? */
|
||||
int nXPix =
|
||||
BitmapBytePad(pCursor->bits->width) * y +
|
||||
(x / 8);
|
||||
bit =
|
||||
~reverse(~pCursor->bits->
|
||||
source[nXPix] & pCursor->bits->
|
||||
mask[nXPix]);
|
||||
bit = bit & (1 << (7 - (x & 7)));
|
||||
if (bit) /* Draw foreground */
|
||||
(*pCur++) = 2;
|
||||
else /* Draw background */
|
||||
(*pCur++) = 1;
|
||||
}
|
||||
else /* Outside the cursor mask */
|
||||
(*pCur++) = 0;
|
||||
}
|
||||
} /* end for (x) */
|
||||
} /* end for (y) */
|
||||
} /* end if (lpbits) */
|
||||
}
|
||||
|
||||
/* If one of the previous two methods gave us the bitmap we need, make a cursor */
|
||||
if (lpBits) {
|
||||
WIN_DEBUG_MSG("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
|
||||
pCursor->bits->xhot, pCursor->bits->yhot);
|
||||
|
||||
hAnd = NULL;
|
||||
hXor = NULL;
|
||||
|
||||
hAnd =
|
||||
CreateBitmap(pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
|
||||
1, 1, pAnd);
|
||||
|
||||
hDC = GetDC(NULL);
|
||||
if (hDC) {
|
||||
hXor =
|
||||
CreateCompatibleBitmap(hDC, pScreenPriv->cursor.sm_cx,
|
||||
pScreenPriv->cursor.sm_cy);
|
||||
SetDIBits(hDC, hXor, 0, pScreenPriv->cursor.sm_cy, lpBits,
|
||||
(BITMAPINFO *) &bi, DIB_RGB_COLORS);
|
||||
ReleaseDC(NULL, hDC);
|
||||
}
|
||||
free(lpBits);
|
||||
|
||||
if (hAnd && hXor) {
|
||||
ii.fIcon = FALSE;
|
||||
ii.xHotspot = pCursor->bits->xhot;
|
||||
ii.yHotspot = pCursor->bits->yhot;
|
||||
ii.hbmMask = hAnd;
|
||||
ii.hbmColor = hXor;
|
||||
hCursor = (HCURSOR) CreateIconIndirect(&ii);
|
||||
|
||||
if (hCursor == NULL)
|
||||
winW32Error(2, "winLoadCursor - CreateIconIndirect failed:");
|
||||
else {
|
||||
if (GetIconInfo(hCursor, &ii)) {
|
||||
if (ii.fIcon) {
|
||||
WIN_DEBUG_MSG
|
||||
("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
|
||||
|
||||
DestroyCursor(hCursor);
|
||||
|
||||
ii.fIcon = FALSE;
|
||||
ii.xHotspot = pCursor->bits->xhot;
|
||||
ii.yHotspot = pCursor->bits->yhot;
|
||||
hCursor = (HCURSOR) CreateIconIndirect(&ii);
|
||||
|
||||
if (hCursor == NULL)
|
||||
winW32Error(2,
|
||||
"winLoadCursor - CreateIconIndirect failed:");
|
||||
}
|
||||
/* GetIconInfo creates new bitmaps. Destroy them again */
|
||||
if (ii.hbmMask)
|
||||
DeleteObject(ii.hbmMask);
|
||||
if (ii.hbmColor)
|
||||
DeleteObject(ii.hbmColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hAnd)
|
||||
DeleteObject(hAnd);
|
||||
if (hXor)
|
||||
DeleteObject(hXor);
|
||||
}
|
||||
|
||||
if (!hCursor) {
|
||||
/* We couldn't make a color cursor for this screen, use
|
||||
black and white instead */
|
||||
hCursor = CreateCursor(g_hInstance,
|
||||
pCursor->bits->xhot, pCursor->bits->yhot,
|
||||
pScreenPriv->cursor.sm_cx,
|
||||
pScreenPriv->cursor.sm_cy, pAnd, pXor);
|
||||
if (hCursor == NULL)
|
||||
winW32Error(2, "winLoadCursor - CreateCursor failed:");
|
||||
}
|
||||
free(pAnd);
|
||||
free(pXor);
|
||||
|
||||
return hCursor;
|
||||
}
|
||||
|
||||
/*
|
||||
===========================================================================
|
||||
|
||||
Pointer sprite functions
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* winRealizeCursor
|
||||
* Convert the X cursor representation to native format if possible.
|
||||
*/
|
||||
static Bool
|
||||
winRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
if (pCursor == NULL || pCursor->bits == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: cache ARGB8888 representation? */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* winUnrealizeCursor
|
||||
* Free the storage space associated with a realized cursor.
|
||||
*/
|
||||
static Bool
|
||||
winUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* winSetCursor
|
||||
* Set the cursor sprite and position.
|
||||
*/
|
||||
static void
|
||||
winSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
|
||||
int y)
|
||||
{
|
||||
POINT ptCurPos, ptTemp;
|
||||
HWND hwnd;
|
||||
RECT rcClient;
|
||||
BOOL bInhibit;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
WIN_DEBUG_MSG("winSetCursor: cursor=%p\n", pCursor);
|
||||
|
||||
/* Inhibit changing the cursor if the mouse is not in a client area */
|
||||
bInhibit = FALSE;
|
||||
if (GetCursorPos(&ptCurPos)) {
|
||||
hwnd = WindowFromPoint(ptCurPos);
|
||||
if (hwnd) {
|
||||
if (GetClientRect(hwnd, &rcClient)) {
|
||||
ptTemp.x = rcClient.left;
|
||||
ptTemp.y = rcClient.top;
|
||||
if (ClientToScreen(hwnd, &ptTemp)) {
|
||||
rcClient.left = ptTemp.x;
|
||||
rcClient.top = ptTemp.y;
|
||||
ptTemp.x = rcClient.right;
|
||||
ptTemp.y = rcClient.bottom;
|
||||
if (ClientToScreen(hwnd, &ptTemp)) {
|
||||
rcClient.right = ptTemp.x;
|
||||
rcClient.bottom = ptTemp.y;
|
||||
if (!PtInRect(&rcClient, ptCurPos))
|
||||
bInhibit = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pCursor == NULL) {
|
||||
if (pScreenPriv->cursor.visible) {
|
||||
if (!bInhibit && g_fSoftwareCursor)
|
||||
ShowCursor(FALSE);
|
||||
pScreenPriv->cursor.visible = FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pScreenPriv->cursor.handle) {
|
||||
if (!bInhibit)
|
||||
SetCursor(NULL);
|
||||
DestroyCursor(pScreenPriv->cursor.handle);
|
||||
pScreenPriv->cursor.handle = NULL;
|
||||
}
|
||||
pScreenPriv->cursor.handle =
|
||||
winLoadCursor(pScreen, pCursor, pScreen->myNum);
|
||||
WIN_DEBUG_MSG("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
|
||||
|
||||
if (!bInhibit)
|
||||
SetCursor(pScreenPriv->cursor.handle);
|
||||
|
||||
if (!pScreenPriv->cursor.visible) {
|
||||
if (!bInhibit && g_fSoftwareCursor)
|
||||
ShowCursor(TRUE);
|
||||
pScreenPriv->cursor.visible = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* winMoveCursor
|
||||
* Move the cursor. This is a noop for us.
|
||||
*/
|
||||
static void
|
||||
winMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
static Bool
|
||||
winDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
|
||||
{
|
||||
winScreenPriv(pScr);
|
||||
return pScreenPriv->cursor.spriteFuncs->DeviceCursorInitialize(pDev, pScr);
|
||||
}
|
||||
|
||||
static void
|
||||
winDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
|
||||
{
|
||||
winScreenPriv(pScr);
|
||||
pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
|
||||
}
|
||||
|
||||
static miPointerSpriteFuncRec winSpriteFuncsRec = {
|
||||
winRealizeCursor,
|
||||
winUnrealizeCursor,
|
||||
winSetCursor,
|
||||
winMoveCursor,
|
||||
winDeviceCursorInitialize,
|
||||
winDeviceCursorCleanup
|
||||
};
|
||||
|
||||
/*
|
||||
===========================================================================
|
||||
|
||||
Other screen functions
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* winCursorQueryBestSize
|
||||
* Handle queries for best cursor size
|
||||
*/
|
||||
static void
|
||||
winCursorQueryBestSize(int class, unsigned short *width,
|
||||
unsigned short *height, ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
if (class == CursorShape) {
|
||||
*width = pScreenPriv->cursor.sm_cx;
|
||||
*height = pScreenPriv->cursor.sm_cy;
|
||||
}
|
||||
else {
|
||||
if (pScreenPriv->cursor.QueryBestSize)
|
||||
(*pScreenPriv->cursor.QueryBestSize) (class, width, height,
|
||||
pScreen);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* winInitCursor
|
||||
* Initialize cursor support
|
||||
*/
|
||||
Bool
|
||||
winInitCursor(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
miPointerScreenPtr pPointPriv;
|
||||
|
||||
/* override some screen procedures */
|
||||
pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
|
||||
pScreen->QueryBestSize = winCursorQueryBestSize;
|
||||
|
||||
pPointPriv = (miPointerScreenPtr)
|
||||
dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
|
||||
|
||||
pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
|
||||
pPointPriv->spriteFuncs = &winSpriteFuncsRec;
|
||||
|
||||
pScreenPriv->cursor.handle = NULL;
|
||||
pScreenPriv->cursor.visible = FALSE;
|
||||
|
||||
pScreenPriv->cursor.sm_cx = GetSystemMetrics(SM_CXCURSOR);
|
||||
pScreenPriv->cursor.sm_cy = GetSystemMetrics(SM_CYCURSOR);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,631 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Earle F. Philhower III
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include <shellapi.h>
|
||||
#include "winprefs.h"
|
||||
|
||||
/*
|
||||
* Local function prototypes
|
||||
*/
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
winChangeDepthDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
winAboutDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static void
|
||||
winDrawURLWindow(LPARAM lParam);
|
||||
|
||||
static LRESULT CALLBACK
|
||||
winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static void
|
||||
winOverrideURLButton(HWND hdlg, int id);
|
||||
|
||||
static void
|
||||
winUnoverrideURLButton(HWND hdlg, int id);
|
||||
|
||||
/*
|
||||
* Owner-draw a button as a URL
|
||||
*/
|
||||
|
||||
static void
|
||||
winDrawURLWindow(LPARAM lParam)
|
||||
{
|
||||
DRAWITEMSTRUCT *draw;
|
||||
char str[256];
|
||||
RECT rect;
|
||||
HFONT font;
|
||||
COLORREF crText;
|
||||
|
||||
draw = (DRAWITEMSTRUCT *) lParam;
|
||||
GetWindowText(draw->hwndItem, str, sizeof(str));
|
||||
str[255] = 0;
|
||||
GetClientRect(draw->hwndItem, &rect);
|
||||
|
||||
/* Color the button depending upon its state */
|
||||
if (draw->itemState & ODS_SELECTED)
|
||||
crText = RGB(128 + 64, 0, 0);
|
||||
else if (draw->itemState & ODS_FOCUS)
|
||||
crText = RGB(0, 128 + 64, 0);
|
||||
else
|
||||
crText = RGB(0, 0, 128 + 64);
|
||||
SetTextColor(draw->hDC, crText);
|
||||
|
||||
/* Create font 8 high, standard dialog font */
|
||||
font = CreateFont(-8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
|
||||
0, 0, 0, 0, 0, "MS Sans Serif");
|
||||
if (!font) {
|
||||
ErrorF("winDrawURLWindow: Unable to create URL font, bailing.\n");
|
||||
return;
|
||||
}
|
||||
/* Draw it */
|
||||
SetBkMode(draw->hDC, OPAQUE);
|
||||
SelectObject(draw->hDC, font);
|
||||
DrawText(draw->hDC, str, strlen(str), &rect, DT_LEFT | DT_VCENTER);
|
||||
/* Delete the created font, replace it with stock font */
|
||||
DeleteObject(SelectObject(draw->hDC, GetStockObject(ANSI_VAR_FONT)));
|
||||
}
|
||||
|
||||
/*
|
||||
* WndProc for overridden buttons
|
||||
*/
|
||||
|
||||
static LRESULT CALLBACK
|
||||
winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
WNDPROC origCB = NULL;
|
||||
HCURSOR cursor;
|
||||
|
||||
/* If it's a SetCursor message, tell it to the hand */
|
||||
if (msg == WM_SETCURSOR) {
|
||||
cursor = LoadCursor(NULL, IDC_HAND);
|
||||
if (cursor)
|
||||
SetCursor(cursor);
|
||||
return TRUE;
|
||||
}
|
||||
origCB = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
/* Otherwise fall through to original WndProc */
|
||||
if (origCB)
|
||||
return CallWindowProc(origCB, hwnd, msg, wParam, lParam);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register and unregister the custom WndProc
|
||||
*/
|
||||
|
||||
static void
|
||||
winOverrideURLButton(HWND hwnd, int id)
|
||||
{
|
||||
WNDPROC origCB;
|
||||
|
||||
origCB = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwnd, id),
|
||||
GWLP_WNDPROC, (LONG_PTR) winURLWndProc);
|
||||
SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_USERDATA, (LONG_PTR) origCB);
|
||||
}
|
||||
|
||||
static void
|
||||
winUnoverrideURLButton(HWND hwnd, int id)
|
||||
{
|
||||
WNDPROC origCB;
|
||||
|
||||
origCB = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_USERDATA, 0);
|
||||
if (origCB)
|
||||
SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_WNDPROC, (LONG_PTR) origCB);
|
||||
}
|
||||
|
||||
/*
|
||||
* Center a dialog window in the desktop window
|
||||
* and set small and large icons to X icons.
|
||||
*/
|
||||
|
||||
static void
|
||||
winInitDialog(HWND hwndDlg)
|
||||
{
|
||||
HWND hwndDesk;
|
||||
RECT rc, rcDlg, rcDesk;
|
||||
HICON hIcon, hIconSmall;
|
||||
|
||||
hwndDesk = GetParent(hwndDlg);
|
||||
if (!hwndDesk || IsIconic(hwndDesk))
|
||||
hwndDesk = GetDesktopWindow();
|
||||
|
||||
/* Remove minimize and maximize buttons */
|
||||
SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE)
|
||||
& ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
|
||||
|
||||
/* Set Window not to show in the task bar */
|
||||
SetWindowLongPtr(hwndDlg, GWL_EXSTYLE,
|
||||
GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);
|
||||
|
||||
/* Center dialog window in the screen. Not done for multi-monitor systems, where
|
||||
* it is likely to end up split across the screens. In that case, it appears
|
||||
* near the Tray icon.
|
||||
*/
|
||||
if (GetSystemMetrics(SM_CMONITORS) > 1) {
|
||||
/* Still need to refresh the frame change. */
|
||||
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
}
|
||||
else {
|
||||
GetWindowRect(hwndDesk, &rcDesk);
|
||||
GetWindowRect(hwndDlg, &rcDlg);
|
||||
CopyRect(&rc, &rcDesk);
|
||||
|
||||
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
|
||||
OffsetRect(&rc, -rc.left, -rc.top);
|
||||
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
|
||||
|
||||
SetWindowPos(hwndDlg,
|
||||
HWND_TOPMOST,
|
||||
rcDesk.left + (rc.right / 2),
|
||||
rcDesk.top + (rc.bottom / 2),
|
||||
0, 0, SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
if (g_hIconX)
|
||||
hIcon = g_hIconX;
|
||||
else
|
||||
hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
|
||||
|
||||
if (g_hSmallIconX)
|
||||
hIconSmall = g_hSmallIconX;
|
||||
else
|
||||
hIconSmall = LoadImage(g_hInstance,
|
||||
MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON),
|
||||
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
||||
|
||||
PostMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
|
||||
PostMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the Exit dialog box
|
||||
*/
|
||||
|
||||
void
|
||||
winDisplayExitDialog(winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
int i;
|
||||
int liveClients = 0;
|
||||
|
||||
/* Count up running clients (clients[0] is serverClient) */
|
||||
for (i = 1; i < currentMaxClients; i++)
|
||||
if (clients[i] != NullClient)
|
||||
liveClients++;
|
||||
/* Count down server internal clients */
|
||||
if (pScreenPriv->pScreenInfo->fMultiWindow)
|
||||
liveClients -= 2; /* multiwindow window manager & XMsgProc */
|
||||
if (g_fClipboardStarted)
|
||||
liveClients--; /* clipboard manager */
|
||||
|
||||
/* A user reported that this sometimes drops below zero. just eye-candy. */
|
||||
if (liveClients < 0)
|
||||
liveClients = 0;
|
||||
|
||||
/* Don't show the exit confirmation dialog if SilentExit & no clients,
|
||||
or ForceExit, is enabled */
|
||||
if ((pref.fSilentExit && liveClients <= 0) || pref.fForceExit) {
|
||||
if (g_hDlgExit != NULL) {
|
||||
DestroyWindow(g_hDlgExit);
|
||||
g_hDlgExit = NULL;
|
||||
}
|
||||
PostMessage(pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
pScreenPriv->iConnectedClients = liveClients;
|
||||
|
||||
/* Check if dialog already exists */
|
||||
if (g_hDlgExit != NULL) {
|
||||
/* Dialog box already exists, display it */
|
||||
ShowWindow(g_hDlgExit, SW_SHOWDEFAULT);
|
||||
|
||||
/* User has lost the dialog. Show them where it is. */
|
||||
SetForegroundWindow(g_hDlgExit);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create dialog box */
|
||||
g_hDlgExit = CreateDialogParam(g_hInstance,
|
||||
"EXIT_DIALOG",
|
||||
pScreenPriv->hwndScreen,
|
||||
winExitDlgProc, (LPARAM) pScreenPriv);
|
||||
|
||||
/* Show the dialog box */
|
||||
ShowWindow(g_hDlgExit, SW_SHOW);
|
||||
|
||||
/* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
|
||||
SetForegroundWindow(g_hDlgExit);
|
||||
|
||||
/* Set focus to the Cancel button */
|
||||
PostMessage(g_hDlgExit, WM_NEXTDLGCTL,
|
||||
(WPARAM) GetDlgItem(g_hDlgExit, IDCANCEL), TRUE);
|
||||
}
|
||||
|
||||
#define CONNECTED_CLIENTS_FORMAT "There %s currently %d client%s connected."
|
||||
|
||||
/*
|
||||
* Exit dialog window procedure
|
||||
*/
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static winPrivScreenPtr s_pScreenPriv = NULL;
|
||||
|
||||
/* Branch on message type */
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
char *pszConnectedClients;
|
||||
|
||||
/* Store pointers to private structures for future use */
|
||||
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
||||
|
||||
winInitDialog(hDialog);
|
||||
|
||||
/* Format the connected clients string */
|
||||
if (asprintf(&pszConnectedClients, CONNECTED_CLIENTS_FORMAT,
|
||||
(s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
|
||||
s_pScreenPriv->iConnectedClients,
|
||||
(s_pScreenPriv->iConnectedClients == 1) ? "" : "s") == -1)
|
||||
return TRUE;
|
||||
|
||||
/* Set the number of connected clients */
|
||||
SetWindowText(GetDlgItem(hDialog, IDC_CLIENTS_CONNECTED),
|
||||
pszConnectedClients);
|
||||
free(pszConnectedClients);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
/* Send message to call the GiveUp function */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
|
||||
DestroyWindow(g_hDlgExit);
|
||||
g_hDlgExit = NULL;
|
||||
|
||||
/* Fix to make sure keyboard focus isn't trapped */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
||||
return TRUE;
|
||||
|
||||
case IDCANCEL:
|
||||
DestroyWindow(g_hDlgExit);
|
||||
g_hDlgExit = NULL;
|
||||
|
||||
/* Fix to make sure keyboard focus isn't trapped */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_NCMOUSEMOVE:
|
||||
/* Show the cursor if it is hidden */
|
||||
if (g_fSoftwareCursor && !g_fCursor) {
|
||||
g_fCursor = TRUE;
|
||||
ShowCursor(TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(g_hDlgExit);
|
||||
g_hDlgExit = NULL;
|
||||
|
||||
/* Fix to make sure keyboard focus isn't trapped */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the Depth Change dialog box
|
||||
*/
|
||||
|
||||
void
|
||||
winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
/* Check if dialog already exists */
|
||||
if (g_hDlgDepthChange != NULL) {
|
||||
/* Dialog box already exists, display it */
|
||||
ShowWindow(g_hDlgDepthChange, SW_SHOWDEFAULT);
|
||||
|
||||
/* User has lost the dialog. Show them where it is. */
|
||||
SetForegroundWindow(g_hDlgDepthChange);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display a notification to the user that the visual
|
||||
* will not be displayed until the Windows display depth
|
||||
* is restored to the original value.
|
||||
*/
|
||||
g_hDlgDepthChange = CreateDialogParam(g_hInstance,
|
||||
"DEPTH_CHANGE_BOX",
|
||||
pScreenPriv->hwndScreen,
|
||||
winChangeDepthDlgProc,
|
||||
(LPARAM) pScreenPriv);
|
||||
/* Show the dialog box */
|
||||
ShowWindow(g_hDlgDepthChange, SW_SHOW);
|
||||
|
||||
if (!g_hDlgDepthChange)
|
||||
ErrorF("winDisplayDepthChangeDialog - GetLastError: %d\n",
|
||||
(int) GetLastError());
|
||||
|
||||
/* Minimize the display window */
|
||||
ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process messages for the dialog that is displayed for
|
||||
* disruptive screen depth changes.
|
||||
*/
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
winChangeDepthDlgProc(HWND hwndDialog, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static winPrivScreenPtr s_pScreenPriv = NULL;
|
||||
static winScreenInfo *s_pScreenInfo = NULL;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winChangeDepthDlgProc\n");
|
||||
#endif
|
||||
|
||||
/* Branch on message type */
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
#if CYGDEBUG
|
||||
winDebug("winChangeDepthDlgProc - WM_INITDIALOG\n");
|
||||
#endif
|
||||
|
||||
/* Store pointers to private structures for future use */
|
||||
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
||||
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %p, "
|
||||
"s_pScreenInfo: %p\n",
|
||||
s_pScreenPriv, s_pScreenInfo);
|
||||
#endif
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %u, "
|
||||
"current bpp: %d\n",
|
||||
(unsigned int)s_pScreenInfo->dwBPP,
|
||||
GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
|
||||
#endif
|
||||
|
||||
winInitDialog(hwndDialog);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case WM_DISPLAYCHANGE:
|
||||
#if CYGDEBUG
|
||||
winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %u, "
|
||||
"new bpp: %d\n",
|
||||
(unsigned int)s_pScreenInfo->dwBPP,
|
||||
GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
|
||||
#endif
|
||||
|
||||
/* Dismiss the dialog if the display returns to the original depth */
|
||||
if (GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL) ==
|
||||
s_pScreenInfo->dwBPP) {
|
||||
ErrorF("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
|
||||
|
||||
/* Depth has been restored, dismiss dialog */
|
||||
DestroyWindow(g_hDlgDepthChange);
|
||||
g_hDlgDepthChange = NULL;
|
||||
|
||||
/* Flag that we have a valid screen depth */
|
||||
s_pScreenPriv->fBadDepth = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
winDebug("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
|
||||
|
||||
/*
|
||||
* User dismissed the dialog, hide it until the
|
||||
* display mode is restored.
|
||||
*/
|
||||
ShowWindow(g_hDlgDepthChange, SW_HIDE);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
winDebug("winChangeDepthDlgProc - WM_CLOSE\n");
|
||||
|
||||
DestroyWindow(g_hDlgAbout);
|
||||
g_hDlgAbout = NULL;
|
||||
|
||||
/* Fix to make sure keyboard focus isn't trapped */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the About dialog box
|
||||
*/
|
||||
|
||||
void
|
||||
winDisplayAboutDialog(winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
/* Check if dialog already exists */
|
||||
if (g_hDlgAbout != NULL) {
|
||||
/* Dialog box already exists, display it */
|
||||
ShowWindow(g_hDlgAbout, SW_SHOWDEFAULT);
|
||||
|
||||
/* User has lost the dialog. Show them where it is. */
|
||||
SetForegroundWindow(g_hDlgAbout);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the about box
|
||||
*/
|
||||
g_hDlgAbout = CreateDialogParam(g_hInstance,
|
||||
"ABOUT_BOX",
|
||||
pScreenPriv->hwndScreen,
|
||||
winAboutDlgProc, (LPARAM) pScreenPriv);
|
||||
|
||||
/* Show the dialog box */
|
||||
ShowWindow(g_hDlgAbout, SW_SHOW);
|
||||
|
||||
/* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
|
||||
SetForegroundWindow(g_hDlgAbout);
|
||||
|
||||
/* Set focus to the OK button */
|
||||
PostMessage(g_hDlgAbout, WM_NEXTDLGCTL,
|
||||
(WPARAM) GetDlgItem(g_hDlgAbout, IDOK), TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process messages for the about dialog.
|
||||
*/
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static winPrivScreenPtr s_pScreenPriv = NULL;
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winAboutDlgProc\n");
|
||||
#endif
|
||||
|
||||
/* Branch on message type */
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
#if CYGDEBUG
|
||||
winDebug("winAboutDlgProc - WM_INITDIALOG\n");
|
||||
#endif
|
||||
|
||||
/* Store pointer to private structure for future use */
|
||||
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
||||
|
||||
winInitDialog(hwndDialog);
|
||||
|
||||
/* Override the URL buttons */
|
||||
winOverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case WM_DRAWITEM:
|
||||
/* Draw the URL buttons as needed */
|
||||
winDrawURLWindow(lParam);
|
||||
return TRUE;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_NCMOUSEMOVE:
|
||||
/* Show the cursor if it is hidden */
|
||||
if (g_fSoftwareCursor && !g_fCursor) {
|
||||
g_fCursor = TRUE;
|
||||
ShowCursor(TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
winDebug("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
|
||||
|
||||
DestroyWindow(g_hDlgAbout);
|
||||
g_hDlgAbout = NULL;
|
||||
|
||||
/* Fix to make sure keyboard focus isn't trapped */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
||||
|
||||
/* Restore window procedures for URL buttons */
|
||||
winUnoverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case ID_ABOUT_WEBSITE:
|
||||
{
|
||||
const char *pszPath = __VENDORDWEBSUPPORT__;
|
||||
INT_PTR iReturn;
|
||||
|
||||
iReturn = (INT_PTR) ShellExecute(NULL,
|
||||
"open",
|
||||
pszPath, NULL, NULL, SW_MAXIMIZE);
|
||||
if (iReturn < 32) {
|
||||
ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
|
||||
"ShellExecute failed: %d\n", (int)iReturn);
|
||||
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
winDebug("winAboutDlgProc - WM_CLOSE\n");
|
||||
|
||||
DestroyWindow(g_hDlgAbout);
|
||||
g_hDlgAbout = NULL;
|
||||
|
||||
/* Fix to make sure keyboard focus isn't trapped */
|
||||
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
||||
|
||||
/* Restore window procedures for URL buttons */
|
||||
winUnoverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* File: windisplay.c
|
||||
* Purpose: Retrieve server display name
|
||||
*
|
||||
* Copyright (C) Jon TURNEY 2009
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <opaque.h> // for display
|
||||
#include "windisplay.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
#define XSERV_t
|
||||
#define TRANS_SERVER
|
||||
#include <X11/Xtrans/Xtrans.h>
|
||||
|
||||
/*
|
||||
Generate a display name string referring to the display of this server,
|
||||
using a transport we know is enabled
|
||||
*/
|
||||
|
||||
void
|
||||
winGetDisplayName(char *szDisplay, unsigned int screen)
|
||||
{
|
||||
if (_XSERVTransIsListening("local")) {
|
||||
snprintf(szDisplay, 512, ":%s.%d", display, screen);
|
||||
}
|
||||
else if (_XSERVTransIsListening("inet")) {
|
||||
snprintf(szDisplay, 512, "127.0.0.1:%s.%d", display, screen);
|
||||
}
|
||||
else if (_XSERVTransIsListening("inet6")) {
|
||||
snprintf(szDisplay, 512, "::1:%s.%d", display, screen);
|
||||
}
|
||||
else {
|
||||
// this can't happen!
|
||||
ErrorF("winGetDisplay: Don't know what to use for DISPLAY\n");
|
||||
snprintf(szDisplay, 512, "localhost:%s.%d", display, screen);
|
||||
}
|
||||
|
||||
winDebug("winGetDisplay: DISPLAY=%s\n", szDisplay);
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* File: windisplay.h
|
||||
* Purpose: Interface to retrieve server display name
|
||||
*
|
||||
* Copyright (C) Jon TURNEY 2009
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WINDISPLAY_H
|
||||
#define WINDISPLAY_H
|
||||
|
||||
void
|
||||
winGetDisplayName(char *szDisplay, unsigned int screen);
|
||||
|
||||
#endif /* !WINDISPLAY_H */
|
|
@ -1,263 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
/*
|
||||
* Global variables for function pointers into
|
||||
* dynamically loaded libraries
|
||||
*/
|
||||
FARPROC g_fpDirectDrawCreate = NULL;
|
||||
FARPROC g_fpDirectDrawCreateClipper = NULL;
|
||||
|
||||
/*
|
||||
module handle for dynamically loaded directdraw library
|
||||
*/
|
||||
static HMODULE g_hmodDirectDraw = NULL;
|
||||
|
||||
/*
|
||||
* Detect engines supported by current Windows version
|
||||
* DirectDraw version and hardware
|
||||
*/
|
||||
|
||||
void
|
||||
winDetectSupportedEngines(void)
|
||||
{
|
||||
/* Initialize the engine support flags */
|
||||
g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
|
||||
|
||||
/* Do we have DirectDraw? */
|
||||
if (g_hmodDirectDraw != NULL) {
|
||||
LPDIRECTDRAW lpdd = NULL;
|
||||
LPDIRECTDRAW4 lpdd4 = NULL;
|
||||
HRESULT ddrval;
|
||||
|
||||
/* Was the DirectDrawCreate function found? */
|
||||
if (g_fpDirectDrawCreate == NULL) {
|
||||
/* No DirectDraw support */
|
||||
return;
|
||||
}
|
||||
|
||||
/* DirectDrawCreate exists, try to call it */
|
||||
/* Create a DirectDraw object, store the address at lpdd */
|
||||
ddrval = (*g_fpDirectDrawCreate) (NULL, (void **) &lpdd, NULL);
|
||||
if (FAILED(ddrval)) {
|
||||
/* No DirectDraw support */
|
||||
winErrorFVerb(2,
|
||||
"winDetectSupportedEngines - DirectDraw not installed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Try to query for DirectDraw4 interface */
|
||||
ddrval = IDirectDraw_QueryInterface(lpdd,
|
||||
&IID_IDirectDraw4,
|
||||
(LPVOID *) &lpdd4);
|
||||
if (SUCCEEDED(ddrval)) {
|
||||
/* We have DirectDraw4 */
|
||||
winErrorFVerb(2,
|
||||
"winDetectSupportedEngines - DirectDraw4 installed, allowing ShadowDDNL\n");
|
||||
g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
|
||||
}
|
||||
|
||||
/* Cleanup DirectDraw interfaces */
|
||||
if (lpdd4 != NULL)
|
||||
IDirectDraw_Release(lpdd4);
|
||||
if (lpdd != NULL)
|
||||
IDirectDraw_Release(lpdd);
|
||||
}
|
||||
|
||||
winErrorFVerb(2,
|
||||
"winDetectSupportedEngines - Returning, supported engines %08x\n",
|
||||
(unsigned int) g_dwEnginesSupported);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the engine type, depending on the engines
|
||||
* supported for this screen, and whether the user
|
||||
* suggested an engine type
|
||||
*/
|
||||
|
||||
Bool
|
||||
winSetEngine(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
HDC hdc;
|
||||
DWORD dwBPP;
|
||||
|
||||
/* Get a DC */
|
||||
hdc = GetDC(NULL);
|
||||
if (hdc == NULL) {
|
||||
ErrorF("winSetEngine - Couldn't get an HDC\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* pScreenInfo->dwBPP may be 0 to indicate that the current screen
|
||||
* depth is to be used. Thus, we must query for the current display
|
||||
* depth here.
|
||||
*/
|
||||
dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
|
||||
|
||||
/* Release the DC */
|
||||
ReleaseDC(NULL, hdc);
|
||||
hdc = NULL;
|
||||
|
||||
/* ShadowGDI is the only engine that supports windowed PseudoColor */
|
||||
if (dwBPP == 8 && !pScreenInfo->fFullScreen) {
|
||||
winErrorFVerb(2,
|
||||
"winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
|
||||
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
|
||||
|
||||
/* Set engine function pointers */
|
||||
winSetEngineFunctionsShadowGDI(pScreen);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ShadowGDI is the only engine that supports Multi Window Mode */
|
||||
if (FALSE
|
||||
|| pScreenInfo->fMultiWindow
|
||||
) {
|
||||
winErrorFVerb(2,
|
||||
"winSetEngine - Multi Window or Rootless => ShadowGDI\n");
|
||||
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
|
||||
|
||||
/* Set engine function pointers */
|
||||
winSetEngineFunctionsShadowGDI(pScreen);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* If the user's choice is supported, we'll use that */
|
||||
if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred) {
|
||||
winErrorFVerb(2, "winSetEngine - Using user's preference: %d\n",
|
||||
(int) pScreenInfo->dwEnginePreferred);
|
||||
pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
|
||||
|
||||
/* Setup engine function pointers */
|
||||
switch (pScreenInfo->dwEngine) {
|
||||
case WIN_SERVER_SHADOW_GDI:
|
||||
winSetEngineFunctionsShadowGDI(pScreen);
|
||||
break;
|
||||
case WIN_SERVER_SHADOW_DDNL:
|
||||
winSetEngineFunctionsShadowDDNL(pScreen);
|
||||
break;
|
||||
default:
|
||||
FatalError("winSetEngine - Invalid engine type\n");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ShadowDDNL has good performance, so why not */
|
||||
if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL) {
|
||||
winErrorFVerb(2, "winSetEngine - Using Shadow DirectDraw NonLocking\n");
|
||||
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
|
||||
|
||||
/* Set engine function pointers */
|
||||
winSetEngineFunctionsShadowDDNL(pScreen);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ShadowGDI is next in line */
|
||||
if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI) {
|
||||
winErrorFVerb(2, "winSetEngine - Using Shadow GDI DIB\n");
|
||||
pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
|
||||
|
||||
/* Set engine function pointers */
|
||||
winSetEngineFunctionsShadowGDI(pScreen);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper
|
||||
*/
|
||||
|
||||
Bool
|
||||
winGetDDProcAddresses(void)
|
||||
{
|
||||
Bool fReturn = TRUE;
|
||||
|
||||
/* Load the DirectDraw library */
|
||||
g_hmodDirectDraw = LoadLibraryEx("ddraw.dll", NULL, 0);
|
||||
if (g_hmodDirectDraw == NULL) {
|
||||
ErrorF("winGetDDProcAddresses - Could not load ddraw.dll\n");
|
||||
fReturn = TRUE;
|
||||
goto winGetDDProcAddresses_Exit;
|
||||
}
|
||||
|
||||
/* Try to get the DirectDrawCreate address */
|
||||
g_fpDirectDrawCreate = GetProcAddress(g_hmodDirectDraw, "DirectDrawCreate");
|
||||
if (g_fpDirectDrawCreate == NULL) {
|
||||
ErrorF("winGetDDProcAddresses - Could not get DirectDrawCreate "
|
||||
"address\n");
|
||||
fReturn = TRUE;
|
||||
goto winGetDDProcAddresses_Exit;
|
||||
}
|
||||
|
||||
/* Try to get the DirectDrawCreateClipper address */
|
||||
g_fpDirectDrawCreateClipper = GetProcAddress(g_hmodDirectDraw,
|
||||
"DirectDrawCreateClipper");
|
||||
if (g_fpDirectDrawCreateClipper == NULL) {
|
||||
ErrorF("winGetDDProcAddresses - Could not get "
|
||||
"DirectDrawCreateClipper address\n");
|
||||
fReturn = FALSE;
|
||||
goto winGetDDProcAddresses_Exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: Do not unload ddraw.dll here. Do it in GiveUp
|
||||
*/
|
||||
|
||||
winGetDDProcAddresses_Exit:
|
||||
/* Unload the DirectDraw library if we failed to initialize */
|
||||
if (!fReturn && g_hmodDirectDraw != NULL) {
|
||||
FreeLibrary(g_hmodDirectDraw);
|
||||
g_hmodDirectDraw = NULL;
|
||||
}
|
||||
|
||||
return fReturn;
|
||||
}
|
||||
|
||||
void
|
||||
winReleaseDDProcAddresses(void)
|
||||
{
|
||||
if (g_hmodDirectDraw != NULL) {
|
||||
FreeLibrary(g_hmodDirectDraw);
|
||||
g_hmodDirectDraw = NULL;
|
||||
g_fpDirectDrawCreate = NULL;
|
||||
g_fpDirectDrawCreateClipper = NULL;
|
||||
}
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <../xfree86/common/xorgVersion.h>
|
||||
#include "win.h"
|
||||
|
||||
#ifdef DDXOSVERRORF
|
||||
void
|
||||
OsVendorVErrorF(const char *pszFormat, va_list va_args)
|
||||
{
|
||||
/* make sure the clipboard and multiwindow threads do not interfere the
|
||||
* main thread */
|
||||
static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* Lock the printing mutex */
|
||||
pthread_mutex_lock(&s_pmPrinting);
|
||||
|
||||
/* Print the error message to a log file, could be stderr */
|
||||
LogVWrite(0, pszFormat, va_args);
|
||||
|
||||
/* Unlock the printing mutex */
|
||||
pthread_mutex_unlock(&s_pmPrinting);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* os/log.c:FatalError () calls our vendor ErrorF, so the message
|
||||
* from a FatalError will be logged.
|
||||
*
|
||||
* Attempt to do last-ditch, safe, important cleanup here.
|
||||
*/
|
||||
void
|
||||
OsVendorFatalError(const char *f, va_list args)
|
||||
{
|
||||
char errormsg[1024] = "";
|
||||
|
||||
/* Don't give duplicate warning if UseMsg was called */
|
||||
if (g_fSilentFatalError)
|
||||
return;
|
||||
|
||||
if (!g_fLogInited) {
|
||||
g_fLogInited = TRUE;
|
||||
g_pszLogFile = LogInit(g_pszLogFile, ".old");
|
||||
}
|
||||
LogClose(EXIT_ERR_ABORT);
|
||||
|
||||
/* Format the error message */
|
||||
vsnprintf(errormsg, sizeof(errormsg), f, args);
|
||||
|
||||
/*
|
||||
Sometimes the error message needs a bit of cosmetic cleaning
|
||||
up for use in a dialog box...
|
||||
*/
|
||||
{
|
||||
char *s;
|
||||
|
||||
while ((s = strstr(errormsg, "\n\t")) != NULL) {
|
||||
s[0] = ' ';
|
||||
s[1] = '\n';
|
||||
}
|
||||
}
|
||||
|
||||
winMessageBoxF("A fatal error has occurred and " PROJECT_NAME " will now exit.\n\n"
|
||||
"%s\n\n"
|
||||
"Please open %s for more information.\n",
|
||||
MB_ICONERROR,
|
||||
errormsg,
|
||||
(g_pszLogFile ? g_pszLogFile : "the logfile"));
|
||||
}
|
||||
|
||||
/*
|
||||
* winMessageBoxF - Print a formatted error message in a useful
|
||||
* message box.
|
||||
*/
|
||||
|
||||
void
|
||||
winMessageBoxF(const char *pszError, UINT uType, ...)
|
||||
{
|
||||
char *pszErrorF = NULL;
|
||||
char *pszMsgBox = NULL;
|
||||
va_list args;
|
||||
int size;
|
||||
|
||||
va_start(args, uType);
|
||||
size = vasprintf(&pszErrorF, pszError, args);
|
||||
va_end(args);
|
||||
if (size == -1) {
|
||||
pszErrorF = NULL;
|
||||
goto winMessageBoxF_Cleanup;
|
||||
}
|
||||
|
||||
#define MESSAGEBOXF \
|
||||
"%s\n" \
|
||||
"Vendor: %s\n" \
|
||||
"Release: %d.%d.%d.%d\n" \
|
||||
"Contact: %s\n" \
|
||||
"%s\n\n" \
|
||||
"XWin was started with the following command-line:\n\n" \
|
||||
"%s\n"
|
||||
|
||||
size = asprintf(&pszMsgBox, MESSAGEBOXF,
|
||||
pszErrorF, XVENDORNAME,
|
||||
XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH,
|
||||
XORG_VERSION_SNAP,
|
||||
BUILDERADDR, BUILDERSTRING, g_pszCommandLine);
|
||||
|
||||
if (size == -1) {
|
||||
pszMsgBox = NULL;
|
||||
goto winMessageBoxF_Cleanup;
|
||||
}
|
||||
|
||||
/* Display the message box string */
|
||||
MessageBox(NULL, pszMsgBox, PROJECT_NAME, MB_OK | uType);
|
||||
|
||||
winMessageBoxF_Cleanup:
|
||||
free(pszErrorF);
|
||||
free(pszMsgBox);
|
||||
#undef MESSAGEBOXF
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* General global variables
|
||||
*/
|
||||
|
||||
int g_iNumScreens = 0;
|
||||
winScreenInfo *g_ScreenInfo = 0;
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
int g_fdMessageQueue = WIN_FD_INVALID;
|
||||
#endif
|
||||
DevPrivateKeyRec g_iScreenPrivateKeyRec;
|
||||
DevPrivateKeyRec g_iCmapPrivateKeyRec;
|
||||
DevPrivateKeyRec g_iGCPrivateKeyRec;
|
||||
DevPrivateKeyRec g_iPixmapPrivateKeyRec;
|
||||
DevPrivateKeyRec g_iWindowPrivateKeyRec;
|
||||
unsigned long g_ulServerGeneration = 0;
|
||||
DWORD g_dwEnginesSupported = 0;
|
||||
HINSTANCE g_hInstance = 0;
|
||||
HWND g_hDlgDepthChange = NULL;
|
||||
HWND g_hDlgExit = NULL;
|
||||
HWND g_hDlgAbout = NULL;
|
||||
const char *g_pszQueryHost = NULL;
|
||||
Bool g_fXdmcpEnabled = FALSE;
|
||||
Bool g_fAuthEnabled = FALSE;
|
||||
Bool g_fCompositeAlpha = FALSE;
|
||||
HICON g_hIconX = NULL;
|
||||
HICON g_hSmallIconX = NULL;
|
||||
|
||||
#ifndef RELOCATE_PROJECTROOT
|
||||
const char *g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log";
|
||||
#else
|
||||
const char *g_pszLogFile = "XWin.log";
|
||||
Bool g_fLogFileChanged = FALSE;
|
||||
#endif
|
||||
int g_iLogVerbose = 2;
|
||||
Bool g_fLogInited = FALSE;
|
||||
char *g_pszCommandLine = NULL;
|
||||
Bool g_fSilentFatalError = FALSE;
|
||||
DWORD g_dwCurrentThreadID = 0;
|
||||
Bool g_fKeyboardHookLL = FALSE;
|
||||
Bool g_fNoHelpMessageBox = FALSE;
|
||||
Bool g_fSoftwareCursor = FALSE;
|
||||
Bool g_fNativeGl = TRUE;
|
||||
Bool g_fHostInTitle = TRUE;
|
||||
pthread_mutex_t g_pmTerminating = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/*
|
||||
* Wrapped DIX functions
|
||||
*/
|
||||
winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
|
||||
|
||||
/*
|
||||
* Clipboard variables
|
||||
*/
|
||||
|
||||
Bool g_fClipboard = TRUE;
|
||||
Bool g_fClipboardStarted = FALSE;
|
||||
|
||||
/*
|
||||
* Re-initialize global variables that are invalidated
|
||||
* by a server reset.
|
||||
*/
|
||||
|
||||
void
|
||||
winInitializeGlobals(void)
|
||||
{
|
||||
g_dwCurrentThreadID = GetCurrentThreadId();
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
File: winglobals.h
|
||||
Purpose: declarations for global variables
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef WINGLOBALS_H
|
||||
#define WINGLOBALS_H
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/*
|
||||
* References to external symbols
|
||||
*/
|
||||
|
||||
extern int g_iNumScreens;
|
||||
extern int g_iLastScreen;
|
||||
extern char *g_pszCommandLine;
|
||||
extern Bool g_fSilentFatalError;
|
||||
extern const char *g_pszLogFile;
|
||||
|
||||
#ifdef RELOCATE_PROJECTROOT
|
||||
extern Bool g_fLogFileChanged;
|
||||
#endif
|
||||
extern int g_iLogVerbose;
|
||||
extern Bool g_fLogInited;
|
||||
|
||||
extern Bool g_fAuthEnabled;
|
||||
extern Bool g_fXdmcpEnabled;
|
||||
extern Bool g_fCompositeAlpha;
|
||||
|
||||
extern Bool g_fNoHelpMessageBox;
|
||||
extern Bool g_fNativeGl;
|
||||
extern Bool g_fHostInTitle;
|
||||
|
||||
extern HWND g_hDlgDepthChange;
|
||||
extern HWND g_hDlgExit;
|
||||
extern HWND g_hDlgAbout;
|
||||
|
||||
extern Bool g_fSoftwareCursor;
|
||||
extern Bool g_fCursor;
|
||||
|
||||
/* Typedef for DIX wrapper functions */
|
||||
typedef int (*winDispatchProcPtr) (ClientPtr);
|
||||
|
||||
/*
|
||||
* Wrapped DIX functions
|
||||
*/
|
||||
extern winDispatchProcPtr winProcEstablishConnectionOrig;
|
||||
extern Bool g_fClipboard;
|
||||
extern Bool g_fClipboardStarted;
|
||||
|
||||
/* The global X default icons */
|
||||
extern HICON g_hIconX;
|
||||
extern HICON g_hSmallIconX;
|
||||
|
||||
extern DWORD g_dwCurrentThreadID;
|
||||
|
||||
extern Bool g_fKeyboardHookLL;
|
||||
extern Bool g_fButton[3];
|
||||
|
||||
extern pthread_mutex_t g_pmTerminating;
|
||||
|
||||
#endif /* WINGLOBALS_H */
|
|
@ -1,545 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Dakshinamurthy Karra
|
||||
* Suhaib M Siddiqi
|
||||
* Peter Busch
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winkeybd.h"
|
||||
#include "winconfig.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
#include "xkbsrv.h"
|
||||
|
||||
/* C does not have a logical XOR operator, so we use a macro instead */
|
||||
#define LOGICAL_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
|
||||
|
||||
static Bool g_winKeyState[NUM_KEYCODES];
|
||||
|
||||
/*
|
||||
* Local prototypes
|
||||
*/
|
||||
|
||||
static void
|
||||
winKeybdBell(int iPercent, DeviceIntPtr pDeviceInt, void *pCtrl, int iClass);
|
||||
|
||||
static void
|
||||
winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl);
|
||||
|
||||
/*
|
||||
* Translate a Windows WM_[SYS]KEY(UP/DOWN) message
|
||||
* into an ASCII scan code.
|
||||
*
|
||||
* We do this ourselves, rather than letting Windows handle it,
|
||||
* because Windows tends to munge the handling of special keys,
|
||||
* like AltGr on European keyboards.
|
||||
*/
|
||||
|
||||
int
|
||||
winTranslateKey(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
|
||||
int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
|
||||
int iParam = HIWORD(lParam);
|
||||
int iParamScanCode = LOBYTE(iParam);
|
||||
int iScanCode;
|
||||
|
||||
winDebug("winTranslateKey: wParam %08x lParam %08x\n", (int)wParam, (int)lParam);
|
||||
|
||||
/* WM_ key messages faked by Vista speech recognition (WSR) don't have a
|
||||
* scan code.
|
||||
*
|
||||
* Vocola 3 (Rick Mohr's supplement to WSR) uses
|
||||
* System.Windows.Forms.SendKeys.SendWait(), which appears always to give a
|
||||
* scan code of 1
|
||||
*/
|
||||
if (iParamScanCode <= 1) {
|
||||
if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
|
||||
/* Trigger special case table to translate to extended
|
||||
* keycode, otherwise if num_lock is on, we can get keypad
|
||||
* numbers instead of navigation keys. */
|
||||
iParam |= KF_EXTENDED;
|
||||
else
|
||||
iParamScanCode = MapVirtualKeyEx(wParam,
|
||||
/*MAPVK_VK_TO_VSC */ 0,
|
||||
GetKeyboardLayout(0));
|
||||
}
|
||||
|
||||
/* Branch on special extended, special non-extended, or normal key */
|
||||
if ((iParam & KF_EXTENDED) && iKeyFixupEx)
|
||||
iScanCode = iKeyFixupEx;
|
||||
else if (iKeyFixup)
|
||||
iScanCode = iKeyFixup;
|
||||
else if (wParam == 0 && iParamScanCode == 0x70)
|
||||
iScanCode = KEY_HKTG;
|
||||
else
|
||||
switch (iParamScanCode) {
|
||||
case 0x70:
|
||||
iScanCode = KEY_HKTG;
|
||||
break;
|
||||
case 0x73:
|
||||
iScanCode = KEY_BSlash2;
|
||||
break;
|
||||
default:
|
||||
iScanCode = iParamScanCode;
|
||||
break;
|
||||
}
|
||||
|
||||
return iScanCode;
|
||||
}
|
||||
|
||||
/* Ring the keyboard bell (system speaker on PCs) */
|
||||
static void
|
||||
winKeybdBell(int iPercent, DeviceIntPtr pDeviceInt, void *pCtrl, int iClass)
|
||||
{
|
||||
/*
|
||||
* We can't use Beep () here because it uses the PC speaker
|
||||
* on NT/2000. MessageBeep (MB_OK) will play the default system
|
||||
* sound on systems with a sound card or it will beep the PC speaker
|
||||
* on systems that do not have a sound card.
|
||||
*/
|
||||
if (iPercent > 0) MessageBeep(MB_OK);
|
||||
}
|
||||
|
||||
/* Change some keyboard configuration parameters */
|
||||
static void
|
||||
winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* See Porting Layer Definition - p. 18
|
||||
* winKeybdProc is known as a DeviceProc.
|
||||
*/
|
||||
|
||||
int
|
||||
winKeybdProc(DeviceIntPtr pDeviceInt, int iState)
|
||||
{
|
||||
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
||||
XkbSrvInfoPtr xkbi;
|
||||
XkbControlsPtr ctrl;
|
||||
|
||||
switch (iState) {
|
||||
case DEVICE_INIT:
|
||||
winConfigKeyboard(pDeviceInt);
|
||||
|
||||
/* FIXME: Maybe we should use winGetKbdLeds () here? */
|
||||
defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
|
||||
|
||||
winErrorFVerb(2, "Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
|
||||
" Variant = \"%s\" Options = \"%s\"\n",
|
||||
g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none",
|
||||
g_winInfo.xkb.model ? g_winInfo.xkb.model : "none",
|
||||
g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none",
|
||||
g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none",
|
||||
g_winInfo.xkb.options ? g_winInfo.xkb.options : "none");
|
||||
|
||||
InitKeyboardDeviceStruct(pDeviceInt,
|
||||
&g_winInfo.xkb, winKeybdBell, winKeybdCtrl);
|
||||
|
||||
xkbi = pDeviceInt->key->xkbInfo;
|
||||
if ((xkbi != NULL) && (xkbi->desc != NULL)) {
|
||||
ctrl = xkbi->desc->ctrls;
|
||||
ctrl->repeat_delay = g_winInfo.keyboard.delay;
|
||||
ctrl->repeat_interval = 1000 / g_winInfo.keyboard.rate;
|
||||
}
|
||||
else {
|
||||
winErrorFVerb(1,
|
||||
"winKeybdProc - Error initializing keyboard AutoRepeat\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DEVICE_ON:
|
||||
pDevice->on = TRUE;
|
||||
|
||||
// immediately copy the state of this keyboard device to the VCK
|
||||
// (which otherwise happens lazily after the first keypress)
|
||||
CopyKeyClass(pDeviceInt, inputInfo.keyboard);
|
||||
break;
|
||||
|
||||
case DEVICE_CLOSE:
|
||||
case DEVICE_OFF:
|
||||
pDevice->on = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect current mode key states upon server startup.
|
||||
*
|
||||
* Simulate a press and release of any key that is currently
|
||||
* toggled.
|
||||
*/
|
||||
|
||||
void
|
||||
winInitializeModeKeyStates(void)
|
||||
{
|
||||
/* Restore NumLock */
|
||||
if (GetKeyState(VK_NUMLOCK) & 0x0001) {
|
||||
winSendKeyEvent(KEY_NumLock, TRUE);
|
||||
winSendKeyEvent(KEY_NumLock, FALSE);
|
||||
}
|
||||
|
||||
/* Restore CapsLock */
|
||||
if (GetKeyState(VK_CAPITAL) & 0x0001) {
|
||||
winSendKeyEvent(KEY_CapsLock, TRUE);
|
||||
winSendKeyEvent(KEY_CapsLock, FALSE);
|
||||
}
|
||||
|
||||
/* Restore ScrollLock */
|
||||
if (GetKeyState(VK_SCROLL) & 0x0001) {
|
||||
winSendKeyEvent(KEY_ScrollLock, TRUE);
|
||||
winSendKeyEvent(KEY_ScrollLock, FALSE);
|
||||
}
|
||||
|
||||
/* Restore KanaLock */
|
||||
if (GetKeyState(VK_KANA) & 0x0001) {
|
||||
winSendKeyEvent(KEY_HKTG, TRUE);
|
||||
winSendKeyEvent(KEY_HKTG, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Upon regaining the keyboard focus we must
|
||||
* resynchronize our internal mode key states
|
||||
* with the actual state of the keys.
|
||||
*/
|
||||
|
||||
void
|
||||
winRestoreModeKeyStates(void)
|
||||
{
|
||||
DWORD dwKeyState;
|
||||
BOOL processEvents = TRUE;
|
||||
unsigned short internalKeyStates;
|
||||
|
||||
/* X server is being initialized */
|
||||
if (!inputInfo.keyboard || !inputInfo.keyboard->key)
|
||||
return;
|
||||
|
||||
/* Only process events if the rootwindow is mapped. The keyboard events
|
||||
* will cause segfaults otherwise */
|
||||
if (screenInfo.screens[0]->root &&
|
||||
screenInfo.screens[0]->root->mapped == FALSE)
|
||||
processEvents = FALSE;
|
||||
|
||||
/* Force to process all pending events in the mi event queue */
|
||||
if (processEvents)
|
||||
mieqProcessInputEvents();
|
||||
|
||||
/* Read the mode key states of our X server */
|
||||
/* (stored in the virtual core keyboard) */
|
||||
internalKeyStates =
|
||||
XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
|
||||
winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
|
||||
|
||||
/* Check if modifier keys are pressed, and if so, fake a press */
|
||||
{
|
||||
|
||||
BOOL lctrl = (GetAsyncKeyState(VK_LCONTROL) < 0);
|
||||
BOOL rctrl = (GetAsyncKeyState(VK_RCONTROL) < 0);
|
||||
BOOL lshift = (GetAsyncKeyState(VK_LSHIFT) < 0);
|
||||
BOOL rshift = (GetAsyncKeyState(VK_RSHIFT) < 0);
|
||||
BOOL alt = (GetAsyncKeyState(VK_LMENU) < 0);
|
||||
BOOL altgr = (GetAsyncKeyState(VK_RMENU) < 0);
|
||||
|
||||
/*
|
||||
If AltGr and CtrlL appear to be pressed, assume the
|
||||
CtrL is a fake one
|
||||
*/
|
||||
if (lctrl && altgr)
|
||||
lctrl = FALSE;
|
||||
|
||||
if (lctrl)
|
||||
winSendKeyEvent(KEY_LCtrl, TRUE);
|
||||
|
||||
if (rctrl)
|
||||
winSendKeyEvent(KEY_RCtrl, TRUE);
|
||||
|
||||
if (lshift)
|
||||
winSendKeyEvent(KEY_ShiftL, TRUE);
|
||||
|
||||
if (rshift)
|
||||
winSendKeyEvent(KEY_ShiftL, TRUE);
|
||||
|
||||
if (alt)
|
||||
winSendKeyEvent(KEY_Alt, TRUE);
|
||||
|
||||
if (altgr)
|
||||
winSendKeyEvent(KEY_AltLang, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
Check if latching modifier key states have changed, and if so,
|
||||
fake a press and a release to toggle the modifier to the correct
|
||||
state
|
||||
*/
|
||||
dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001;
|
||||
if (LOGICAL_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
|
||||
winSendKeyEvent(KEY_NumLock, TRUE);
|
||||
winSendKeyEvent(KEY_NumLock, FALSE);
|
||||
}
|
||||
|
||||
dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001;
|
||||
if (LOGICAL_XOR(internalKeyStates & LockMask, dwKeyState)) {
|
||||
winSendKeyEvent(KEY_CapsLock, TRUE);
|
||||
winSendKeyEvent(KEY_CapsLock, FALSE);
|
||||
}
|
||||
|
||||
dwKeyState = GetKeyState(VK_SCROLL) & 0x0001;
|
||||
if (LOGICAL_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
|
||||
winSendKeyEvent(KEY_ScrollLock, TRUE);
|
||||
winSendKeyEvent(KEY_ScrollLock, FALSE);
|
||||
}
|
||||
|
||||
dwKeyState = GetKeyState(VK_KANA) & 0x0001;
|
||||
if (LOGICAL_XOR(internalKeyStates & KanaMask, dwKeyState)) {
|
||||
winSendKeyEvent(KEY_HKTG, TRUE);
|
||||
winSendKeyEvent(KEY_HKTG, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
For strict correctness, we should also press any non-modifier keys
|
||||
which are already down when we gain focus, but nobody has complained
|
||||
yet :-)
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for the lovely fake Control_L press/release generated by Windows
|
||||
* when AltGr is pressed/released on a non-U.S. keyboard.
|
||||
*/
|
||||
|
||||
Bool
|
||||
winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MSG msgNext;
|
||||
LONG lTime;
|
||||
Bool fReturn;
|
||||
|
||||
static Bool lastWasControlL = FALSE;
|
||||
static LONG lastTime;
|
||||
|
||||
/*
|
||||
* Fake Ctrl_L presses will be followed by an Alt_R press
|
||||
* with the same timestamp as the Ctrl_L press.
|
||||
*/
|
||||
if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
|
||||
&& wParam == VK_CONTROL && (HIWORD(lParam) & KF_EXTENDED) == 0) {
|
||||
/* Got a Ctrl_L press */
|
||||
|
||||
/* Get time of current message */
|
||||
lTime = GetMessageTime();
|
||||
|
||||
/* Look for next press message */
|
||||
fReturn = PeekMessage(&msgNext, NULL,
|
||||
WM_KEYDOWN, WM_SYSKEYDOWN, PM_NOREMOVE);
|
||||
|
||||
if (fReturn && msgNext.message != WM_KEYDOWN &&
|
||||
msgNext.message != WM_SYSKEYDOWN)
|
||||
fReturn = 0;
|
||||
|
||||
if (!fReturn) {
|
||||
lastWasControlL = TRUE;
|
||||
lastTime = lTime;
|
||||
}
|
||||
else {
|
||||
lastWasControlL = FALSE;
|
||||
}
|
||||
|
||||
/* Is next press an Alt_R with the same timestamp? */
|
||||
if (fReturn && msgNext.wParam == VK_MENU
|
||||
&& msgNext.time == lTime
|
||||
&& (HIWORD(msgNext.lParam) & KF_EXTENDED)) {
|
||||
/*
|
||||
* Next key press is Alt_R with same timestamp as current
|
||||
* Ctrl_L message. Therefore, this Ctrl_L press is a fake
|
||||
* event, so discard it.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Sometimes, the Alt_R press message is not yet posted when the
|
||||
* fake Ctrl_L press message arrives (even though it has the
|
||||
* same timestamp), so check for an Alt_R press message that has
|
||||
* arrived since the last Ctrl_L message.
|
||||
*/
|
||||
else if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
|
||||
&& wParam == VK_MENU && (HIWORD(lParam) & KF_EXTENDED)) {
|
||||
/* Got a Alt_R press */
|
||||
|
||||
if (lastWasControlL) {
|
||||
lTime = GetMessageTime();
|
||||
|
||||
if (lastTime == lTime) {
|
||||
/* Undo the fake Ctrl_L press by sending a fake Ctrl_L release */
|
||||
winSendKeyEvent(KEY_LCtrl, FALSE);
|
||||
}
|
||||
lastWasControlL = FALSE;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Fake Ctrl_L releases will be followed by an Alt_R release
|
||||
* with the same timestamp as the Ctrl_L release.
|
||||
*/
|
||||
else if ((message == WM_KEYUP || message == WM_SYSKEYUP)
|
||||
&& wParam == VK_CONTROL && (HIWORD(lParam) & KF_EXTENDED) == 0) {
|
||||
/* Got a Ctrl_L release */
|
||||
|
||||
/* Get time of current message */
|
||||
lTime = GetMessageTime();
|
||||
|
||||
/* Look for next release message */
|
||||
fReturn = PeekMessage(&msgNext, NULL,
|
||||
WM_KEYUP, WM_SYSKEYUP, PM_NOREMOVE);
|
||||
|
||||
if (fReturn && msgNext.message != WM_KEYUP &&
|
||||
msgNext.message != WM_SYSKEYUP)
|
||||
fReturn = 0;
|
||||
|
||||
lastWasControlL = FALSE;
|
||||
|
||||
/* Is next press an Alt_R with the same timestamp? */
|
||||
if (fReturn
|
||||
&& (msgNext.message == WM_KEYUP || msgNext.message == WM_SYSKEYUP)
|
||||
&& msgNext.wParam == VK_MENU
|
||||
&& msgNext.time == lTime
|
||||
&& (HIWORD(msgNext.lParam) & KF_EXTENDED)) {
|
||||
/*
|
||||
* Next key release is Alt_R with same timestamp as current
|
||||
* Ctrl_L message. Therefore, this Ctrl_L release is a fake
|
||||
* event, so discard it.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* On any other press or release message, we don't have a
|
||||
potentially fake Ctrl_L to worry about anymore... */
|
||||
lastWasControlL = FALSE;
|
||||
}
|
||||
|
||||
/* Not a fake control left press/release */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lift any modifier keys that are pressed
|
||||
*/
|
||||
|
||||
void
|
||||
winKeybdReleaseKeys(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
/* Verify that the mi input system has been initialized */
|
||||
if (g_fdMessageQueue == WIN_FD_INVALID)
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Loop through all keys */
|
||||
for (i = 0; i < NUM_KEYCODES; ++i) {
|
||||
/* Pop key if pressed */
|
||||
if (g_winKeyState[i])
|
||||
winSendKeyEvent(i, FALSE);
|
||||
|
||||
/* Reset pressed flag for keys */
|
||||
g_winKeyState[i] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Take a raw X key code and send an up or down event for it.
|
||||
*
|
||||
* Thanks to VNC for inspiration, though it is a simple function.
|
||||
*/
|
||||
|
||||
void
|
||||
winSendKeyEvent(DWORD dwKey, Bool fDown)
|
||||
{
|
||||
/*
|
||||
* When alt-tabing between screens we can get phantom key up messages
|
||||
* Here we only pass them through it we think we should!
|
||||
*/
|
||||
if (g_winKeyState[dwKey] == FALSE && fDown == FALSE)
|
||||
return;
|
||||
|
||||
/* Update the keyState map */
|
||||
g_winKeyState[dwKey] = fDown;
|
||||
|
||||
QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease,
|
||||
dwKey + MIN_KEYCODE);
|
||||
|
||||
winDebug("winSendKeyEvent: dwKey: %u, fDown: %u\n", (unsigned int)dwKey, fDown);
|
||||
}
|
||||
|
||||
BOOL
|
||||
winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wParam) {
|
||||
case VK_CONTROL:
|
||||
if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
|
||||
return TRUE;
|
||||
if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
|
||||
return TRUE;
|
||||
break;
|
||||
case VK_SHIFT:
|
||||
if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
|
||||
return TRUE;
|
||||
if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Only one shift release message is sent even if both are pressed.
|
||||
* Fix this here
|
||||
*/
|
||||
void
|
||||
winFixShiftKeys(int iScanCode)
|
||||
{
|
||||
if (GetKeyState(VK_SHIFT) & 0x8000)
|
||||
return;
|
||||
|
||||
if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
|
||||
winSendKeyEvent(KEY_ShiftR, FALSE);
|
||||
if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
|
||||
winSendKeyEvent(KEY_ShiftL, FALSE);
|
||||
}
|
|
@ -1,308 +0,0 @@
|
|||
#if !defined(WINKEYBD_H)
|
||||
#define WINKEYBD_H
|
||||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
/*
|
||||
* We need symbols for the scan codes of keys.
|
||||
*/
|
||||
#include "winkeynames.h"
|
||||
|
||||
#define VK_FN 0xFF
|
||||
|
||||
#define WIN_KEYMAP_COLS 3
|
||||
|
||||
/* Rows 160 through 165 correspond to software-generated codes, which
|
||||
* may not be associated with the appropriate scan code.
|
||||
*/
|
||||
const int
|
||||
g_iKeyMap[] = {
|
||||
/* count Windows VK, ASCII, ASCII when extended VK */
|
||||
/* 0 */ 0, 0, 0,
|
||||
/* 1 */ 0, 0, 0,
|
||||
/* 2 */ 0, 0, 0,
|
||||
/* 3 */ VK_CANCEL, 0, KEY_Break,
|
||||
/* 4 */ 0, 0, 0,
|
||||
/* 5 */ 0, 0, 0,
|
||||
/* 6 */ 0, 0, 0,
|
||||
/* 7 */ 0, 0, 0,
|
||||
/* 8 */ 0, 0, 0,
|
||||
/* 9 */ 0, 0, 0,
|
||||
/* 10 */ 0, 0, 0,
|
||||
/* 11 */ 0, 0, 0,
|
||||
/* 12 */ 0, 0, 0,
|
||||
/* 13 */ VK_RETURN, 0, KEY_KP_Enter,
|
||||
/* 14 */ 0, 0, 0,
|
||||
/* 15 */ 0, 0, 0,
|
||||
/* 16 */ VK_SHIFT, 0, 0,
|
||||
/* 17 */ VK_CONTROL, 0, KEY_RCtrl,
|
||||
/* 18 */ VK_MENU, 0, KEY_AltLang,
|
||||
/* 19 */ VK_PAUSE, KEY_Pause, 0,
|
||||
/* 20 */ 0, 0, 0,
|
||||
/* 21 */ 0, 0, 0,
|
||||
/* 22 */ 0, 0, 0,
|
||||
/* 23 */ 0, 0, 0,
|
||||
/* 24 */ 0, 0, 0,
|
||||
/* 25 */ 0, 0, 0,
|
||||
/* 26 */ 0, 0, 0,
|
||||
/* 27 */ 0, 0, 0,
|
||||
/* 28 */ 0, 0, 0,
|
||||
/* 29 */ 0, 0, 0,
|
||||
/* 30 */ 0, 0, 0,
|
||||
/* 31 */ 0, 0, 0,
|
||||
/* 32 */ 0, 0, 0,
|
||||
/* 33 */ VK_PRIOR, 0, KEY_PgUp,
|
||||
/* 34 */ VK_NEXT, 0, KEY_PgDown,
|
||||
/* 35 */ VK_END, 0, KEY_End,
|
||||
/* 36 */ VK_HOME, 0, KEY_Home,
|
||||
/* 37 */ VK_LEFT, 0, KEY_Left,
|
||||
/* 38 */ VK_UP, 0, KEY_Up,
|
||||
/* 39 */ VK_RIGHT, 0, KEY_Right,
|
||||
/* 40 */ VK_DOWN, 0, KEY_Down,
|
||||
/* 41 */ 0, 0, 0,
|
||||
/* 42 */ 0, 0, 0,
|
||||
/* 43 */ 0, 0, 0,
|
||||
/* 44 */ VK_SNAPSHOT, 0, KEY_Print,
|
||||
/* 45 */ VK_INSERT, 0, KEY_Insert,
|
||||
/* 46 */ VK_DELETE, 0, KEY_Delete,
|
||||
/* 47 */ 0, 0, 0,
|
||||
/* 48 */ 0, 0, 0,
|
||||
/* 49 */ 0, 0, 0,
|
||||
/* 50 */ 0, 0, 0,
|
||||
/* 51 */ 0, 0, 0,
|
||||
/* 52 */ 0, 0, 0,
|
||||
/* 53 */ 0, 0, 0,
|
||||
/* 54 */ 0, 0, 0,
|
||||
/* 55 */ 0, 0, 0,
|
||||
/* 56 */ 0, 0, 0,
|
||||
/* 57 */ 0, 0, 0,
|
||||
/* 58 */ 0, 0, 0,
|
||||
/* 59 */ 0, 0, 0,
|
||||
/* 60 */ 0, 0, 0,
|
||||
/* 61 */ 0, 0, 0,
|
||||
/* 62 */ 0, 0, 0,
|
||||
/* 63 */ 0, 0, 0,
|
||||
/* 64 */ 0, 0, 0,
|
||||
/* 65 */ 0, 0, 0,
|
||||
/* 66 */ 0, 0, 0,
|
||||
/* 67 */ 0, 0, 0,
|
||||
/* 68 */ 0, 0, 0,
|
||||
/* 69 */ 0, 0, 0,
|
||||
/* 70 */ 0, 0, 0,
|
||||
/* 71 */ 0, 0, 0,
|
||||
/* 72 */ 0, 0, 0,
|
||||
/* 73 */ 0, 0, 0,
|
||||
/* 74 */ 0, 0, 0,
|
||||
/* 75 */ 0, 0, 0,
|
||||
/* 76 */ 0, 0, 0,
|
||||
/* 77 */ 0, 0, 0,
|
||||
/* 78 */ 0, 0, 0,
|
||||
/* 79 */ 0, 0, 0,
|
||||
/* 80 */ 0, 0, 0,
|
||||
/* 81 */ 0, 0, 0,
|
||||
/* 82 */ 0, 0, 0,
|
||||
/* 83 */ 0, 0, 0,
|
||||
/* 84 */ 0, 0, 0,
|
||||
/* 85 */ 0, 0, 0,
|
||||
/* 86 */ 0, 0, 0,
|
||||
/* 87 */ 0, 0, 0,
|
||||
/* 88 */ 0, 0, 0,
|
||||
/* 89 */ 0, 0, 0,
|
||||
/* 90 */ 0, 0, 0,
|
||||
/* 91 */ VK_LWIN, KEY_LMeta, 0,
|
||||
/* 92 */ VK_RWIN, KEY_RMeta, 0,
|
||||
/* 93 */ VK_APPS, KEY_Menu, 0,
|
||||
/* 94 */ 0, 0, 0,
|
||||
/* 95 */ 0, 0, 0,
|
||||
/* 96 */ 0, 0, 0,
|
||||
/* 97 */ 0, 0, 0,
|
||||
/* 98 */ 0, 0, 0,
|
||||
/* 99 */ 0, 0, 0,
|
||||
/* 100 */ 0, 0, 0,
|
||||
/* 101 */ 0, 0, 0,
|
||||
/* 102 */ 0, 0, 0,
|
||||
/* 103 */ 0, 0, 0,
|
||||
/* 104 */ 0, 0, 0,
|
||||
/* 105 */ 0, 0, 0,
|
||||
/* 106 */ 0, 0, 0,
|
||||
/* 107 */ 0, 0, 0,
|
||||
/* 108 */ 0, 0, 0,
|
||||
/* 109 */ 0, 0, 0,
|
||||
/* 110 */ 0, 0, 0,
|
||||
/* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
|
||||
/* 112 */ 0, 0, 0,
|
||||
/* 113 */ 0, 0, 0,
|
||||
/* 114 */ 0, 0, 0,
|
||||
/* 115 */ 0, 0, 0,
|
||||
/* 116 */ 0, 0, 0,
|
||||
/* 117 */ 0, 0, 0,
|
||||
/* 118 */ 0, 0, 0,
|
||||
/* 119 */ 0, 0, 0,
|
||||
/* 120 */ 0, 0, 0,
|
||||
/* 121 */ 0, 0, 0,
|
||||
/* 122 */ 0, 0, 0,
|
||||
/* 123 */ 0, 0, 0,
|
||||
/* 124 */ 0, 0, 0,
|
||||
/* 125 */ 0, 0, 0,
|
||||
/* 126 */ 0, 0, 0,
|
||||
/* 127 */ 0, 0, 0,
|
||||
/* 128 */ 0, 0, 0,
|
||||
/* 129 */ 0, 0, 0,
|
||||
/* 130 */ 0, 0, 0,
|
||||
/* 131 */ 0, 0, 0,
|
||||
/* 132 */ 0, 0, 0,
|
||||
/* 133 */ 0, 0, 0,
|
||||
/* 134 */ 0, 0, 0,
|
||||
/* 135 */ 0, 0, 0,
|
||||
/* 136 */ 0, 0, 0,
|
||||
/* 137 */ 0, 0, 0,
|
||||
/* 138 */ 0, 0, 0,
|
||||
/* 139 */ 0, 0, 0,
|
||||
/* 140 */ 0, 0, 0,
|
||||
/* 141 */ 0, 0, 0,
|
||||
/* 142 */ 0, 0, 0,
|
||||
/* 143 */ 0, 0, 0,
|
||||
/* 144 */ 0, 0, 0,
|
||||
/* 145 */ 0, 0, 0,
|
||||
/* 146 */ 0, 0, 0,
|
||||
/* 147 */ 0, 0, 0,
|
||||
/* 148 */ 0, 0, 0,
|
||||
/* 149 */ 0, 0, 0,
|
||||
/* 150 */ 0, 0, 0,
|
||||
/* 151 */ 0, 0, 0,
|
||||
/* 152 */ 0, 0, 0,
|
||||
/* 153 */ 0, 0, 0,
|
||||
/* 154 */ 0, 0, 0,
|
||||
/* 155 */ 0, 0, 0,
|
||||
/* 156 */ 0, 0, 0,
|
||||
/* 157 */ 0, 0, 0,
|
||||
/* 158 */ 0, 0, 0,
|
||||
/* 159 */ 0, 0, 0,
|
||||
/* 160 */ VK_LSHIFT, KEY_ShiftL, 0,
|
||||
/* 161 */ VK_RSHIFT, KEY_ShiftR, 0,
|
||||
/* 162 */ VK_LCONTROL, KEY_LCtrl, 0,
|
||||
/* 163 */ VK_RCONTROL, KEY_RCtrl, 0,
|
||||
/* 164 */ VK_LMENU, KEY_Alt, 0,
|
||||
/* 165 */ VK_RMENU, KEY_AltLang, 0,
|
||||
/* 166 */ 0, 0, 0,
|
||||
/* 167 */ 0, 0, 0,
|
||||
/* 168 */ 0, 0, 0,
|
||||
/* 169 */ 0, 0, 0,
|
||||
/* 170 */ 0, 0, 0,
|
||||
/* 171 */ 0, 0, 0,
|
||||
/* 172 */ 0, 0, 0,
|
||||
/* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute,
|
||||
/* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower,
|
||||
/* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise,
|
||||
/* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG,
|
||||
/* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG,
|
||||
/* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD,
|
||||
/* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE,
|
||||
/* 180 */ 0, 0, 0,
|
||||
/* 181 */ 0, 0, 0,
|
||||
/* 182 */ 0, 0, 0,
|
||||
/* 183 */ 0, 0, 0,
|
||||
/* 184 */ 0, 0, 0,
|
||||
/* 185 */ 0, 0, 0,
|
||||
/* 186 */ 0, 0, 0,
|
||||
/* 187 */ 0, 0, 0,
|
||||
/* 188 */ 0, 0, 0,
|
||||
/* 189 */ 0, 0, 0,
|
||||
/* 190 */ 0, 0, 0,
|
||||
/* 191 */ 0, 0, 0,
|
||||
/* 192 */ 0, 0, 0,
|
||||
/* 193 */ 0, 0, 0,
|
||||
/* 194 */ 0, 0, 0,
|
||||
/* 195 */ 0, 0, 0,
|
||||
/* 196 */ 0, 0, 0,
|
||||
/* 197 */ 0, 0, 0,
|
||||
/* 198 */ 0, 0, 0,
|
||||
/* 199 */ 0, 0, 0,
|
||||
/* 200 */ 0, 0, 0,
|
||||
/* 201 */ 0, 0, 0,
|
||||
/* 202 */ 0, 0, 0,
|
||||
/* 203 */ 0, 0, 0,
|
||||
/* 204 */ 0, 0, 0,
|
||||
/* 205 */ 0, 0, 0,
|
||||
/* 206 */ 0, 0, 0,
|
||||
/* 207 */ 0, 0, 0,
|
||||
/* 208 */ 0, 0, 0,
|
||||
/* 209 */ 0, 0, 0,
|
||||
/* 210 */ 0, 0, 0,
|
||||
/* 211 */ 0, 0, 0,
|
||||
/* 212 */ 0, 0, 0,
|
||||
/* 213 */ 0, 0, 0,
|
||||
/* 214 */ 0, 0, 0,
|
||||
/* 215 */ 0, 0, 0,
|
||||
/* 216 */ 0, 0, 0,
|
||||
/* 217 */ 0, 0, 0,
|
||||
/* 218 */ 0, 0, 0,
|
||||
/* 219 */ 0, 0, 0,
|
||||
/* 220 */ 0, 0, 0,
|
||||
/* 221 */ 0, 0, 0,
|
||||
/* 222 */ 0, 0, 0,
|
||||
/* 223 */ VK_OEM_8, 0, KEY_RCtrl,
|
||||
/* at least on Canadian Multilingual Standard layout */
|
||||
/* 224 */ 0, 0, 0,
|
||||
/* 225 */ 0, 0, 0,
|
||||
/* 226 */ 0, 0, 0,
|
||||
/* 227 */ 0, 0, 0,
|
||||
/* 228 */ 0, 0, 0,
|
||||
/* 229 */ 0, 0, 0,
|
||||
/* 230 */ 0, 0, 0,
|
||||
/* 231 */ 0, 0, 0,
|
||||
/* 232 */ 0, 0, 0,
|
||||
/* 233 */ 0, 0, 0,
|
||||
/* 234 */ 0, 0, 0,
|
||||
/* 235 */ 0, 0, 0,
|
||||
/* 236 */ 0, 0, 0,
|
||||
/* 237 */ 0, 0, 0,
|
||||
/* 238 */ 0, 0, 0,
|
||||
/* 239 */ 0, 0, 0,
|
||||
/* 240 */ 0, 0, 0,
|
||||
/* 241 */ 0, 0, 0,
|
||||
/* 242 */ 0, 0, 0,
|
||||
/* 243 */ 0, 0, 0,
|
||||
/* 244 */ 0, 0, 0,
|
||||
/* 245 */ 0, 0, 0,
|
||||
/* 246 */ 0, 0, 0,
|
||||
/* 247 */ 0, 0, 0,
|
||||
/* 248 */ 0, 0, 0,
|
||||
/* 249 */ 0, 0, 0,
|
||||
/* 250 */ 0, 0, 0,
|
||||
/* 251 */ 0, 0, 0,
|
||||
/* 252 */ 0, 0, 0,
|
||||
/* 253 */ 0, 0, 0,
|
||||
/* 254 */ 0, 0, 0,
|
||||
/* 255 */ VK_FN, 0, KEY_Fn
|
||||
/* Most keyboards don't generate a scancode for Fn, but a few do... */
|
||||
};
|
||||
|
||||
#endif /* WINKEYBD_H */
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
static HHOOK g_hhookKeyboardLL = NULL;
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
static LRESULT CALLBACK
|
||||
winKeyboardMessageHookLL(int iCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#ifndef LLKHF_EXTENDED
|
||||
#define LLKHF_EXTENDED 0x00000001
|
||||
#endif
|
||||
#ifndef LLKHF_UP
|
||||
#define LLKHF_UP 0x00000080
|
||||
#endif
|
||||
|
||||
/*
|
||||
* KeyboardMessageHook
|
||||
*/
|
||||
|
||||
static LRESULT CALLBACK
|
||||
winKeyboardMessageHookLL(int iCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
BOOL fPassKeystroke = FALSE;
|
||||
BOOL fPassAltTab = TRUE;
|
||||
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
|
||||
HWND hwnd = GetActiveWindow();
|
||||
|
||||
WindowPtr pWin = NULL;
|
||||
winPrivWinPtr pWinPriv = NULL;
|
||||
winPrivScreenPtr pScreenPriv = NULL;
|
||||
winScreenInfo *pScreenInfo = NULL;
|
||||
|
||||
/* Check if the Windows window property for our X window pointer is valid */
|
||||
if ((pWin = GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
|
||||
/* Get a pointer to our window privates */
|
||||
pWinPriv = winGetWindowPriv(pWin);
|
||||
|
||||
/* Get pointers to our screen privates and screen info */
|
||||
pScreenPriv = pWinPriv->pScreenPriv;
|
||||
pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
|
||||
if (pScreenInfo->fMultiWindow)
|
||||
fPassAltTab = FALSE;
|
||||
}
|
||||
|
||||
/* Pass keystrokes on to our main message loop */
|
||||
if (iCode == HC_ACTION) {
|
||||
winDebug("winKeyboardMessageHook: vkCode: %08x scanCode: %08x\n",
|
||||
(unsigned int)p->vkCode, (unsigned int)p->scanCode);
|
||||
|
||||
switch (wParam) {
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
fPassKeystroke =
|
||||
(fPassAltTab &&
|
||||
(p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
|
||||
|| (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass message on to our main message loop.
|
||||
* We process this immediately with SendMessage so that the keystroke
|
||||
* appears in, hopefully, the correct order.
|
||||
*/
|
||||
if (fPassKeystroke) {
|
||||
LPARAM lParamKey = 0x0;
|
||||
|
||||
/* Construct the lParam from KBDLLHOOKSTRUCT */
|
||||
lParamKey = lParamKey | (0x0000FFFF & 0x00000001); /* Repeat count */
|
||||
lParamKey = lParamKey | (0x00FF0000 & (p->scanCode << 16));
|
||||
lParamKey = lParamKey
|
||||
| (0x01000000 & ((p->flags & LLKHF_EXTENDED) << 23));
|
||||
lParamKey = lParamKey
|
||||
| (0x20000000 & ((p->flags & LLKHF_ALTDOWN) << 24));
|
||||
lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24));
|
||||
|
||||
/* Send message to our main window that has the keyboard focus */
|
||||
PostMessage(hwnd, (UINT) wParam, (WPARAM) p->vkCode, lParamKey);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Call next hook */
|
||||
return CallNextHookEx(NULL, iCode, wParam, lParam);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to install the keyboard hook, return FALSE if it was not installed
|
||||
*/
|
||||
|
||||
Bool
|
||||
winInstallKeyboardHookLL(void)
|
||||
{
|
||||
/* Install the hook only once */
|
||||
if (!g_hhookKeyboardLL)
|
||||
g_hhookKeyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL,
|
||||
winKeyboardMessageHookLL,
|
||||
g_hInstance, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the keyboard hook if it is installed
|
||||
*/
|
||||
|
||||
void
|
||||
winRemoveKeyboardHookLL(void)
|
||||
{
|
||||
if (g_hhookKeyboardLL)
|
||||
UnhookWindowsHookEx(g_hhookKeyboardLL);
|
||||
g_hhookKeyboardLL = NULL;
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
#ifndef _WINKEYNAMES_H
|
||||
#define _WINKEYNAMES_H
|
||||
/*
|
||||
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
|
||||
*
|
||||
* 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, and that the name of Thomas Roell not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Thomas Roell makes no representations
|
||||
* about the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*
|
||||
* THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#define GLYPHS_PER_KEY 4
|
||||
#define NUM_KEYCODES 248
|
||||
#define MIN_KEYCODE 8
|
||||
#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
|
||||
|
||||
#define AltMask Mod1Mask
|
||||
#define NumLockMask Mod2Mask
|
||||
#define AltLangMask Mod3Mask
|
||||
#define KanaMask Mod4Mask
|
||||
#define ScrollLockMask Mod5Mask
|
||||
|
||||
#define ModifierDown(k) ((keyc->state & (k)) == (k))
|
||||
|
||||
/*
|
||||
* NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
|
||||
* sets of scancodes. Set3 can only be generated by a MF keyboard.
|
||||
* Set2 sends a makecode for keypress, and the same code prefixed by a
|
||||
* F0 for keyrelease. This is a little bit ugly to handle. Thus we use
|
||||
* here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
|
||||
* Bit 7 is set if the key is released. The code E0 switches to a
|
||||
* different meaning to add the new MF cursorkeys, while not breaking old
|
||||
* applications. E1 is another special prefix. Since I assume that there
|
||||
* will be further versions of PC/XT scancode compatible keyboards, we
|
||||
* may be in trouble one day.
|
||||
*
|
||||
* IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
|
||||
* 2) Use the keyboards native set and translate it to common keysyms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* definition of the AT84/MF101/MF102 Keyboard:
|
||||
* ============================================================
|
||||
* Defined Key Cap Glyphs Pressed value
|
||||
* Key Name Main Also (hex) (dec)
|
||||
* ---------------- ---------- ------- ------ ------
|
||||
*/
|
||||
|
||||
#define KEY_Escape /* Escape 0x01 */ 1
|
||||
#define KEY_1 /* 1 ! 0x02 */ 2
|
||||
#define KEY_2 /* 2 @ 0x03 */ 3
|
||||
#define KEY_3 /* 3 # 0x04 */ 4
|
||||
#define KEY_4 /* 4 $ 0x05 */ 5
|
||||
#define KEY_5 /* 5 % 0x06 */ 6
|
||||
#define KEY_6 /* 6 ^ 0x07 */ 7
|
||||
#define KEY_7 /* 7 & 0x08 */ 8
|
||||
#define KEY_8 /* 8 * 0x09 */ 9
|
||||
#define KEY_9 /* 9 ( 0x0a */ 10
|
||||
#define KEY_0 /* 0 ) 0x0b */ 11
|
||||
#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12
|
||||
#define KEY_Equal /* = (Equal) + 0x0d */ 13
|
||||
#define KEY_BackSpace /* Back Space 0x0e */ 14
|
||||
#define KEY_Tab /* Tab 0x0f */ 15
|
||||
#define KEY_Q /* Q 0x10 */ 16
|
||||
#define KEY_W /* W 0x11 */ 17
|
||||
#define KEY_E /* E 0x12 */ 18
|
||||
#define KEY_R /* R 0x13 */ 19
|
||||
#define KEY_T /* T 0x14 */ 20
|
||||
#define KEY_Y /* Y 0x15 */ 21
|
||||
#define KEY_U /* U 0x16 */ 22
|
||||
#define KEY_I /* I 0x17 */ 23
|
||||
#define KEY_O /* O 0x18 */ 24
|
||||
#define KEY_P /* P 0x19 */ 25
|
||||
#define KEY_LBrace /* [ { 0x1a */ 26
|
||||
#define KEY_RBrace /* ] } 0x1b */ 27
|
||||
#define KEY_Enter /* Enter 0x1c */ 28
|
||||
#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29
|
||||
#define KEY_A /* A 0x1e */ 30
|
||||
#define KEY_S /* S 0x1f */ 31
|
||||
#define KEY_D /* D 0x20 */ 32
|
||||
#define KEY_F /* F 0x21 */ 33
|
||||
#define KEY_G /* G 0x22 */ 34
|
||||
#define KEY_H /* H 0x23 */ 35
|
||||
#define KEY_J /* J 0x24 */ 36
|
||||
#define KEY_K /* K 0x25 */ 37
|
||||
#define KEY_L /* L 0x26 */ 38
|
||||
#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39
|
||||
#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40
|
||||
#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41
|
||||
#define KEY_ShiftL /* Shift(left) 0x2a */ 42
|
||||
#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43
|
||||
#define KEY_Z /* Z 0x2c */ 44
|
||||
#define KEY_X /* X 0x2d */ 45
|
||||
#define KEY_C /* C 0x2e */ 46
|
||||
#define KEY_V /* V 0x2f */ 47
|
||||
#define KEY_B /* B 0x30 */ 48
|
||||
#define KEY_N /* N 0x31 */ 49
|
||||
#define KEY_M /* M 0x32 */ 50
|
||||
#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51
|
||||
#define KEY_Period /* . (Period) >(Greater)0x34 */ 52
|
||||
#define KEY_Slash /* / (Slash) ? 0x35 */ 53
|
||||
#define KEY_ShiftR /* Shift(right) 0x36 */ 54
|
||||
#define KEY_KP_Multiply /* * 0x37 */ 55
|
||||
#define KEY_Alt /* Alt(left) 0x38 */ 56
|
||||
#define KEY_Space /* (SpaceBar) 0x39 */ 57
|
||||
#define KEY_CapsLock /* CapsLock 0x3a */ 58
|
||||
#define KEY_F1 /* F1 0x3b */ 59
|
||||
#define KEY_F2 /* F2 0x3c */ 60
|
||||
#define KEY_F3 /* F3 0x3d */ 61
|
||||
#define KEY_F4 /* F4 0x3e */ 62
|
||||
#define KEY_F5 /* F5 0x3f */ 63
|
||||
#define KEY_F6 /* F6 0x40 */ 64
|
||||
#define KEY_F7 /* F7 0x41 */ 65
|
||||
#define KEY_F8 /* F8 0x42 */ 66
|
||||
#define KEY_F9 /* F9 0x43 */ 67
|
||||
#define KEY_F10 /* F10 0x44 */ 68
|
||||
#define KEY_NumLock /* NumLock 0x45 */ 69
|
||||
#define KEY_ScrollLock /* ScrollLock 0x46 */ 70
|
||||
#define KEY_KP_7 /* 7 Home 0x47 */ 71
|
||||
#define KEY_KP_8 /* 8 Up 0x48 */ 72
|
||||
#define KEY_KP_9 /* 9 PgUp 0x49 */ 73
|
||||
#define KEY_KP_Minus /* - (Minus) 0x4a */ 74
|
||||
#define KEY_KP_4 /* 4 Left 0x4b */ 75
|
||||
#define KEY_KP_5 /* 5 0x4c */ 76
|
||||
#define KEY_KP_6 /* 6 Right 0x4d */ 77
|
||||
#define KEY_KP_Plus /* + (Plus) 0x4e */ 78
|
||||
#define KEY_KP_1 /* 1 End 0x4f */ 79
|
||||
#define KEY_KP_2 /* 2 Down 0x50 */ 80
|
||||
#define KEY_KP_3 /* 3 PgDown 0x51 */ 81
|
||||
#define KEY_KP_0 /* 0 Insert 0x52 */ 82
|
||||
#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83
|
||||
#define KEY_SysReqest /* SysReqest 0x54 */ 84
|
||||
#define KEY_Fn /* Fn 0x55 */ 85
|
||||
#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86
|
||||
#define KEY_F11 /* F11 0x57 */ 87
|
||||
#define KEY_F12 /* F12 0x58 */ 88
|
||||
|
||||
#define KEY_Prefix0 /* special 0x60 */ 96
|
||||
#define KEY_Prefix1 /* special 0x61 */ 97
|
||||
|
||||
/*
|
||||
* The 'scancodes' below are generated by the server, because the MF101/102
|
||||
* keyboard sends them as sequence of other scancodes
|
||||
*/
|
||||
#define KEY_Home /* Home 0x59 */ 89
|
||||
#define KEY_Up /* Up 0x5a */ 90
|
||||
#define KEY_PgUp /* PgUp 0x5b */ 91
|
||||
#define KEY_Left /* Left 0x5c */ 92
|
||||
#define KEY_Begin /* Begin 0x5d */ 93
|
||||
#define KEY_Right /* Right 0x5e */ 94
|
||||
#define KEY_End /* End 0x5f */ 95
|
||||
#define KEY_Down /* Down 0x60 */ 96
|
||||
#define KEY_PgDown /* PgDown 0x61 */ 97
|
||||
#define KEY_Insert /* Insert 0x62 */ 98
|
||||
#define KEY_Delete /* Delete 0x63 */ 99
|
||||
#define KEY_KP_Enter /* Enter 0x64 */ 100
|
||||
#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101
|
||||
#define KEY_Pause /* Pause 0x66 */ 102
|
||||
#define KEY_Print /* Print 0x67 */ 103
|
||||
#define KEY_KP_Divide /* Divide 0x68 */ 104
|
||||
#define KEY_AltLang /* AtlLang(right) 0x69 */ 105
|
||||
#define KEY_Break /* Break 0x6a */ 106
|
||||
#define KEY_LMeta /* Left Meta 0x6b */ 107
|
||||
#define KEY_RMeta /* Right Meta 0x6c */ 108
|
||||
#define KEY_Menu /* Menu 0x6d */ 109
|
||||
#define KEY_F13 /* F13 0x6e */ 110
|
||||
#define KEY_F14 /* F14 0x6f */ 111
|
||||
#define KEY_F15 /* F15 0x70 */ 112
|
||||
#define KEY_F16 /* F16 0x71 */ 113
|
||||
#define KEY_F17 /* F17 0x72 */ 114
|
||||
#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
|
||||
#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118
|
||||
#define KEY_XFER /* Kanji Transfer 0x79 */ 121
|
||||
#define KEY_NFER /* No Kanji Transfer 0x7b */ 123
|
||||
#define KEY_Yen /* Yen 0x7d */ 125
|
||||
#define KEY_HKTG /* Hirugana/Katakana tog 0xc8 */ 200
|
||||
#define KEY_BSlash2 /* \ _ 0xcb */ 203
|
||||
|
||||
#define KEY_Mute /* Audio Mute */ 152
|
||||
#define KEY_AudioLower /* Audio Lower */ 166
|
||||
#define KEY_AudioRaise /* Audio Raise */ 168
|
||||
|
||||
#define KEY_NEXTSONG /* Media next */ 145
|
||||
#define KEY_PLAYPAUSE /* Media play/pause toggle */ 154
|
||||
#define KEY_PREVIOUSSONG /* Media previous */ 136
|
||||
#define KEY_STOPCD /* Media stop */ 156
|
||||
|
||||
/* These are for "notused" and "unknown" entries in translation maps. */
|
||||
#define KEY_NOTUSED 0
|
||||
#define KEY_UNKNOWN 255
|
||||
|
||||
#endif /* _WINKEYNAMES_H */
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2005 Alexander Gottwald
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
|
||||
* holders shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written authorization.
|
||||
*/
|
||||
/* Definitions for various keyboard layouts from windows and their
|
||||
* XKB settings.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned int winlayout;
|
||||
int winkbtype;
|
||||
const char *xkbmodel;
|
||||
const char *xkblayout;
|
||||
const char *xkbvariant;
|
||||
const char *xkboptions;
|
||||
const char *layoutname;
|
||||
} WinKBLayoutRec, *WinKBLayoutPtr;
|
||||
|
||||
/*
|
||||
This table is sorted by low byte of winlayout, then by next byte, etc.
|
||||
*/
|
||||
|
||||
WinKBLayoutRec winKBLayouts[] = {
|
||||
{0x00000404, -1, "pc105", "cn", NULL, NULL, "Chinese (Traditional)"},
|
||||
{0x00000804, -1, "pc105", "cn", NULL, NULL, "Chinese (Simplified)"},
|
||||
{0x00000405, -1, "pc105", "cz", NULL, NULL, "Czech"},
|
||||
{0x00010405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
|
||||
{0x00000406, -1, "pc105", "dk", NULL, NULL, "Danish"},
|
||||
{0x00000407, -1, "pc105", "de", NULL, NULL, "German (Germany)"},
|
||||
{0x00010407, -1, "pc105", "de", NULL, NULL, "German (Germany,IBM)"},
|
||||
{0x00000807, -1, "pc105", "ch", "de", NULL, "German (Switzerland)"},
|
||||
{0x00000409, -1, "pc105", "us", NULL, NULL, "English (USA)"},
|
||||
{0x00010409, -1, "pc105", "dvorak", NULL, NULL, "English (USA,Dvorak)"},
|
||||
{0x00020409, -1, "pc105", "us_intl", NULL, NULL,
|
||||
"English (USA,International)"},
|
||||
{0x00000809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
|
||||
{0x00001009, -1, "pc105", "ca", "fr", NULL, "French (Canada)"},
|
||||
{0x00011009, -1, "pc105", "ca", "multix", NULL,
|
||||
"Canadian Multilingual Standard"},
|
||||
{0x00001809, -1, "pc105", "ie", NULL, NULL, "Irish"},
|
||||
{0x0000040a, -1, "pc105", "es", NULL, NULL,
|
||||
"Spanish (Spain,Traditional Sort)"},
|
||||
{0x0000080a, -1, "pc105", "latam", NULL, NULL, "Latin American"},
|
||||
{0x0000040b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
|
||||
{0x0000040c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
|
||||
{0x0000080c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
|
||||
{0x0001080c, -1, "pc105", "be", NULL, NULL, "Belgian (Comma)"},
|
||||
{0x00000c0c, -1, "pc105", "ca", "fr-legacy", NULL,
|
||||
"French (Canada, Legacy)"},
|
||||
{0x0000100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"},
|
||||
{0x0000040d, -1, "pc105", "il", NULL, NULL, "Hebrew"},
|
||||
{0x0000040e, -1, "pc105", "hu", NULL, NULL, "Hungarian"},
|
||||
{0x0000040f, -1, "pc105", "is", NULL, NULL, "Icelandic"},
|
||||
{0x00000410, -1, "pc105", "it", NULL, NULL, "Italian"},
|
||||
{0x00010410, -1, "pc105", "it", NULL, NULL, "Italian (142)"},
|
||||
{0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
|
||||
{0x00000412, -1, "kr106", "kr", NULL, NULL, "Korean"},
|
||||
{0x00000413, -1, "pc105", "nl", NULL, NULL, "Dutch"},
|
||||
{0x00000813, -1, "pc105", "be", NULL, NULL, "Dutch (Belgian)"},
|
||||
{0x00000414, -1, "pc105", "no", NULL, NULL, "Norwegian"},
|
||||
{0x00000415, -1, "pc105", "pl", NULL, NULL, "Polish (Programmers)"},
|
||||
{0x00000416, -1, "pc105", "br", NULL, NULL, "Portuguese (Brazil,ABNT)"},
|
||||
{0x00010416, -1, "abnt2", "br", NULL, NULL, "Portuguese (Brazil,ABNT2)"},
|
||||
{0x00000816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"},
|
||||
{0x00000419, -1, "pc105", "ru", NULL, NULL, "Russian"},
|
||||
{0x0000041a, -1, "pc105", "hr", NULL, NULL, "Croatian"},
|
||||
{0x0000041d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
|
||||
{0x0000041f, -1, "pc105", "tr", NULL, NULL, "Turkish (Q)"},
|
||||
{0x0001041f, -1, "pc105", "tr", "f", NULL, "Turkish (F)"},
|
||||
{0x00000424, -1, "pc105", "si", NULL, NULL, "Slovenian"},
|
||||
{0x00000425, -1, "pc105", "ee", NULL, NULL, "Estonian"},
|
||||
{0x00000452, -1, "pc105", "gb", "intl", NULL, "United Kingdom (Extended)"},
|
||||
{-1, -1, NULL, NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
See http://technet.microsoft.com/en-us/library/cc766503%28WS.10%29.aspx
|
||||
for a listing of input locale (keyboard layout) codes
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* Count the number of one bits in a color mask.
|
||||
*/
|
||||
|
||||
CARD8
|
||||
winCountBits(DWORD dw)
|
||||
{
|
||||
DWORD dwBits = 0;
|
||||
|
||||
while (dw) {
|
||||
dwBits += (dw & 1);
|
||||
dw >>= 1;
|
||||
}
|
||||
|
||||
return dwBits;
|
||||
}
|
||||
|
||||
/*
|
||||
* Modify the screen pixmap to point to the new framebuffer address
|
||||
*/
|
||||
|
||||
Bool
|
||||
winUpdateFBPointer(ScreenPtr pScreen, void *pbits)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
|
||||
/* Location of shadow framebuffer has changed */
|
||||
pScreenInfo->pfb = pbits;
|
||||
|
||||
/* Update the screen pixmap */
|
||||
if (!(*pScreen->ModifyPixmapHeader) (pScreen->devPrivate,
|
||||
pScreen->width,
|
||||
pScreen->height,
|
||||
pScreen->rootDepth,
|
||||
BitsPerPixel(pScreen->rootDepth),
|
||||
PixmapBytePad(pScreenInfo->dwStride,
|
||||
pScreenInfo->dwBPP),
|
||||
pScreenInfo->pfb)) {
|
||||
FatalError("winUpdateFramebufferPointer - Failed modifying "
|
||||
"screen pixmap\n");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
|
||||
Copyright 1993, 1998 The Open Group
|
||||
Copyright (C) Colin Harrison 2005-2008
|
||||
|
||||
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 "winmonitors.h"
|
||||
|
||||
/*
|
||||
* getMonitorInfo - callback function used to return information from the enumeration of monitors attached
|
||||
*/
|
||||
|
||||
static
|
||||
WINBOOL CALLBACK
|
||||
getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
|
||||
{
|
||||
struct GetMonitorInfoData *data = (struct GetMonitorInfoData *) _data;
|
||||
|
||||
// only get data for monitor number specified in <data>
|
||||
data->monitorNum++;
|
||||
if (data->monitorNum == data->requestedMonitor) {
|
||||
data->bMonitorSpecifiedExists = TRUE;
|
||||
data->monitorOffsetX = rect->left;
|
||||
data->monitorOffsetY = rect->top;
|
||||
data->monitorHeight = rect->bottom - rect->top;
|
||||
data->monitorWidth = rect->right - rect->left;
|
||||
data->monitorHandle = hMonitor;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
QueryMonitor(int i, struct GetMonitorInfoData *data)
|
||||
{
|
||||
/* prepare data */
|
||||
if (data == NULL)
|
||||
return FALSE;
|
||||
memset(data, 0, sizeof(*data));
|
||||
data->requestedMonitor = i;
|
||||
|
||||
/* query information */
|
||||
EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
|
||||
|
||||
return data->bMonitorSpecifiedExists;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
|
||||
Copyright 1993, 1998 The Open Group
|
||||
Copyright (C) Colin Harrison 2005-2008
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
/* data returned for monitor information */
|
||||
struct GetMonitorInfoData {
|
||||
int requestedMonitor;
|
||||
int monitorNum;
|
||||
Bool bUserSpecifiedMonitor;
|
||||
Bool bMonitorSpecifiedExists;
|
||||
int monitorOffsetX;
|
||||
int monitorOffsetY;
|
||||
int monitorHeight;
|
||||
int monitorWidth;
|
||||
HMONITOR monitorHandle;
|
||||
};
|
||||
|
||||
Bool QueryMonitor(int i, struct GetMonitorInfoData *data);
|
|
@ -1,350 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Dakshinamurthy Karra
|
||||
* Suhaib M Siddiqi
|
||||
* Peter Busch
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
#include "inputstr.h"
|
||||
#include "exevents.h" /* for button/axes labels */
|
||||
#include "xserver-properties.h"
|
||||
#include "inpututils.h"
|
||||
|
||||
/* Peek the internal button mapping */
|
||||
static CARD8 const *g_winMouseButtonMap = NULL;
|
||||
|
||||
/*
|
||||
* Local prototypes
|
||||
*/
|
||||
|
||||
static void
|
||||
winMouseCtrl(DeviceIntPtr pDevice, PtrCtrl * pCtrl);
|
||||
|
||||
static void
|
||||
winMouseCtrl(DeviceIntPtr pDevice, PtrCtrl * pCtrl)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* See Porting Layer Definition - p. 18
|
||||
* This is known as a DeviceProc
|
||||
*/
|
||||
|
||||
int
|
||||
winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||
{
|
||||
int lngMouseButtons, i;
|
||||
int lngWheelEvents = 4;
|
||||
CARD8 *map;
|
||||
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
||||
Atom btn_labels[9];
|
||||
Atom axes_labels[2];
|
||||
|
||||
switch (iState) {
|
||||
case DEVICE_INIT:
|
||||
/* Get number of mouse buttons */
|
||||
lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
|
||||
winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
|
||||
|
||||
/* Mapping of windows events to X events:
|
||||
* LEFT:1 MIDDLE:2 RIGHT:3
|
||||
* SCROLL_UP:4 SCROLL_DOWN:5
|
||||
* TILT_LEFT:6 TILT_RIGHT:7
|
||||
* XBUTTON 1:8 XBUTTON 2:9 (most commonly 'back' and 'forward')
|
||||
* ...
|
||||
*
|
||||
* The current Windows API only defines 2 extra buttons, so we don't
|
||||
* expect more than 5 buttons to be reported, but more than that
|
||||
* should be handled correctly
|
||||
*/
|
||||
|
||||
/*
|
||||
* To map scroll wheel correctly we need at least the 3 normal buttons
|
||||
*/
|
||||
if (lngMouseButtons < 3)
|
||||
lngMouseButtons = 3;
|
||||
|
||||
/* allocate memory:
|
||||
* number of buttons + 4 x mouse wheel event + 1 extra (offset for map)
|
||||
*/
|
||||
map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
|
||||
|
||||
/* initialize button map */
|
||||
map[0] = 0;
|
||||
for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++)
|
||||
map[i] = i;
|
||||
|
||||
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
||||
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
||||
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
||||
btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
|
||||
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
|
||||
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
|
||||
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
|
||||
btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK);
|
||||
btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD);
|
||||
|
||||
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
||||
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
||||
|
||||
InitPointerDeviceStruct(pDevice,
|
||||
map,
|
||||
lngMouseButtons + lngWheelEvents,
|
||||
btn_labels,
|
||||
winMouseCtrl,
|
||||
GetMotionHistorySize(), 2, axes_labels);
|
||||
free(map);
|
||||
|
||||
g_winMouseButtonMap = pDeviceInt->button->map;
|
||||
break;
|
||||
|
||||
case DEVICE_ON:
|
||||
pDevice->on = TRUE;
|
||||
break;
|
||||
|
||||
case DEVICE_CLOSE:
|
||||
g_winMouseButtonMap = NULL;
|
||||
|
||||
case DEVICE_OFF:
|
||||
pDevice->on = FALSE;
|
||||
break;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
/* Handle the mouse wheel */
|
||||
int
|
||||
winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown)
|
||||
{
|
||||
int button;
|
||||
|
||||
/* Do we have any previous delta stored? */
|
||||
if ((*iTotalDeltaZ > 0 && iDeltaZ > 0)
|
||||
|| (*iTotalDeltaZ < 0 && iDeltaZ < 0)) {
|
||||
/* Previous delta and of same sign as current delta */
|
||||
iDeltaZ += *iTotalDeltaZ;
|
||||
*iTotalDeltaZ = 0;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Previous delta of different sign, or zero.
|
||||
* We will set it to zero for either case,
|
||||
* as blindly setting takes just as much time
|
||||
* as checking, then setting if necessary :)
|
||||
*/
|
||||
*iTotalDeltaZ = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only process this message if the wheel has moved further than
|
||||
* WHEEL_DELTA
|
||||
*/
|
||||
if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA) {
|
||||
*iTotalDeltaZ = 0;
|
||||
|
||||
/* Figure out how many whole deltas of the wheel we have */
|
||||
iDeltaZ /= WHEEL_DELTA;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Wheel has not moved past WHEEL_DELTA threshold;
|
||||
* we will store the wheel delta until the threshold
|
||||
* has been reached.
|
||||
*/
|
||||
*iTotalDeltaZ = iDeltaZ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the button to indicate up or down wheel delta */
|
||||
if (iDeltaZ > 0) {
|
||||
button = iButtonUp;
|
||||
}
|
||||
else {
|
||||
button = iButtonDown;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flip iDeltaZ to positive, if negative,
|
||||
* because always need to generate a *positive* number of
|
||||
* button clicks for the Z axis.
|
||||
*/
|
||||
if (iDeltaZ < 0) {
|
||||
iDeltaZ *= -1;
|
||||
}
|
||||
|
||||
/* Generate X input messages for each wheel delta we have seen */
|
||||
while (iDeltaZ--) {
|
||||
/* Push the wheel button */
|
||||
winMouseButtonsSendEvent(ButtonPress, button);
|
||||
|
||||
/* Release the wheel button */
|
||||
winMouseButtonsSendEvent(ButtonRelease, button);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enqueue a mouse button event
|
||||
*/
|
||||
|
||||
void
|
||||
winMouseButtonsSendEvent(int iEventType, int iButton)
|
||||
{
|
||||
ValuatorMask mask;
|
||||
|
||||
if (g_winMouseButtonMap)
|
||||
iButton = g_winMouseButtonMap[iButton];
|
||||
|
||||
valuator_mask_zero(&mask);
|
||||
QueuePointerEvents(g_pwinPointer, iEventType, iButton,
|
||||
POINTER_RELATIVE, &mask);
|
||||
|
||||
#if CYGDEBUG
|
||||
ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
|
||||
iEventType, iButton);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Decide what to do with a Windows mouse message
|
||||
*/
|
||||
|
||||
int
|
||||
winMouseButtonsHandle(ScreenPtr pScreen,
|
||||
int iEventType, int iButton, WPARAM wParam)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
|
||||
/* Send button events right away if emulate 3 buttons is off */
|
||||
if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF) {
|
||||
/* Emulate 3 buttons is off, send the button event */
|
||||
winMouseButtonsSendEvent(iEventType, iButton);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Emulate 3 buttons is on, let the fun begin */
|
||||
if (iEventType == ButtonPress
|
||||
&& pScreenPriv->iE3BCachedPress == 0
|
||||
&& !pScreenPriv->fE3BFakeButton2Sent) {
|
||||
/*
|
||||
* Button was pressed, no press is cached,
|
||||
* and there is no fake button 2 release pending.
|
||||
*/
|
||||
|
||||
/* Store button press type */
|
||||
pScreenPriv->iE3BCachedPress = iButton;
|
||||
|
||||
/*
|
||||
* Set a timer to send this button press if the other button
|
||||
* is not pressed within the timeout time.
|
||||
*/
|
||||
SetTimer(pScreenPriv->hwndScreen,
|
||||
WIN_E3B_TIMER_ID, pScreenInfo->iE3BTimeout, NULL);
|
||||
}
|
||||
else if (iEventType == ButtonPress
|
||||
&& pScreenPriv->iE3BCachedPress != 0
|
||||
&& pScreenPriv->iE3BCachedPress != iButton
|
||||
&& !pScreenPriv->fE3BFakeButton2Sent) {
|
||||
/*
|
||||
* Button press is cached, other button was pressed,
|
||||
* and there is no fake button 2 release pending.
|
||||
*/
|
||||
|
||||
/* Mouse button was cached and other button was pressed */
|
||||
KillTimer(pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
|
||||
pScreenPriv->iE3BCachedPress = 0;
|
||||
|
||||
/* Send fake middle button */
|
||||
winMouseButtonsSendEvent(ButtonPress, Button2);
|
||||
|
||||
/* Indicate that a fake middle button event was sent */
|
||||
pScreenPriv->fE3BFakeButton2Sent = TRUE;
|
||||
}
|
||||
else if (iEventType == ButtonRelease
|
||||
&& pScreenPriv->iE3BCachedPress == iButton) {
|
||||
/*
|
||||
* Cached button was released before timer ran out,
|
||||
* and before the other mouse button was pressed.
|
||||
*/
|
||||
KillTimer(pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
|
||||
pScreenPriv->iE3BCachedPress = 0;
|
||||
|
||||
/* Send cached press, then send release */
|
||||
winMouseButtonsSendEvent(ButtonPress, iButton);
|
||||
winMouseButtonsSendEvent(ButtonRelease, iButton);
|
||||
}
|
||||
else if (iEventType == ButtonRelease
|
||||
&& pScreenPriv->fE3BFakeButton2Sent && !(wParam & MK_LBUTTON)
|
||||
&& !(wParam & MK_RBUTTON)) {
|
||||
/*
|
||||
* Fake button 2 was sent and both mouse buttons have now been released
|
||||
*/
|
||||
pScreenPriv->fE3BFakeButton2Sent = FALSE;
|
||||
|
||||
/* Send middle mouse button release */
|
||||
winMouseButtonsSendEvent(ButtonRelease, Button2);
|
||||
}
|
||||
else if (iEventType == ButtonRelease
|
||||
&& pScreenPriv->iE3BCachedPress == 0
|
||||
&& !pScreenPriv->fE3BFakeButton2Sent) {
|
||||
/*
|
||||
* Button was release, no button is cached,
|
||||
* and there is no fake button 2 release is pending.
|
||||
*/
|
||||
winMouseButtonsSendEvent(ButtonRelease, iButton);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue a motion event.
|
||||
*
|
||||
*/
|
||||
void
|
||||
winEnqueueMotion(int x, int y)
|
||||
{
|
||||
int valuators[2];
|
||||
ValuatorMask mask;
|
||||
|
||||
valuators[0] = x;
|
||||
valuators[1] = y;
|
||||
|
||||
valuator_mask_set_range(&mask, 0, 2, valuators);
|
||||
QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
|
||||
POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef _WINMS_H_
|
||||
#define _WINMS_H_
|
||||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#define DIRECTDRAW_VERSION 0x0300
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef WINVER
|
||||
#define WINVER 0x0500
|
||||
#endif
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#pragma push_macro("Status")
|
||||
#undef Status
|
||||
#define Status wStatus
|
||||
#include "ddraw.h"
|
||||
#pragma pop_macro("Status")
|
||||
|
||||
#undef CreateWindow
|
||||
|
||||
#endif /* _WINMS_H_ */
|
155
hw/xwin/winmsg.c
155
hw/xwin/winmsg.c
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Alexander Gottwald
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winmsg.h"
|
||||
#if CYGDEBUG
|
||||
#include "winmessages.h"
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
void
|
||||
winDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
LogVMessageVerb(type, 0, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
winDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
LogVMessageVerb(type, verb, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
winErrorFVerb(int verb, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
LogVMessageVerb(X_NONE, verb, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
winDebug(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
LogVMessageVerb(X_NONE, 3, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
winTrace(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
LogVMessageVerb(X_NONE, 10, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
winW32Error(int verb, const char *msg)
|
||||
{
|
||||
winW32ErrorEx(verb, msg, GetLastError());
|
||||
}
|
||||
|
||||
void
|
||||
winW32ErrorEx(int verb, const char *msg, DWORD errorcode)
|
||||
{
|
||||
LPVOID buffer;
|
||||
|
||||
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
errorcode,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buffer, 0, NULL)) {
|
||||
winErrorFVerb(verb, "Unknown error in FormatMessage!\n");
|
||||
}
|
||||
else {
|
||||
winErrorFVerb(verb, "%s %s", msg, (char *) buffer);
|
||||
LocalFree(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
#if CYGDEBUG
|
||||
void
|
||||
winDebugWin32Message(const char *function, HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static int force = 0;
|
||||
|
||||
if (message >= WM_USER) {
|
||||
if (force || getenv("WIN_DEBUG_MESSAGES") ||
|
||||
getenv("WIN_DEBUG_WM_USER")) {
|
||||
winDebug("%s - Message WM_USER + %d\n", function,
|
||||
message - WM_USER);
|
||||
winDebug("\thwnd 0x%p wParam 0x%x lParam 0x%x\n", hwnd, (int)wParam,
|
||||
(int)lParam);
|
||||
}
|
||||
}
|
||||
else if (message < MESSAGE_NAMES_LEN && MESSAGE_NAMES[message]) {
|
||||
const char *msgname = MESSAGE_NAMES[message];
|
||||
char buffer[64];
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "WIN_DEBUG_%s", msgname);
|
||||
buffer[63] = 0;
|
||||
if (force || getenv("WIN_DEBUG_MESSAGES") || getenv(buffer)) {
|
||||
winDebug("%s - Message %s\n", function, MESSAGE_NAMES[message]);
|
||||
winDebug("\thwnd 0x%p wParam 0x%x lParam 0x%x\n", hwnd, (int)wParam,
|
||||
(int)lParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
winDebugWin32Message(const char *function, HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
}
|
||||
#endif
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Alexander Gottwald
|
||||
*/
|
||||
|
||||
#ifndef __WIN_MSG_H__
|
||||
#define __WIN_MSG_H__
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <X11/Xfuncproto.h>
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
#ifdef XWIN_XF86CONFIG
|
||||
void
|
||||
winDrvMsgVerb(int scrnIndex,
|
||||
MessageType type, int verb, const char *format, ...)
|
||||
_X_ATTRIBUTE_PRINTF(4, 5);
|
||||
void
|
||||
winDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
|
||||
_X_ATTRIBUTE_PRINTF(3, 4);
|
||||
#endif
|
||||
|
||||
#define winMsg LogMessage
|
||||
|
||||
void
|
||||
winDebug(const char *format, ...)
|
||||
_X_ATTRIBUTE_PRINTF(1, 2);
|
||||
void
|
||||
winTrace(const char *format, ...)
|
||||
_X_ATTRIBUTE_PRINTF(1, 2);
|
||||
|
||||
void
|
||||
winErrorFVerb(int verb, const char *format, ...)
|
||||
_X_ATTRIBUTE_PRINTF(2, 3);
|
||||
void winW32Error(int verb, const char *message);
|
||||
void winW32ErrorEx(int verb, const char *message, DWORD errorcode);
|
||||
void winDebugWin32Message(const char *function, HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) Jon TURNEY 2011
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* This is the messaging window, a hidden top-level window. We never do anything
|
||||
* with it, but other programs may send messages to it.
|
||||
*/
|
||||
|
||||
/*
|
||||
* winMsgWindowProc - Window procedure for msg window
|
||||
*/
|
||||
|
||||
static
|
||||
LRESULT CALLBACK
|
||||
winMsgWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
#if CYGDEBUG
|
||||
winDebugWin32Message("winMsgWindowProc", hwnd, message, wParam, lParam);
|
||||
#endif
|
||||
|
||||
switch (message) {
|
||||
case WM_ENDSESSION:
|
||||
if (!wParam)
|
||||
return 0; /* shutdown is being cancelled */
|
||||
|
||||
/*
|
||||
Send a WM_GIVEUP message to the X server thread so it wakes up if
|
||||
blocked in select(), performs GiveUp(), and then notices that GiveUp()
|
||||
has set the DE_TERMINATE flag so exits the msg dispatch loop.
|
||||
*/
|
||||
{
|
||||
ScreenPtr pScreen = screenInfo.screens[0];
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
PostMessage(pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
This process will be terminated by the system almost immediately
|
||||
after the last thread with a message queue returns from processing
|
||||
WM_ENDSESSION, so we cannot rely on any code executing after this
|
||||
message is processed and need to wait here until ddxGiveUp() is called
|
||||
and releases the termination mutex to guarantee that the lock file and
|
||||
unix domain sockets have been removed
|
||||
|
||||
ofc, Microsoft doesn't document this under WM_ENDSESSION, you are supposed
|
||||
to read the source of CRSS to find out how it works :-)
|
||||
|
||||
http://blogs.msdn.com/b/michen/archive/2008/04/04/application-termination-when-user-logs-off.aspx
|
||||
*/
|
||||
{
|
||||
int iReturn = pthread_mutex_lock(&g_pmTerminating);
|
||||
|
||||
if (iReturn != 0) {
|
||||
ErrorF("winMsgWindowProc - pthread_mutex_lock () failed: %d\n",
|
||||
iReturn);
|
||||
}
|
||||
winDebug
|
||||
("winMsgWindowProc - WM_ENDSESSION termination lock acquired\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
static HWND
|
||||
winCreateMsgWindow(void)
|
||||
{
|
||||
HWND hwndMsg;
|
||||
|
||||
// register window class
|
||||
{
|
||||
WNDCLASSEX wcx;
|
||||
|
||||
wcx.cbSize = sizeof(WNDCLASSEX);
|
||||
wcx.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcx.lpfnWndProc = winMsgWindowProc;
|
||||
wcx.cbClsExtra = 0;
|
||||
wcx.cbWndExtra = 0;
|
||||
wcx.hInstance = g_hInstance;
|
||||
wcx.hIcon = NULL;
|
||||
wcx.hCursor = 0;
|
||||
wcx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
wcx.lpszMenuName = NULL;
|
||||
wcx.lpszClassName = WINDOW_CLASS_X_MSG;
|
||||
wcx.hIconSm = NULL;
|
||||
RegisterClassEx(&wcx);
|
||||
}
|
||||
|
||||
// Create the msg window.
|
||||
hwndMsg = CreateWindowEx(0, // no extended styles
|
||||
WINDOW_CLASS_X_MSG, // class name
|
||||
"XWin Msg Window", // window name
|
||||
WS_OVERLAPPEDWINDOW, // overlapped window
|
||||
CW_USEDEFAULT, // default horizontal position
|
||||
CW_USEDEFAULT, // default vertical position
|
||||
CW_USEDEFAULT, // default width
|
||||
CW_USEDEFAULT, // default height
|
||||
(HWND) NULL, // no parent or owner window
|
||||
(HMENU) NULL, // class menu used
|
||||
GetModuleHandle(NULL), // instance handle
|
||||
NULL); // no window creation data
|
||||
|
||||
if (!hwndMsg) {
|
||||
ErrorF("winCreateMsgWindow - Create msg window failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
winDebug("winCreateMsgWindow - Created msg window hwnd 0x%p\n", hwndMsg);
|
||||
|
||||
return hwndMsg;
|
||||
}
|
||||
|
||||
static void *
|
||||
winMsgWindowThreadProc(void *arg)
|
||||
{
|
||||
HWND hwndMsg;
|
||||
|
||||
winDebug("winMsgWindowThreadProc - Hello\n");
|
||||
|
||||
hwndMsg = winCreateMsgWindow();
|
||||
if (hwndMsg) {
|
||||
MSG msg;
|
||||
|
||||
/* Pump the msg window message queue */
|
||||
while (GetMessage(&msg, hwndMsg, 0, 0) > 0) {
|
||||
#if CYGDEBUG
|
||||
winDebugWin32Message("winMsgWindowThread", msg.hwnd, msg.message,
|
||||
msg.wParam, msg.lParam);
|
||||
#endif
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
winDebug("winMsgWindowThreadProc - Exit\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Bool
|
||||
winCreateMsgWindowThread(void)
|
||||
{
|
||||
pthread_t ptMsgWindowThreadProc;
|
||||
|
||||
/* Spawn a thread for the msg window */
|
||||
if (pthread_create(&ptMsgWindowThreadProc,
|
||||
NULL, winMsgWindowThreadProc, NULL)) {
|
||||
/* Bail if thread creation failed */
|
||||
ErrorF("winCreateMsgWindow - pthread_create failed.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,300 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include <X11/Xatom.h>
|
||||
#include "propertyst.h"
|
||||
#include "windowstr.h"
|
||||
#include "winmultiwindowclass.h"
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* Local function
|
||||
*/
|
||||
|
||||
DEFINE_ATOM_HELPER(AtmWmWindowRole, "WM_WINDOW_ROLE")
|
||||
|
||||
int
|
||||
winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class)
|
||||
{
|
||||
struct _Window *pwin;
|
||||
struct _Property *prop;
|
||||
int len_name, len_class;
|
||||
|
||||
if (!pWin || !res_name || !res_class) {
|
||||
ErrorF("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
|
||||
"NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pwin = (struct _Window *) pWin;
|
||||
|
||||
if (pwin->optional)
|
||||
prop = (struct _Property *) pwin->optional->userProps;
|
||||
else
|
||||
prop = NULL;
|
||||
|
||||
*res_name = *res_class = NULL;
|
||||
|
||||
while (prop) {
|
||||
if (prop->propertyName == XA_WM_CLASS
|
||||
&& prop->type == XA_STRING && prop->format == 8 && prop->data) {
|
||||
/*
|
||||
WM_CLASS property should consist of 2 null terminated strings, but we
|
||||
must handle the cases when one or both is absent or not null terminated
|
||||
*/
|
||||
len_name = strlen((char *) prop->data);
|
||||
if (len_name > prop->size) len_name = prop->size;
|
||||
|
||||
(*res_name) = malloc(len_name + 1);
|
||||
|
||||
if (!*res_name) {
|
||||
ErrorF("winMultiWindowGetClassHint - *res_name was NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy name and ensure null terminated */
|
||||
strncpy((*res_name), prop->data, len_name);
|
||||
(*res_name)[len_name] = '\0';
|
||||
|
||||
/* Compute length of class name, it could be that it is absent or not null terminated */
|
||||
len_class = (len_name >= prop->size) ? 0 : (strlen(((char *) prop->data) + 1 + len_name));
|
||||
if (len_class > prop->size - 1 - len_name) len_class = prop->size - 1 - len_name;
|
||||
|
||||
(*res_class) = malloc(len_class + 1);
|
||||
|
||||
if (!*res_class) {
|
||||
ErrorF("winMultiWindowGetClassHint - *res_class was NULL\n");
|
||||
|
||||
/* Free the previously allocated res_name */
|
||||
free(*res_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy class name and ensure null terminated */
|
||||
strncpy((*res_class), ((char *) prop->data) + 1 + len_name, len_class);
|
||||
(*res_class)[len_class] = '\0';
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
winMultiWindowGetWMHints(WindowPtr pWin, WinXWMHints * hints)
|
||||
{
|
||||
struct _Window *pwin;
|
||||
struct _Property *prop;
|
||||
|
||||
if (!pWin || !hints) {
|
||||
ErrorF("winMultiWindowGetWMHints - pWin or hints was NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pwin = (struct _Window *) pWin;
|
||||
|
||||
if (pwin->optional)
|
||||
prop = (struct _Property *) pwin->optional->userProps;
|
||||
else
|
||||
prop = NULL;
|
||||
|
||||
memset(hints, 0, sizeof(WinXWMHints));
|
||||
|
||||
while (prop) {
|
||||
if (prop->propertyName == XA_WM_HINTS && prop->data) {
|
||||
memcpy(hints, prop->data, sizeof(WinXWMHints));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
winMultiWindowGetWindowRole(WindowPtr pWin, char **res_role)
|
||||
{
|
||||
struct _Window *pwin;
|
||||
struct _Property *prop;
|
||||
int len_role;
|
||||
|
||||
if (!pWin || !res_role)
|
||||
return 0;
|
||||
|
||||
pwin = (struct _Window *) pWin;
|
||||
|
||||
if (pwin->optional)
|
||||
prop = (struct _Property *) pwin->optional->userProps;
|
||||
else
|
||||
prop = NULL;
|
||||
|
||||
*res_role = NULL;
|
||||
while (prop) {
|
||||
if (prop->propertyName == AtmWmWindowRole()
|
||||
&& prop->type == XA_STRING && prop->format == 8 && prop->data) {
|
||||
len_role = prop->size;
|
||||
|
||||
(*res_role) = malloc(len_role + 1);
|
||||
|
||||
if (!*res_role) {
|
||||
ErrorF("winMultiWindowGetWindowRole - *res_role was NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy((*res_role), prop->data, len_role);
|
||||
(*res_role)[len_role] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
winMultiWindowGetWMNormalHints(WindowPtr pWin, WinXSizeHints * hints)
|
||||
{
|
||||
struct _Window *pwin;
|
||||
struct _Property *prop;
|
||||
|
||||
if (!pWin || !hints) {
|
||||
ErrorF("winMultiWindowGetWMNormalHints - pWin or hints was NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pwin = (struct _Window *) pWin;
|
||||
|
||||
if (pwin->optional)
|
||||
prop = (struct _Property *) pwin->optional->userProps;
|
||||
else
|
||||
prop = NULL;
|
||||
|
||||
memset(hints, 0, sizeof(WinXSizeHints));
|
||||
|
||||
while (prop) {
|
||||
if (prop->propertyName == XA_WM_NORMAL_HINTS && prop->data) {
|
||||
memcpy(hints, prop->data, sizeof(WinXSizeHints));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
winMultiWindowGetTransientFor(WindowPtr pWin, Window *pDaddyId)
|
||||
{
|
||||
struct _Window *pwin;
|
||||
struct _Property *prop;
|
||||
|
||||
if (!pWin) {
|
||||
ErrorF("winMultiWindowGetTransientFor - pWin was NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pwin = (struct _Window *) pWin;
|
||||
|
||||
if (pwin->optional)
|
||||
prop = (struct _Property *) pwin->optional->userProps;
|
||||
else
|
||||
prop = NULL;
|
||||
|
||||
if (pDaddyId)
|
||||
*pDaddyId = 0;
|
||||
|
||||
while (prop) {
|
||||
if (prop->propertyName == XA_WM_TRANSIENT_FOR) {
|
||||
if (pDaddyId)
|
||||
memcpy(pDaddyId, prop->data, sizeof(Window));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
winMultiWindowGetWMName(WindowPtr pWin, char **wmName)
|
||||
{
|
||||
struct _Window *pwin;
|
||||
struct _Property *prop;
|
||||
int len_name;
|
||||
|
||||
if (!pWin || !wmName) {
|
||||
ErrorF("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
|
||||
"NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pwin = (struct _Window *) pWin;
|
||||
|
||||
if (pwin->optional)
|
||||
prop = (struct _Property *) pwin->optional->userProps;
|
||||
else
|
||||
prop = NULL;
|
||||
|
||||
*wmName = NULL;
|
||||
|
||||
while (prop) {
|
||||
if (prop->propertyName == XA_WM_NAME
|
||||
&& prop->type == XA_STRING && prop->data) {
|
||||
len_name = prop->size;
|
||||
|
||||
(*wmName) = malloc(len_name + 1);
|
||||
|
||||
if (!*wmName) {
|
||||
ErrorF("winMultiWindowGetWMName - *wmName was NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy((*wmName), prop->data, len_name);
|
||||
(*wmName)[len_name] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
#if !defined(WINMULTIWINDOWCLASS_H)
|
||||
#define WINMULTIWINDOWCLASS_H
|
||||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
*/
|
||||
|
||||
/*
|
||||
* The next block of definitions are for window manager properties that
|
||||
* clients and applications use for communication.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* WM_HINTS structure
|
||||
*
|
||||
* NOTE: this structure represents the internal format stored in the property
|
||||
* after it is marshalled by libX11, converting the flags field from an
|
||||
* arch-dependent long to a 32-bit int.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int flags; /* marks which fields in this structure are defined */
|
||||
Bool input; /* does this application rely on the window manager to
|
||||
get keyboard input? */
|
||||
int initial_state; /* see below */
|
||||
Pixmap icon_pixmap; /* pixmap to be used as icon */
|
||||
Window icon_window; /* window to be used as icon */
|
||||
int icon_x, icon_y; /* initial position of icon */
|
||||
Pixmap icon_mask; /* icon mask bitmap */
|
||||
XID window_group; /* id of related window group */
|
||||
/* this structure may be extended in the future */
|
||||
} WinXWMHints;
|
||||
|
||||
/* Window manager hints mask bits */
|
||||
#define InputHint (1L << 0)
|
||||
#define StateHint (1L << 1)
|
||||
#define IconPixmapHint (1L << 2)
|
||||
#define IconWindowHint (1L << 3)
|
||||
#define IconPositionHint (1L << 4)
|
||||
#define IconMaskHint (1L << 5)
|
||||
#define WindowGroupHint (1L << 6)
|
||||
#define UrgencyHint (1L << 8)
|
||||
#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint|IconPositionHint|IconMaskHint|WindowGroupHint)
|
||||
|
||||
/*
|
||||
* ICCCM 1.0 version containing base_width, base_height, and win_gravity fields;
|
||||
* used with WM_NORMAL_HINTS.
|
||||
*
|
||||
* NOTE: this structure represents the internal format stored in the property
|
||||
* after it is marshalled by libX11, converting the flags field from an
|
||||
* arch-dependent long to a 32-bit int.
|
||||
*/
|
||||
typedef struct {
|
||||
int flags; /* marks which fields in this structure are defined */
|
||||
int x, y; /* obsolete for new window mgrs, but clients */
|
||||
int width, height; /* should set so old wm's don't mess up */
|
||||
int min_width, min_height;
|
||||
int max_width, max_height;
|
||||
int width_inc, height_inc;
|
||||
struct {
|
||||
int x; /* numerator */
|
||||
int y; /* denominator */
|
||||
} min_aspect, max_aspect;
|
||||
int base_width, base_height; /* added by ICCCM version 1 */
|
||||
int win_gravity; /* added by ICCCM version 1 */
|
||||
} WinXSizeHints;
|
||||
|
||||
/* flags argument in size hints */
|
||||
#define USPosition (1L << 0) /* user specified x, y */
|
||||
#define USSize (1L << 1) /* user specified width, height */
|
||||
|
||||
#define PPosition (1L << 2) /* program specified position */
|
||||
#define PSize (1L << 3) /* program specified size */
|
||||
#define PMinSize (1L << 4) /* program specified minimum size */
|
||||
#define PMaxSize (1L << 5) /* program specified maximum size */
|
||||
#define PResizeInc (1L << 6) /* program specified resize increments */
|
||||
#define PAspect (1L << 7) /* program specified min and max aspect ratios */
|
||||
#define PBaseSize (1L << 8) /* program specified base for incrementing */
|
||||
#define PWinGravity (1L << 9) /* program specified window gravity */
|
||||
|
||||
/* obsolete */
|
||||
#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
int
|
||||
winMultiWindowGetWMHints(WindowPtr pWin, WinXWMHints * hints);
|
||||
|
||||
int
|
||||
winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class);
|
||||
|
||||
int
|
||||
winMultiWindowGetWindowRole(WindowPtr pWin, char **res_role);
|
||||
|
||||
int
|
||||
winMultiWindowGetWMNormalHints(WindowPtr pWin, WinXSizeHints * hints);
|
||||
|
||||
int
|
||||
winMultiWindowGetWMName(WindowPtr pWin, char **wmName);
|
||||
|
||||
int
|
||||
winMultiWindowGetTransientFor(WindowPtr pWin, Window *ppDaddy);
|
||||
|
||||
#endif
|
|
@ -1,671 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef WINVER
|
||||
#define WINVER 0x0500
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_icccm.h>
|
||||
#include <xcb/xcb_image.h>
|
||||
|
||||
#include "winresource.h"
|
||||
#include "winprefs.h"
|
||||
#include "winmsg.h"
|
||||
#include "winmultiwindowicons.h"
|
||||
#include "winglobals.h"
|
||||
|
||||
/*
|
||||
* global variables
|
||||
*/
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
/*
|
||||
* Scale an X icon ZPixmap into a Windoze icon bitmap
|
||||
*/
|
||||
|
||||
static void
|
||||
winScaleXImageToWindowsIcon(int iconSize,
|
||||
int effBPP,
|
||||
int stride, xcb_image_t* pixmap, unsigned char *image)
|
||||
{
|
||||
int row, column, effXBPP, effXDepth;
|
||||
unsigned char *outPtr;
|
||||
unsigned char *iconData = 0;
|
||||
int xStride;
|
||||
float factX, factY;
|
||||
int posX, posY;
|
||||
unsigned char *ptr;
|
||||
unsigned int zero;
|
||||
unsigned int color;
|
||||
|
||||
effXBPP = pixmap->bpp;
|
||||
if (pixmap->bpp == 15)
|
||||
effXBPP = 16;
|
||||
|
||||
effXDepth = pixmap->depth;
|
||||
if (pixmap->depth == 15)
|
||||
effXDepth = 16;
|
||||
|
||||
xStride = pixmap->stride;
|
||||
if (stride == 0 || xStride == 0) {
|
||||
ErrorF("winScaleXBitmapToWindows - stride or xStride is zero. "
|
||||
"Bailing.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get icon data */
|
||||
iconData = (unsigned char *) pixmap->data;
|
||||
|
||||
/* Keep aspect ratio */
|
||||
factX = ((float) pixmap->width) / ((float) iconSize);
|
||||
factY = ((float) pixmap->height) / ((float) iconSize);
|
||||
if (factX > factY)
|
||||
factY = factX;
|
||||
else
|
||||
factX = factY;
|
||||
|
||||
/* Out-of-bounds, fill icon with zero */
|
||||
zero = 0;
|
||||
|
||||
for (row = 0; row < iconSize; row++) {
|
||||
outPtr = image + stride * row;
|
||||
for (column = 0; column < iconSize; column++) {
|
||||
posX = factX * column;
|
||||
posY = factY * row;
|
||||
|
||||
ptr = (unsigned char *) iconData + posY * xStride;
|
||||
if (effXBPP == 1) {
|
||||
ptr += posX / 8;
|
||||
|
||||
/* Out of X icon bounds, leave space blank */
|
||||
if (posX >= pixmap->width || posY >= pixmap->height)
|
||||
ptr = (unsigned char *) &zero;
|
||||
|
||||
if ((*ptr) & (1 << (posX & 7)))
|
||||
switch (effBPP) {
|
||||
case 32:
|
||||
*(outPtr++) = 0;
|
||||
case 24:
|
||||
*(outPtr++) = 0;
|
||||
case 16:
|
||||
*(outPtr++) = 0;
|
||||
case 8:
|
||||
*(outPtr++) = 0;
|
||||
break;
|
||||
case 1:
|
||||
outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch (effBPP) {
|
||||
case 32:
|
||||
*(outPtr++) = 255;
|
||||
*(outPtr++) = 255;
|
||||
*(outPtr++) = 255;
|
||||
*(outPtr++) = 0;
|
||||
break;
|
||||
case 24:
|
||||
*(outPtr++) = 255;
|
||||
case 16:
|
||||
*(outPtr++) = 255;
|
||||
case 8:
|
||||
*(outPtr++) = 255;
|
||||
break;
|
||||
case 1:
|
||||
outPtr[column / 8] |= (1 << (7 - (column & 7)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (effXDepth == 24 || effXDepth == 32) {
|
||||
ptr += posX * (effXBPP / 8);
|
||||
|
||||
/* Out of X icon bounds, leave space blank */
|
||||
if (posX >= pixmap->width || posY >= pixmap->height)
|
||||
ptr = (unsigned char *) &zero;
|
||||
color = (((*ptr) << 16)
|
||||
+ ((*(ptr + 1)) << 8)
|
||||
+ ((*(ptr + 2)) << 0));
|
||||
switch (effBPP) {
|
||||
case 32:
|
||||
*(outPtr++) = *(ptr++); /* b */
|
||||
*(outPtr++) = *(ptr++); /* g */
|
||||
*(outPtr++) = *(ptr++); /* r */
|
||||
*(outPtr++) = (effXDepth == 32) ? *(ptr++) : 0x0; /* alpha */
|
||||
break;
|
||||
case 24:
|
||||
*(outPtr++) = *(ptr++);
|
||||
*(outPtr++) = *(ptr++);
|
||||
*(outPtr++) = *(ptr++);
|
||||
break;
|
||||
case 16:
|
||||
color = ((((*ptr) >> 2) << 10)
|
||||
+ (((*(ptr + 1)) >> 2) << 5)
|
||||
+ (((*(ptr + 2)) >> 2)));
|
||||
*(outPtr++) = (color >> 8);
|
||||
*(outPtr++) = (color & 255);
|
||||
break;
|
||||
case 8:
|
||||
color = (((*ptr))) + (((*(ptr + 1)))) + (((*(ptr + 2))));
|
||||
color /= 3;
|
||||
*(outPtr++) = color;
|
||||
break;
|
||||
case 1:
|
||||
if (color)
|
||||
outPtr[column / 8] |= (1 << (7 - (column & 7)));
|
||||
else
|
||||
outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
|
||||
}
|
||||
}
|
||||
else if (effXDepth == 16) {
|
||||
ptr += posX * (effXBPP / 8);
|
||||
|
||||
/* Out of X icon bounds, leave space blank */
|
||||
if (posX >= pixmap->width || posY >= pixmap->height)
|
||||
ptr = (unsigned char *) &zero;
|
||||
color = ((*ptr) << 8) + (*(ptr + 1));
|
||||
switch (effBPP) {
|
||||
case 32:
|
||||
*(outPtr++) = (color & 31) << 2;
|
||||
*(outPtr++) = ((color >> 5) & 31) << 2;
|
||||
*(outPtr++) = ((color >> 10) & 31) << 2;
|
||||
*(outPtr++) = 0; /* resvd */
|
||||
break;
|
||||
case 24:
|
||||
*(outPtr++) = (color & 31) << 2;
|
||||
*(outPtr++) = ((color >> 5) & 31) << 2;
|
||||
*(outPtr++) = ((color >> 10) & 31) << 2;
|
||||
break;
|
||||
case 16:
|
||||
*(outPtr++) = *(ptr++);
|
||||
*(outPtr++) = *(ptr++);
|
||||
break;
|
||||
case 8:
|
||||
*(outPtr++) = (((color & 31)
|
||||
+ ((color >> 5) & 31)
|
||||
+ ((color >> 10) & 31)) / 3) << 2;
|
||||
break;
|
||||
case 1:
|
||||
if (color)
|
||||
outPtr[column / 8] |= (1 << (7 - (column & 7)));
|
||||
else
|
||||
outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
|
||||
break;
|
||||
} /* end switch(effbpp) */
|
||||
} /* end if effxbpp==16) */
|
||||
} /* end for column */
|
||||
} /* end for row */
|
||||
}
|
||||
|
||||
static HICON
|
||||
NetWMToWinIconAlpha(uint32_t * icon)
|
||||
{
|
||||
int width = icon[0];
|
||||
int height = icon[1];
|
||||
uint32_t *pixels = &icon[2];
|
||||
HICON result;
|
||||
HDC hdc = GetDC(NULL);
|
||||
uint32_t *DIB_pixels;
|
||||
ICONINFO ii;
|
||||
BITMAPV4HEADER bmh = { sizeof(bmh) };
|
||||
|
||||
/* Define an ARGB pixel format used for Color+Alpha icons */
|
||||
bmh.bV4Width = width;
|
||||
bmh.bV4Height = -height; /* Invert the image */
|
||||
bmh.bV4Planes = 1;
|
||||
bmh.bV4BitCount = 32;
|
||||
bmh.bV4V4Compression = BI_BITFIELDS;
|
||||
bmh.bV4AlphaMask = 0xFF000000;
|
||||
bmh.bV4RedMask = 0x00FF0000;
|
||||
bmh.bV4GreenMask = 0x0000FF00;
|
||||
bmh.bV4BlueMask = 0x000000FF;
|
||||
|
||||
ii.fIcon = TRUE;
|
||||
ii.xHotspot = 0; /* ignored */
|
||||
ii.yHotspot = 0; /* ignored */
|
||||
ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO *) &bmh,
|
||||
DIB_RGB_COLORS, (void **) &DIB_pixels, NULL,
|
||||
0);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
if (!ii.hbmColor)
|
||||
return NULL;
|
||||
|
||||
ii.hbmMask = CreateBitmap(width, height, 1, 1, NULL);
|
||||
memcpy(DIB_pixels, pixels, height * width * 4);
|
||||
|
||||
/* CreateIconIndirect() traditionally required DDBitmaps */
|
||||
/* Systems from WinXP accept 32-bit ARGB DIBitmaps with full 8-bit alpha support */
|
||||
/* The icon is created with a DIB + empty DDB mask (an MS example does the same) */
|
||||
result = CreateIconIndirect(&ii);
|
||||
|
||||
DeleteObject(ii.hbmColor);
|
||||
DeleteObject(ii.hbmMask);
|
||||
|
||||
winDebug("NetWMToWinIconAlpha - %d x %d = %p\n", icon[0], icon[1], result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static HICON
|
||||
NetWMToWinIconThreshold(uint32_t * icon)
|
||||
{
|
||||
int width = icon[0];
|
||||
int height = icon[1];
|
||||
uint32_t *pixels = &icon[2];
|
||||
int row, col;
|
||||
HICON result;
|
||||
ICONINFO ii;
|
||||
|
||||
HDC hdc = GetDC(NULL);
|
||||
HDC xorDC = CreateCompatibleDC(hdc);
|
||||
HDC andDC = CreateCompatibleDC(hdc);
|
||||
|
||||
ii.fIcon = TRUE;
|
||||
ii.xHotspot = 0; /* ignored */
|
||||
ii.yHotspot = 0; /* ignored */
|
||||
ii.hbmColor = CreateCompatibleBitmap(hdc, width, height);
|
||||
ii.hbmMask = CreateCompatibleBitmap(hdc, width, height);
|
||||
ReleaseDC(NULL, hdc);
|
||||
SelectObject(xorDC, ii.hbmColor);
|
||||
SelectObject(andDC, ii.hbmMask);
|
||||
|
||||
for (row = 0; row < height; row++) {
|
||||
for (col = 0; col < width; col++) {
|
||||
if ((*pixels & 0xFF000000) > 31 << 24) { /* 31 alpha threshold, i.e. opaque above, transparent below */
|
||||
SetPixelV(xorDC, col, row,
|
||||
RGB(((char *) pixels)[2], ((char *) pixels)[1],
|
||||
((char *) pixels)[0]));
|
||||
SetPixelV(andDC, col, row, RGB(0, 0, 0)); /* black mask */
|
||||
}
|
||||
else {
|
||||
SetPixelV(xorDC, col, row, RGB(0, 0, 0));
|
||||
SetPixelV(andDC, col, row, RGB(255, 255, 255)); /* white mask */
|
||||
}
|
||||
pixels++;
|
||||
}
|
||||
}
|
||||
DeleteDC(xorDC);
|
||||
DeleteDC(andDC);
|
||||
|
||||
result = CreateIconIndirect(&ii);
|
||||
|
||||
DeleteObject(ii.hbmColor);
|
||||
DeleteObject(ii.hbmMask);
|
||||
|
||||
winDebug("NetWMToWinIconThreshold - %d x %d = %p\n", icon[0], icon[1],
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static HICON
|
||||
NetWMToWinIcon(int bpp, uint32_t * icon)
|
||||
{
|
||||
static bool hasIconAlphaChannel = FALSE;
|
||||
static bool versionChecked = FALSE;
|
||||
|
||||
if (!versionChecked) {
|
||||
OSVERSIONINFOEX osvi = { 0 };
|
||||
ULONGLONG dwlConditionMask = 0;
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
osvi.dwMajorVersion = 5;
|
||||
osvi.dwMinorVersion = 1;
|
||||
|
||||
/* Windows versions later than XP have icon alpha channel support, 2000 does not */
|
||||
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION,
|
||||
VER_GREATER_EQUAL);
|
||||
VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION,
|
||||
VER_GREATER_EQUAL);
|
||||
hasIconAlphaChannel =
|
||||
VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION,
|
||||
dwlConditionMask);
|
||||
versionChecked = TRUE;
|
||||
|
||||
ErrorF("OS has icon alpha channel support: %s\n",
|
||||
hasIconAlphaChannel ? "yes" : "no");
|
||||
}
|
||||
|
||||
if (hasIconAlphaChannel && (bpp == 32))
|
||||
return NetWMToWinIconAlpha(icon);
|
||||
else
|
||||
return NetWMToWinIconThreshold(icon);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to create a custom icon from the WM_HINTS bitmaps
|
||||
*/
|
||||
|
||||
static
|
||||
HICON
|
||||
winXIconToHICON(xcb_connection_t *conn, xcb_window_t id, int iconSize)
|
||||
{
|
||||
unsigned char *mask, *image = NULL, *imageMask;
|
||||
unsigned char *dst, *src;
|
||||
int planes, bpp, i;
|
||||
unsigned int biggest_size = 0;
|
||||
HDC hDC;
|
||||
ICONINFO ii;
|
||||
xcb_icccm_wm_hints_t hints;
|
||||
HICON hIcon = NULL;
|
||||
uint32_t *biggest_icon = NULL;
|
||||
static xcb_atom_t _XA_NET_WM_ICON;
|
||||
static int generation;
|
||||
uint32_t *icon, *icon_data = NULL;
|
||||
unsigned long int size;
|
||||
|
||||
hDC = GetDC(GetDesktopWindow());
|
||||
planes = GetDeviceCaps(hDC, PLANES);
|
||||
bpp = GetDeviceCaps(hDC, BITSPIXEL);
|
||||
ReleaseDC(GetDesktopWindow(), hDC);
|
||||
|
||||
/* Always prefer _NET_WM_ICON icons */
|
||||
if (generation != serverGeneration) {
|
||||
xcb_intern_atom_reply_t *atom_reply;
|
||||
xcb_intern_atom_cookie_t atom_cookie;
|
||||
const char *atomName = "_NET_WM_ICON";
|
||||
|
||||
generation = serverGeneration;
|
||||
|
||||
_XA_NET_WM_ICON = XCB_NONE;
|
||||
|
||||
atom_cookie = xcb_intern_atom(conn, 0, strlen(atomName), atomName);
|
||||
atom_reply = xcb_intern_atom_reply(conn, atom_cookie, NULL);
|
||||
if (atom_reply) {
|
||||
_XA_NET_WM_ICON = atom_reply->atom;
|
||||
free(atom_reply);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
xcb_get_property_cookie_t cookie = xcb_get_property(conn, FALSE, id, _XA_NET_WM_ICON, XCB_ATOM_CARDINAL, 0L, INT_MAX);
|
||||
xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL);
|
||||
|
||||
if (reply &&
|
||||
((icon_data = xcb_get_property_value(reply)) != NULL)) {
|
||||
size = xcb_get_property_value_length(reply)/sizeof(uint32_t);
|
||||
for (icon = icon_data; icon < &icon_data[size] && *icon;
|
||||
icon = &icon[icon[0] * icon[1] + 2]) {
|
||||
winDebug("winXIconToHICON: %u x %u NetIcon\n", icon[0], icon[1]);
|
||||
|
||||
/* Icon data size will overflow an int and thus is bigger than the
|
||||
property can possibly be */
|
||||
if ((INT_MAX/icon[0]) < icon[1]) {
|
||||
winDebug("winXIconToHICON: _NET_WM_ICON icon data size overflow\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Icon data size is bigger than amount of data remaining */
|
||||
if (&icon[icon[0] * icon[1] + 2] > &icon_data[size]) {
|
||||
winDebug("winXIconToHICON: _NET_WM_ICON data is malformed\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Found an exact match to the size we require... */
|
||||
if (icon[0] == iconSize && icon[1] == iconSize) {
|
||||
winDebug("winXIconToHICON: selected %d x %d NetIcon\n",
|
||||
iconSize, iconSize);
|
||||
hIcon = NetWMToWinIcon(bpp, icon);
|
||||
break;
|
||||
}
|
||||
/* Otherwise, find the biggest icon and let Windows scale the size */
|
||||
else if (biggest_size < icon[0]) {
|
||||
biggest_icon = icon;
|
||||
biggest_size = icon[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (!hIcon && biggest_icon) {
|
||||
winDebug
|
||||
("winXIconToHICON: selected %u x %u NetIcon for scaling to %d x %d\n",
|
||||
biggest_icon[0], biggest_icon[1], iconSize, iconSize);
|
||||
|
||||
hIcon = NetWMToWinIcon(bpp, biggest_icon);
|
||||
}
|
||||
|
||||
free(reply);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hIcon) {
|
||||
xcb_get_property_cookie_t wm_hints_cookie;
|
||||
|
||||
winDebug("winXIconToHICON: no suitable NetIcon\n");
|
||||
|
||||
wm_hints_cookie = xcb_icccm_get_wm_hints(conn, id);
|
||||
if (xcb_icccm_get_wm_hints_reply(conn, wm_hints_cookie, &hints, NULL)) {
|
||||
winDebug("winXIconToHICON: id 0x%x icon_pixmap hint 0x%x\n",
|
||||
(unsigned int)id,
|
||||
(unsigned int)hints.icon_pixmap);
|
||||
|
||||
if (hints.icon_pixmap) {
|
||||
unsigned int width, height;
|
||||
xcb_image_t *xImageIcon;
|
||||
xcb_image_t *xImageMask = NULL;
|
||||
|
||||
xcb_get_geometry_cookie_t geom_cookie = xcb_get_geometry(conn, hints.icon_pixmap);
|
||||
xcb_get_geometry_reply_t *geom_reply = xcb_get_geometry_reply(conn, geom_cookie, NULL);
|
||||
|
||||
if (geom_reply) {
|
||||
width = geom_reply->width;
|
||||
height = geom_reply->height;
|
||||
|
||||
xImageIcon = xcb_image_get(conn, hints.icon_pixmap,
|
||||
0, 0, width, height,
|
||||
0xFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP);
|
||||
|
||||
winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%p\n",
|
||||
(unsigned int)id, xImageIcon);
|
||||
|
||||
if (hints.icon_mask)
|
||||
xImageMask = xcb_image_get(conn, hints.icon_mask,
|
||||
0, 0, width, height,
|
||||
0xFFFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP);
|
||||
|
||||
if (xImageIcon) {
|
||||
int effBPP, stride, maskStride;
|
||||
|
||||
/* 15 BPP is really 16BPP as far as we care */
|
||||
if (bpp == 15)
|
||||
effBPP = 16;
|
||||
else
|
||||
effBPP = bpp;
|
||||
|
||||
/* Need 16-bit aligned rows for DDBitmaps */
|
||||
stride = ((iconSize * effBPP + 15) & (~15)) / 8;
|
||||
|
||||
/* Mask is 1-bit deep */
|
||||
maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
|
||||
|
||||
image = malloc(stride * iconSize);
|
||||
imageMask = malloc(stride * iconSize);
|
||||
mask = malloc(maskStride * iconSize);
|
||||
|
||||
/* Default to a completely black mask */
|
||||
memset(imageMask, 0, stride * iconSize);
|
||||
memset(mask, 0, maskStride * iconSize);
|
||||
|
||||
winScaleXImageToWindowsIcon(iconSize, effBPP, stride,
|
||||
xImageIcon, image);
|
||||
|
||||
if (xImageMask) {
|
||||
winScaleXImageToWindowsIcon(iconSize, 1, maskStride,
|
||||
xImageMask, mask);
|
||||
winScaleXImageToWindowsIcon(iconSize, effBPP, stride,
|
||||
xImageMask, imageMask);
|
||||
}
|
||||
|
||||
/* Now we need to set all bits of the icon which are not masked */
|
||||
/* on to 0 because Color is really an XOR, not an OR function */
|
||||
dst = image;
|
||||
src = imageMask;
|
||||
|
||||
for (i = 0; i < (stride * iconSize); i++)
|
||||
if ((*(src++)))
|
||||
*(dst++) = 0;
|
||||
else
|
||||
dst++;
|
||||
|
||||
ii.fIcon = TRUE;
|
||||
ii.xHotspot = 0; /* ignored */
|
||||
ii.yHotspot = 0; /* ignored */
|
||||
|
||||
/* Create Win32 mask from pixmap shape */
|
||||
ii.hbmMask =
|
||||
CreateBitmap(iconSize, iconSize, planes, 1, mask);
|
||||
|
||||
/* Create Win32 bitmap from pixmap */
|
||||
ii.hbmColor =
|
||||
CreateBitmap(iconSize, iconSize, planes, bpp, image);
|
||||
|
||||
/* Merge Win32 mask and bitmap into icon */
|
||||
hIcon = CreateIconIndirect(&ii);
|
||||
|
||||
/* Release Win32 mask and bitmap */
|
||||
DeleteObject(ii.hbmMask);
|
||||
DeleteObject(ii.hbmColor);
|
||||
|
||||
/* Free X mask and bitmap */
|
||||
free(mask);
|
||||
free(image);
|
||||
free(imageMask);
|
||||
|
||||
if (xImageMask)
|
||||
xcb_image_destroy(xImageMask);
|
||||
|
||||
xcb_image_destroy(xImageIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return hIcon;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the Windows window icon
|
||||
*/
|
||||
|
||||
void
|
||||
winUpdateIcon(HWND hWnd, xcb_connection_t *conn, xcb_window_t id, HICON hIconNew)
|
||||
{
|
||||
HICON hIcon, hIconSmall = NULL, hIconOld;
|
||||
|
||||
if (hIconNew)
|
||||
{
|
||||
/* Start with the icon from preferences, if any */
|
||||
hIcon = hIconNew;
|
||||
hIconSmall = hIconNew;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If we still need an icon, try and get the icon from WM_HINTS */
|
||||
hIcon = winXIconToHICON(conn, id, GetSystemMetrics(SM_CXICON));
|
||||
hIconSmall = winXIconToHICON(conn, id, GetSystemMetrics(SM_CXSMICON));
|
||||
}
|
||||
|
||||
/* If we got the small, but not the large one swap them */
|
||||
if (!hIcon && hIconSmall) {
|
||||
hIcon = hIconSmall;
|
||||
hIconSmall = NULL;
|
||||
}
|
||||
|
||||
/* Set the large icon */
|
||||
hIconOld = (HICON) SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
|
||||
/* Delete the old icon if its not the default */
|
||||
winDestroyIcon(hIconOld);
|
||||
|
||||
/* Same for the small icon */
|
||||
hIconOld =
|
||||
(HICON) SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
|
||||
winDestroyIcon(hIconOld);
|
||||
}
|
||||
|
||||
void
|
||||
winInitGlobalIcons(void)
|
||||
{
|
||||
int sm_cx = GetSystemMetrics(SM_CXICON);
|
||||
int sm_cxsm = GetSystemMetrics(SM_CXSMICON);
|
||||
|
||||
/* Load default X icon in case it's not ready yet */
|
||||
if (!g_hIconX) {
|
||||
g_hIconX = winOverrideDefaultIcon(sm_cx);
|
||||
g_hSmallIconX = winOverrideDefaultIcon(sm_cxsm);
|
||||
}
|
||||
|
||||
if (!g_hIconX) {
|
||||
g_hIconX = (HICON) LoadImage(g_hInstance,
|
||||
MAKEINTRESOURCE(IDI_XWIN),
|
||||
IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXICON),
|
||||
GetSystemMetrics(SM_CYICON), 0);
|
||||
g_hSmallIconX = (HICON) LoadImage(g_hInstance,
|
||||
MAKEINTRESOURCE(IDI_XWIN),
|
||||
IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON),
|
||||
GetSystemMetrics(SM_CYSMICON),
|
||||
LR_DEFAULTSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
winSelectIcons(HICON * pIcon, HICON * pSmallIcon)
|
||||
{
|
||||
HICON hIcon, hSmallIcon;
|
||||
|
||||
winInitGlobalIcons();
|
||||
|
||||
/* Use default X icon */
|
||||
hIcon = g_hIconX;
|
||||
hSmallIcon = g_hSmallIconX;
|
||||
|
||||
if (pIcon)
|
||||
*pIcon = hIcon;
|
||||
|
||||
if (pSmallIcon)
|
||||
*pSmallIcon = hSmallIcon;
|
||||
}
|
||||
|
||||
void
|
||||
winDestroyIcon(HICON hIcon)
|
||||
{
|
||||
/* Delete the icon if its not one of the application defaults or an override */
|
||||
if (hIcon &&
|
||||
hIcon != g_hIconX &&
|
||||
hIcon != g_hSmallIconX && !winIconIsOverride(hIcon))
|
||||
DestroyIcon(hIcon);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* File: winmultiwindowicons.h
|
||||
* Purpose: interface for multiwindow mode icon functions
|
||||
*
|
||||
* Copyright (c) Jon TURNEY 2012
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
*/
|
||||
|
||||
#ifndef WINMULTIWINDOWICONS_H
|
||||
#define WINMULTIWINDOWICONS_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
void
|
||||
winUpdateIcon(HWND hWnd, xcb_connection_t *conn, xcb_window_t id, HICON hIconNew);
|
||||
|
||||
void
|
||||
winInitGlobalIcons(void);
|
||||
|
||||
void
|
||||
winDestroyIcon(HICON hIcon);
|
||||
|
||||
void
|
||||
winSelectIcons(HICON * pIcon, HICON * pSmallIcon);
|
||||
|
||||
#endif /* WINMULTIWINDOWICONS_H */
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Kensuke Matsuzaki
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* winSetShapeMultiWindow - See Porting Layer Definition - p. 42
|
||||
*/
|
||||
|
||||
void
|
||||
winSetShapeMultiWindow(WindowPtr pWin, int kind)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGMULTIWINDOW_DEBUG
|
||||
ErrorF("winSetShapeMultiWindow - pWin: %p kind: %i\n", pWin, kind);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(SetShape);
|
||||
(*pScreen->SetShape) (pWin, kind);
|
||||
WIN_WRAP(SetShape, winSetShapeMultiWindow);
|
||||
|
||||
/* Update the Windows window's shape */
|
||||
winReshapeMultiWindow(pWin);
|
||||
winUpdateRgnMultiWindow(pWin);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* winUpdateRgnMultiWindow - Local function to update a Windows window region
|
||||
*/
|
||||
|
||||
void
|
||||
winUpdateRgnMultiWindow(WindowPtr pWin)
|
||||
{
|
||||
SetWindowRgn(winGetWindowPriv(pWin)->hWnd,
|
||||
winGetWindowPriv(pWin)->hRgn, TRUE);
|
||||
|
||||
/* The system now owns the region specified by the region handle and will delete it when it is no longer needed. */
|
||||
winGetWindowPriv(pWin)->hRgn = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* winReshapeMultiWindow - Computes the composite clipping region for a window
|
||||
*/
|
||||
|
||||
void
|
||||
winReshapeMultiWindow(WindowPtr pWin)
|
||||
{
|
||||
int nRects;
|
||||
RegionRec rrNewShape;
|
||||
BoxPtr pShape, pRects, pEnd;
|
||||
HRGN hRgn, hRgnRect;
|
||||
|
||||
winWindowPriv(pWin);
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winReshape ()\n");
|
||||
#endif
|
||||
|
||||
/* Bail if the window is the root window */
|
||||
if (pWin->parent == NULL)
|
||||
return;
|
||||
|
||||
/* Bail if the window is not top level */
|
||||
if (pWin->parent->parent != NULL)
|
||||
return;
|
||||
|
||||
/* Bail if Windows window handle is invalid */
|
||||
if (pWinPriv->hWnd == NULL)
|
||||
return;
|
||||
|
||||
/* Free any existing window region stored in the window privates */
|
||||
if (pWinPriv->hRgn != NULL) {
|
||||
DeleteObject(pWinPriv->hRgn);
|
||||
pWinPriv->hRgn = NULL;
|
||||
}
|
||||
|
||||
/* Bail if the window has no bounding region defined */
|
||||
if (!wBoundingShape(pWin))
|
||||
return;
|
||||
|
||||
RegionNull(&rrNewShape);
|
||||
RegionCopy(&rrNewShape, wBoundingShape(pWin));
|
||||
RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth);
|
||||
|
||||
nRects = RegionNumRects(&rrNewShape);
|
||||
pShape = RegionRects(&rrNewShape);
|
||||
|
||||
/* Don't do anything if there are no rectangles in the region */
|
||||
if (nRects > 0) {
|
||||
RECT rcClient;
|
||||
RECT rcWindow;
|
||||
int iOffsetX, iOffsetY;
|
||||
|
||||
/* Get client rectangle */
|
||||
if (!GetClientRect(pWinPriv->hWnd, &rcClient)) {
|
||||
ErrorF("winReshape - GetClientRect failed, bailing: %d\n",
|
||||
(int) GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Translate client rectangle coords to screen coords */
|
||||
/* NOTE: Only transforms top and left members */
|
||||
ClientToScreen(pWinPriv->hWnd, (LPPOINT) &rcClient);
|
||||
|
||||
/* Get window rectangle */
|
||||
if (!GetWindowRect(pWinPriv->hWnd, &rcWindow)) {
|
||||
ErrorF("winReshape - GetWindowRect failed, bailing: %d\n",
|
||||
(int) GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Calculate offset from window upper-left to client upper-left */
|
||||
iOffsetX = rcClient.left - rcWindow.left;
|
||||
iOffsetY = rcClient.top - rcWindow.top;
|
||||
|
||||
/* Create initial Windows region for title bar */
|
||||
/* FIXME: Mean, nasty, ugly hack!!! */
|
||||
hRgn = CreateRectRgn(0, 0, rcWindow.right, iOffsetY);
|
||||
if (hRgn == NULL) {
|
||||
ErrorF("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
|
||||
"failed: %d\n",
|
||||
0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError());
|
||||
}
|
||||
|
||||
/* Loop through all rectangles in the X region */
|
||||
for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) {
|
||||
/* Create a Windows region for the X rectangle */
|
||||
hRgnRect = CreateRectRgn(pRects->x1 + iOffsetX,
|
||||
pRects->y1 + iOffsetY,
|
||||
pRects->x2 + iOffsetX,
|
||||
pRects->y2 + iOffsetY);
|
||||
if (hRgnRect == NULL) {
|
||||
ErrorF("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
|
||||
"failed: %d\n"
|
||||
"\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n",
|
||||
pRects->x1 + iOffsetX,
|
||||
pRects->y1 + iOffsetY,
|
||||
pRects->x2 + iOffsetX,
|
||||
pRects->y2 + iOffsetY,
|
||||
(int) GetLastError(),
|
||||
pRects->x1, pRects->x2, iOffsetX,
|
||||
pRects->y1, pRects->y2, iOffsetY);
|
||||
}
|
||||
|
||||
/* Merge the Windows region with the accumulated region */
|
||||
if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) {
|
||||
ErrorF("winReshape - CombineRgn () failed: %d\n",
|
||||
(int) GetLastError());
|
||||
}
|
||||
|
||||
/* Delete the temporary Windows region */
|
||||
DeleteObject(hRgnRect);
|
||||
}
|
||||
|
||||
/* Save a handle to the composite region in the window privates */
|
||||
pWinPriv->hRgn = hRgn;
|
||||
}
|
||||
|
||||
RegionUninit(&rrNewShape);
|
||||
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2014 Colin Harrison All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
|
||||
* holders shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written authorization.
|
||||
*
|
||||
* Author: Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
|
||||
|
||||
static const char*
|
||||
IsWow64(void)
|
||||
{
|
||||
#ifdef __x86_64__
|
||||
return " (64-bit)";
|
||||
#else
|
||||
WINBOOL bIsWow64;
|
||||
LPFN_ISWOW64PROCESS fnIsWow64Process =
|
||||
(LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")),
|
||||
"IsWow64Process");
|
||||
if (NULL != fnIsWow64Process) {
|
||||
if (fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
|
||||
return bIsWow64 ? " (WoW64)" : " (32-bit)";
|
||||
}
|
||||
|
||||
/* OS doesn't support IsWow64Process() */
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Report the OS version
|
||||
*/
|
||||
|
||||
void
|
||||
winOS(void)
|
||||
{
|
||||
OSVERSIONINFOEX osvi = {0};
|
||||
|
||||
/* Get operating system version information */
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
GetVersionEx((LPOSVERSIONINFO)&osvi);
|
||||
|
||||
ErrorF("OS: Windows NT %d.%d build %d%s\n",
|
||||
(int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion,
|
||||
(int)osvi.dwBuildNumber, IsWow64());
|
||||
}
|
|
@ -1,805 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
* Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* 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 XFREE86 PROJECT 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 XFree86 Project
|
||||
* 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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __CYGWIN__
|
||||
#include <sys/resource.h>
|
||||
#include <sys/cygwin.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
#include <X11/Xwindows.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "winprefs.h"
|
||||
#include "windisplay.h"
|
||||
#include "winmultiwindowclass.h"
|
||||
#include "winmultiwindowicons.h"
|
||||
|
||||
/* Where will the custom menu commands start counting from? */
|
||||
#define STARTMENUID WM_USER
|
||||
|
||||
extern const char *winGetBaseDir(void);
|
||||
|
||||
/* From winprefslex.l, the real parser */
|
||||
extern int parse_file(FILE * fp);
|
||||
|
||||
/* Currently in use command ID, incremented each new menu item created */
|
||||
static int g_cmdid = STARTMENUID;
|
||||
|
||||
/*
|
||||
* Creates or appends a menu from a MENUPARSED structure
|
||||
*/
|
||||
static HMENU
|
||||
MakeMenu(char *name, HMENU editMenu, int editItem)
|
||||
{
|
||||
int i;
|
||||
int item;
|
||||
MENUPARSED *m;
|
||||
HMENU hmenu, hsub;
|
||||
|
||||
for (i = 0; i < pref.menuItems; i++) {
|
||||
if (!strcmp(name, pref.menu[i].menuName))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Didn't find a match, bummer */
|
||||
if (i == pref.menuItems) {
|
||||
ErrorF("MakeMenu: Can't find menu %s\n", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m = &(pref.menu[i]);
|
||||
|
||||
if (editMenu) {
|
||||
hmenu = editMenu;
|
||||
item = editItem;
|
||||
}
|
||||
else {
|
||||
hmenu = CreatePopupMenu();
|
||||
if (!hmenu) {
|
||||
ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
|
||||
return NULL;
|
||||
}
|
||||
item = 0;
|
||||
}
|
||||
|
||||
/* Add the menu items */
|
||||
for (i = 0; i < m->menuItems; i++) {
|
||||
/* Only assign IDs one time... */
|
||||
if (m->menuItem[i].commandID == 0)
|
||||
m->menuItem[i].commandID = g_cmdid++;
|
||||
|
||||
switch (m->menuItem[i].cmd) {
|
||||
case CMD_EXEC:
|
||||
case CMD_ALWAYSONTOP:
|
||||
case CMD_RELOAD:
|
||||
InsertMenu(hmenu,
|
||||
item,
|
||||
MF_BYPOSITION | MF_ENABLED | MF_STRING,
|
||||
m->menuItem[i].commandID, m->menuItem[i].text);
|
||||
break;
|
||||
|
||||
case CMD_SEPARATOR:
|
||||
InsertMenu(hmenu, item, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
||||
break;
|
||||
|
||||
case CMD_MENU:
|
||||
/* Recursive! */
|
||||
hsub = MakeMenu(m->menuItem[i].param, 0, 0);
|
||||
if (hsub)
|
||||
InsertMenu(hmenu,
|
||||
item,
|
||||
MF_BYPOSITION | MF_POPUP | MF_ENABLED | MF_STRING,
|
||||
(UINT_PTR) hsub, m->menuItem[i].text);
|
||||
break;
|
||||
}
|
||||
|
||||
/* If item==-1 (means to add at end of menu) don't increment) */
|
||||
if (item >= 0)
|
||||
item++;
|
||||
}
|
||||
|
||||
return hmenu;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback routine that is executed once per window class.
|
||||
* Removes or creates custom window settings depending on LPARAM
|
||||
*/
|
||||
static wBOOL CALLBACK
|
||||
ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
HICON hicon;
|
||||
|
||||
if (!hwnd) {
|
||||
ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* It's our baby, either clean or dirty it */
|
||||
if (lParam == FALSE) {
|
||||
/* Reset the window's icon to undefined. */
|
||||
hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
|
||||
|
||||
/* If the old icon is generated on-the-fly, get rid of it, will regen */
|
||||
winDestroyIcon(hicon);
|
||||
|
||||
/* Same for the small icon */
|
||||
hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
|
||||
winDestroyIcon(hicon);
|
||||
|
||||
/* Remove any menu additions; bRevert=TRUE destroys any modified menus */
|
||||
GetSystemMenu(hwnd, TRUE);
|
||||
|
||||
/* This window is now clean of our taint (but with undefined icons) */
|
||||
}
|
||||
else {
|
||||
/* Send a message to WM thread telling it re-evaluate the icon for this window */
|
||||
{
|
||||
winWMMessageRec wmMsg;
|
||||
|
||||
WindowPtr pWin = GetProp(hwnd, WIN_WINDOW_PROP);
|
||||
|
||||
if (pWin) {
|
||||
winPrivWinPtr pWinPriv = winGetWindowPriv(pWin);
|
||||
winPrivScreenPtr s_pScreenPriv = pWinPriv->pScreenPriv;
|
||||
|
||||
wmMsg.msg = WM_WM_ICON_EVENT;
|
||||
wmMsg.hwndWindow = hwnd;
|
||||
wmMsg.iWindow = (Window) (INT_PTR) GetProp(hwnd, WIN_WID_PROP);
|
||||
|
||||
winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the system menu for this window */
|
||||
SetupSysMenu(hwnd);
|
||||
|
||||
/* That was easy... */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes any custom icons in classes, custom menus, etc.
|
||||
* Frees all members in pref structure.
|
||||
* Reloads the preferences file.
|
||||
* Set custom icons and menus again.
|
||||
*/
|
||||
static void
|
||||
ReloadPrefs(winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
int i;
|
||||
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
|
||||
/* First, iterate over all windows, deleting their icons and custom menus.
|
||||
* This is really only needed because winDestroyIcon() will try to
|
||||
* destroy the old global icons, which will have changed.
|
||||
* It is probably better to set a windows USER_DATA to flag locally defined
|
||||
* icons, and use that to accurately know when to destroy old icons.
|
||||
*/
|
||||
if (pScreenInfo->fMultiWindow)
|
||||
EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
|
||||
|
||||
/* Now, free/clear all info from our prefs structure */
|
||||
for (i = 0; i < pref.menuItems; i++)
|
||||
free(pref.menu[i].menuItem);
|
||||
free(pref.menu);
|
||||
pref.menu = NULL;
|
||||
pref.menuItems = 0;
|
||||
|
||||
pref.rootMenuName[0] = 0;
|
||||
|
||||
free(pref.sysMenu);
|
||||
pref.sysMenuItems = 0;
|
||||
|
||||
pref.defaultSysMenuName[0] = 0;
|
||||
pref.defaultSysMenuPos = 0;
|
||||
|
||||
pref.iconDirectory[0] = 0;
|
||||
pref.defaultIconName[0] = 0;
|
||||
pref.trayIconName[0] = 0;
|
||||
|
||||
for (i = 0; i < pref.iconItems; i++)
|
||||
if (pref.icon[i].hicon)
|
||||
DestroyIcon((HICON) pref.icon[i].hicon);
|
||||
free(pref.icon);
|
||||
pref.icon = NULL;
|
||||
pref.iconItems = 0;
|
||||
|
||||
/* Free global default X icon */
|
||||
if (g_hIconX)
|
||||
DestroyIcon(g_hIconX);
|
||||
if (g_hSmallIconX)
|
||||
DestroyIcon(g_hSmallIconX);
|
||||
|
||||
/* Reset the custom command IDs */
|
||||
g_cmdid = STARTMENUID;
|
||||
|
||||
/* Load the updated resource file */
|
||||
LoadPreferences();
|
||||
|
||||
g_hIconX = NULL;
|
||||
g_hSmallIconX = NULL;
|
||||
|
||||
if (pScreenInfo->fMultiWindow) {
|
||||
winInitGlobalIcons();
|
||||
|
||||
/* Rebuild the icons and menus */
|
||||
EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
|
||||
}
|
||||
|
||||
/* Whew, done */
|
||||
}
|
||||
|
||||
/*
|
||||
* Check/uncheck the ALWAYSONTOP items in this menu
|
||||
*/
|
||||
void
|
||||
HandleCustomWM_INITMENU(HWND hwnd, HMENU hmenu)
|
||||
{
|
||||
DWORD dwExStyle;
|
||||
int i, j;
|
||||
|
||||
if (!hwnd || !hmenu)
|
||||
return;
|
||||
|
||||
if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||
dwExStyle = MF_BYCOMMAND | MF_CHECKED;
|
||||
else
|
||||
dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
|
||||
|
||||
for (i = 0; i < pref.menuItems; i++)
|
||||
for (j = 0; j < pref.menu[i].menuItems; j++)
|
||||
if (pref.menu[i].menuItem[j].cmd == CMD_ALWAYSONTOP)
|
||||
CheckMenuItem(hmenu, pref.menu[i].menuItem[j].commandID,
|
||||
dwExStyle);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for the custom WM_COMMAND command ID and performs action.
|
||||
* Return TRUE if command is processed, FALSE otherwise.
|
||||
*/
|
||||
Bool
|
||||
HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
int i, j;
|
||||
MENUPARSED *m;
|
||||
DWORD dwExStyle;
|
||||
|
||||
if (!command)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < pref.menuItems; i++) {
|
||||
m = &(pref.menu[i]);
|
||||
for (j = 0; j < m->menuItems; j++) {
|
||||
if (command == m->menuItem[j].commandID) {
|
||||
/* Match! */
|
||||
switch (m->menuItem[j].cmd) {
|
||||
#ifdef __CYGWIN__
|
||||
case CMD_EXEC:
|
||||
if (fork() == 0) {
|
||||
struct rlimit rl;
|
||||
int fd;
|
||||
|
||||
/* Close any open descriptors except for STD* */
|
||||
getrlimit(RLIMIT_NOFILE, &rl);
|
||||
for (fd = STDERR_FILENO + 1; fd < rl.rlim_cur; fd++)
|
||||
close(fd);
|
||||
|
||||
/* Disassociate any TTYs */
|
||||
setsid();
|
||||
|
||||
execl("/bin/sh",
|
||||
"/bin/sh", "-c", m->menuItem[j].param, NULL);
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
break;
|
||||
#else
|
||||
case CMD_EXEC:
|
||||
{
|
||||
/* Start process without console window */
|
||||
STARTUPINFO start;
|
||||
PROCESS_INFORMATION child;
|
||||
|
||||
memset(&start, 0, sizeof(start));
|
||||
start.cb = sizeof(start);
|
||||
start.dwFlags = STARTF_USESHOWWINDOW;
|
||||
start.wShowWindow = SW_HIDE;
|
||||
|
||||
memset(&child, 0, sizeof(child));
|
||||
|
||||
if (CreateProcess
|
||||
(NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0, NULL,
|
||||
NULL, &start, &child)) {
|
||||
CloseHandle(child.hThread);
|
||||
CloseHandle(child.hProcess);
|
||||
}
|
||||
else
|
||||
MessageBox(NULL, m->menuItem[j].param,
|
||||
"Mingrc Exec Command Error!",
|
||||
MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
return TRUE;
|
||||
#endif
|
||||
case CMD_ALWAYSONTOP:
|
||||
if (!hwnd)
|
||||
return FALSE;
|
||||
|
||||
/* Get extended window style */
|
||||
dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
|
||||
/* Handle topmost windows */
|
||||
if (dwExStyle & WS_EX_TOPMOST)
|
||||
SetWindowPos(hwnd,
|
||||
HWND_NOTOPMOST,
|
||||
0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||
else
|
||||
SetWindowPos(hwnd,
|
||||
HWND_TOPMOST,
|
||||
0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||
{
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
if (pScreenInfo->fMultiWindow)
|
||||
/* Reflect the changed Z order */
|
||||
winReorderWindowsMultiWindow();
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case CMD_RELOAD:
|
||||
ReloadPrefs(pScreenPriv);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
} /* match */
|
||||
} /* for j */
|
||||
} /* for i */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the default or a custom menu depending on the class match
|
||||
*/
|
||||
void
|
||||
SetupSysMenu(HWND hwnd)
|
||||
{
|
||||
HMENU sys;
|
||||
int i;
|
||||
WindowPtr pWin;
|
||||
char *res_name, *res_class;
|
||||
|
||||
if (!hwnd)
|
||||
return;
|
||||
|
||||
pWin = GetProp(hwnd, WIN_WINDOW_PROP);
|
||||
|
||||
sys = GetSystemMenu(hwnd, FALSE);
|
||||
if (!sys)
|
||||
return;
|
||||
|
||||
if (pWin) {
|
||||
/* First see if there's a class match... */
|
||||
if (winMultiWindowGetClassHint(pWin, &res_name, &res_class)) {
|
||||
for (i = 0; i < pref.sysMenuItems; i++) {
|
||||
if (!strcmp(pref.sysMenu[i].match, res_name) ||
|
||||
!strcmp(pref.sysMenu[i].match, res_class)) {
|
||||
free(res_name);
|
||||
free(res_class);
|
||||
|
||||
MakeMenu(pref.sysMenu[i].menuName, sys,
|
||||
pref.sysMenu[i].menuPos == AT_START ? 0 : -1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* No match, just free alloc'd strings */
|
||||
free(res_name);
|
||||
free(res_class);
|
||||
} /* Found wm_class */
|
||||
} /* if pwin */
|
||||
|
||||
/* Fallback to system default */
|
||||
if (pref.defaultSysMenuName[0]) {
|
||||
if (pref.defaultSysMenuPos == AT_START)
|
||||
MakeMenu(pref.defaultSysMenuName, sys, 0);
|
||||
else
|
||||
MakeMenu(pref.defaultSysMenuName, sys, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Possibly add a menu to the toolbar icon
|
||||
*/
|
||||
void
|
||||
SetupRootMenu(HMENU root)
|
||||
{
|
||||
if (!root)
|
||||
return;
|
||||
|
||||
if (pref.rootMenuName[0]) {
|
||||
MakeMenu(pref.rootMenuName, root, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for and return an overridden default ICON specified in the prefs
|
||||
*/
|
||||
HICON
|
||||
winOverrideDefaultIcon(int size)
|
||||
{
|
||||
HICON hicon;
|
||||
|
||||
if (pref.defaultIconName[0]) {
|
||||
hicon = LoadImageComma(pref.defaultIconName, pref.iconDirectory, size, size, 0);
|
||||
if (hicon == NULL)
|
||||
ErrorF("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
|
||||
pref.defaultIconName);
|
||||
|
||||
return hicon;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the HICON to use in the taskbar notification area
|
||||
*/
|
||||
HICON
|
||||
winTaskbarIcon(void)
|
||||
{
|
||||
HICON hicon;
|
||||
|
||||
hicon = 0;
|
||||
/* First try and load an overridden, if success then return it */
|
||||
if (pref.trayIconName[0]) {
|
||||
hicon = LoadImageComma(pref.trayIconName, pref.iconDirectory,
|
||||
GetSystemMetrics(SM_CXSMICON),
|
||||
GetSystemMetrics(SM_CYSMICON), 0);
|
||||
if (hicon == NULL)
|
||||
ErrorF("winTaskbarIcon: LoadImageComma(%s) failed\n",
|
||||
pref.trayIconName);
|
||||
}
|
||||
|
||||
/* Otherwise return the default */
|
||||
if (!hicon)
|
||||
hicon = (HICON) LoadImage(g_hInstance,
|
||||
MAKEINTRESOURCE(IDI_XWIN),
|
||||
IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON),
|
||||
GetSystemMetrics(SM_CYSMICON), 0);
|
||||
|
||||
return hicon;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle comma-ified icon names
|
||||
*
|
||||
* Parse a filename to extract an icon:
|
||||
* If fname is exactly ",nnn" then extract icon from our resource
|
||||
* else if it is "file,nnn" then extract icon nnn from that file
|
||||
* else try to load it as an .ico file and if that fails return NULL
|
||||
*/
|
||||
HICON
|
||||
LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags)
|
||||
{
|
||||
HICON hicon;
|
||||
int i;
|
||||
|
||||
/* Some input error checking */
|
||||
if (!fname || !fname[0])
|
||||
return NULL;
|
||||
|
||||
i = 0;
|
||||
hicon = NULL;
|
||||
|
||||
if (fname[0] == ',') {
|
||||
/* It's the XWIN.EXE resource they want */
|
||||
i = atoi(fname + 1);
|
||||
hicon = LoadImage(g_hInstance,
|
||||
MAKEINTRESOURCE(i), IMAGE_ICON, sx, sy, flags);
|
||||
}
|
||||
else {
|
||||
char *file = malloc(PATH_MAX + NAME_MAX + 2);
|
||||
Bool convert = FALSE;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
file[0] = 0;
|
||||
|
||||
/* If fname starts 'X:\', it's an absolute Windows path, do nothing */
|
||||
if (!(fname[0] && fname[1] == ':' && fname[2] == '\\')) {
|
||||
#ifdef __CYGWIN__
|
||||
/* If fname starts with '/', it's an absolute cygwin path, we'll
|
||||
need to convert it */
|
||||
if (fname[0] == '/') {
|
||||
convert = TRUE;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (iconDirectory) {
|
||||
/* Otherwise, prepend the default icon directory, which
|
||||
currently must be in absolute Windows path form */
|
||||
strcpy(file, iconDirectory);
|
||||
if (iconDirectory[0])
|
||||
if (iconDirectory[strlen(iconDirectory) - 1] != '\\')
|
||||
strcat(file, "\\");
|
||||
}
|
||||
}
|
||||
strcat(file, fname);
|
||||
|
||||
/* Trim off any ',index' */
|
||||
if (strrchr(file, ',')) {
|
||||
*(strrchr(file, ',')) = 0; /* End string at comma */
|
||||
i = atoi(strrchr(fname, ',') + 1);
|
||||
}
|
||||
else {
|
||||
i = -1;
|
||||
}
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* Convert from Cygwin path to Windows path */
|
||||
if (convert) {
|
||||
char *converted_file = cygwin_create_path(CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, file);
|
||||
if (converted_file) {
|
||||
free(file);
|
||||
file = converted_file;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (i >= 0) {
|
||||
/* Specified as <fname>,<index> */
|
||||
hicon = ExtractIcon(g_hInstance, file, i);
|
||||
}
|
||||
else {
|
||||
/* Specified as just an .ico file */
|
||||
hicon = (HICON) LoadImage(NULL,
|
||||
file,
|
||||
IMAGE_ICON,
|
||||
sx, sy, LR_LOADFROMFILE | flags);
|
||||
}
|
||||
free(file);
|
||||
}
|
||||
return hicon;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for a match of the window class to one specified in the
|
||||
* ICONS{} section in the prefs file, and load the icon from a file
|
||||
*/
|
||||
HICON
|
||||
winOverrideIcon(char *res_name, char *res_class, char *wmName)
|
||||
{
|
||||
int i;
|
||||
HICON hicon;
|
||||
|
||||
for (i = 0; i < pref.iconItems; i++) {
|
||||
if ((res_name && !strcmp(pref.icon[i].match, res_name)) ||
|
||||
(res_class && !strcmp(pref.icon[i].match, res_class)) ||
|
||||
(wmName && strstr(wmName, pref.icon[i].match))) {
|
||||
if (pref.icon[i].hicon)
|
||||
return pref.icon[i].hicon;
|
||||
|
||||
hicon = LoadImageComma(pref.icon[i].iconFile, pref.iconDirectory, 0, 0, LR_DEFAULTSIZE);
|
||||
if (hicon == NULL)
|
||||
ErrorF("winOverrideIcon: LoadImageComma(%s) failed\n",
|
||||
pref.icon[i].iconFile);
|
||||
|
||||
pref.icon[i].hicon = hicon;
|
||||
return hicon;
|
||||
}
|
||||
}
|
||||
|
||||
/* Didn't find the icon, fail gracefully */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Should we free this icon or leave it in memory (is it part of our
|
||||
* ICONS{} overrides)?
|
||||
*/
|
||||
int
|
||||
winIconIsOverride(HICON hicon)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!hicon)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < pref.iconItems; i++)
|
||||
if ((HICON) pref.icon[i].hicon == hicon)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open and parse the XWinrc config file @path.
|
||||
* If @path is NULL, use the built-in default.
|
||||
*/
|
||||
static int
|
||||
winPrefsLoadPreferences(const char *path)
|
||||
{
|
||||
FILE *prefFile = NULL;
|
||||
|
||||
if (path)
|
||||
prefFile = fopen(path, "r");
|
||||
#ifdef __CYGWIN__
|
||||
else {
|
||||
char defaultPrefs[] =
|
||||
"MENU rmenu {\n"
|
||||
" \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n"
|
||||
" \"Launch xterm\" EXEC xterm\n"
|
||||
" \"Load .XWinrc\" RELOAD\n"
|
||||
" SEPARATOR\n" "}\n" "\n" "ROOTMENU rmenu\n";
|
||||
|
||||
path = "built-in default";
|
||||
prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!prefFile) {
|
||||
ErrorF("LoadPreferences: %s not found\n", path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ErrorF("LoadPreferences: Loading %s\n", path);
|
||||
|
||||
if ((parse_file(prefFile)) != 0) {
|
||||
ErrorF("LoadPreferences: %s is badly formed!\n", path);
|
||||
fclose(prefFile);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose(prefFile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try and open ~/.XWinrc and system.XWinrc
|
||||
* Load it into prefs structure for use by other functions
|
||||
*/
|
||||
void
|
||||
LoadPreferences(void)
|
||||
{
|
||||
char *home;
|
||||
char fname[PATH_MAX + NAME_MAX + 2];
|
||||
char szDisplay[512];
|
||||
char *szEnvDisplay;
|
||||
int i, j;
|
||||
char param[PARAM_MAX + 1];
|
||||
char *srcParam, *dstParam;
|
||||
int parsed = FALSE;
|
||||
|
||||
/* First, clear all preference settings */
|
||||
memset(&pref, 0, sizeof(pref));
|
||||
|
||||
/* Now try and find a ~/.xwinrc file */
|
||||
home = getenv("HOME");
|
||||
if (home) {
|
||||
strcpy(fname, home);
|
||||
if (fname[strlen(fname) - 1] != '/')
|
||||
strcat(fname, "/");
|
||||
strcat(fname, ".XWinrc");
|
||||
parsed = winPrefsLoadPreferences(fname);
|
||||
}
|
||||
|
||||
/* No home file found, check system default */
|
||||
if (!parsed) {
|
||||
char buffer[MAX_PATH];
|
||||
|
||||
#ifdef RELOCATE_PROJECTROOT
|
||||
snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
|
||||
#else
|
||||
strncpy(buffer, SYSCONFDIR "/X11/system.XWinrc", sizeof(buffer));
|
||||
#endif
|
||||
buffer[sizeof(buffer) - 1] = 0;
|
||||
parsed = winPrefsLoadPreferences(buffer);
|
||||
}
|
||||
|
||||
/* Neither user nor system configuration found, or were badly formed */
|
||||
if (!parsed) {
|
||||
ErrorF
|
||||
("LoadPreferences: See \"man XWinrc\" to customize the XWin menu.\n");
|
||||
parsed = winPrefsLoadPreferences(NULL);
|
||||
}
|
||||
|
||||
/* Setup a DISPLAY environment variable, need to allocate on heap */
|
||||
/* because putenv doesn't copy the argument... */
|
||||
winGetDisplayName(szDisplay, 0);
|
||||
szEnvDisplay = (char *) (malloc(strlen(szDisplay) + strlen("DISPLAY=") + 1));
|
||||
if (szEnvDisplay) {
|
||||
snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
|
||||
putenv(szEnvDisplay);
|
||||
}
|
||||
|
||||
/* Replace any "%display%" in menu commands with display string */
|
||||
for (i = 0; i < pref.menuItems; i++) {
|
||||
for (j = 0; j < pref.menu[i].menuItems; j++) {
|
||||
if (pref.menu[i].menuItem[j].cmd == CMD_EXEC) {
|
||||
srcParam = pref.menu[i].menuItem[j].param;
|
||||
dstParam = param;
|
||||
while (*srcParam) {
|
||||
if (!strncmp(srcParam, "%display%", 9)) {
|
||||
memcpy(dstParam, szDisplay, strlen(szDisplay));
|
||||
dstParam += strlen(szDisplay);
|
||||
srcParam += 9;
|
||||
}
|
||||
else {
|
||||
*dstParam = *srcParam;
|
||||
dstParam++;
|
||||
srcParam++;
|
||||
}
|
||||
}
|
||||
*dstParam = 0;
|
||||
strcpy(pref.menu[i].menuItem[j].param, param);
|
||||
} /* cmd==cmd_exec */
|
||||
} /* for all menuitems */
|
||||
} /* for all menus */
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for a match of the window class to one specified in the
|
||||
* STYLES{} section in the prefs file, and return the style type
|
||||
*/
|
||||
unsigned long
|
||||
winOverrideStyle(char *res_name, char *res_class, char *wmName)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pref.styleItems; i++) {
|
||||
if ((res_name && !strcmp(pref.style[i].match, res_name)) ||
|
||||
(res_class && !strcmp(pref.style[i].match, res_class)) ||
|
||||
(wmName && strstr(wmName, pref.style[i].match))) {
|
||||
if (pref.style[i].type)
|
||||
return pref.style[i].type;
|
||||
}
|
||||
}
|
||||
|
||||
/* Didn't find the style, fail gracefully */
|
||||
return STYLE_NONE;
|
||||
}
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
* Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* 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 XFREE86 PROJECT 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 XFree86 Project
|
||||
* 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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
* Colin Harrison
|
||||
*/
|
||||
|
||||
#if !defined(WINPREFS_H)
|
||||
#define WINPREFS_H
|
||||
|
||||
/* Need Bool */
|
||||
#include <X11/Xdefs.h>
|
||||
/* Need TRUE */
|
||||
#include "misc.h"
|
||||
|
||||
/* Need to know how long paths can be... */
|
||||
#include <limits.h>
|
||||
/* Xwindows redefines PATH_MAX to at least 1024 */
|
||||
#include <X11/Xwindows.h>
|
||||
|
||||
#include "winwindow.h"
|
||||
|
||||
#ifndef NAME_MAX
|
||||
#define NAME_MAX PATH_MAX
|
||||
#endif
|
||||
#define MENU_MAX 128 /* Maximum string length of a menu name or item */
|
||||
#define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */
|
||||
|
||||
/* Supported commands in a MENU {} statement */
|
||||
typedef enum MENUCOMMANDTYPE {
|
||||
CMD_EXEC, /* /bin/sh -c the parameter */
|
||||
CMD_MENU, /* Display a popup menu named param */
|
||||
CMD_SEPARATOR, /* Menu separator */
|
||||
CMD_ALWAYSONTOP, /* Toggle always-on-top mode */
|
||||
CMD_RELOAD /* Reparse the .XWINRC file */
|
||||
} MENUCOMMANDTYPE;
|
||||
|
||||
#define STYLE_NONE (0L) /* Dummy the first entry */
|
||||
#define STYLE_NOTITLE (1L) /* Force window style no titlebar */
|
||||
#define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */
|
||||
#define STYLE_NOFRAME (1L<<2) /* Force window style no frame */
|
||||
#define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */
|
||||
#define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */
|
||||
#define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */
|
||||
#define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */
|
||||
|
||||
/* Where to place a system menu */
|
||||
typedef enum MENUPOSITION {
|
||||
AT_START, /* Place menu at the top of the system menu */
|
||||
AT_END /* Put it at the bottom of the menu (default) */
|
||||
} MENUPOSITION;
|
||||
|
||||
/* Menu item definitions */
|
||||
typedef struct MENUITEM {
|
||||
char text[MENU_MAX + 1]; /* To be displayed in menu */
|
||||
MENUCOMMANDTYPE cmd; /* What should it do? */
|
||||
char param[PARAM_MAX + 1]; /* Any parameters? */
|
||||
unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */
|
||||
} MENUITEM;
|
||||
|
||||
/* A completely read in menu... */
|
||||
typedef struct MENUPARSED {
|
||||
char menuName[MENU_MAX + 1]; /* What's it called in the text? */
|
||||
MENUITEM *menuItem; /* Array of items */
|
||||
int menuItems; /* How big's the array? */
|
||||
} MENUPARSED;
|
||||
|
||||
/* To map between a window and a system menu to add for it */
|
||||
typedef struct SYSMENUITEM {
|
||||
char match[MENU_MAX + 1]; /* String to look for to apply this sysmenu */
|
||||
char menuName[MENU_MAX + 1]; /* Which menu to show? Used to set *menu */
|
||||
MENUPOSITION menuPos; /* Where to place it (ignored in root) */
|
||||
} SYSMENUITEM;
|
||||
|
||||
/* To redefine icons for certain window types */
|
||||
typedef struct ICONITEM {
|
||||
char match[MENU_MAX + 1]; /* What string to search for? */
|
||||
char iconFile[PATH_MAX + NAME_MAX + 2]; /* Icon location, WIN32 path */
|
||||
HICON hicon; /* LoadImage() result */
|
||||
} ICONITEM;
|
||||
|
||||
/* To redefine styles for certain window types */
|
||||
typedef struct STYLEITEM {
|
||||
char match[MENU_MAX + 1]; /* What string to search for? */
|
||||
unsigned long type; /* What should it do? */
|
||||
} STYLEITEM;
|
||||
|
||||
typedef struct WINPREFS {
|
||||
/* Menu information */
|
||||
MENUPARSED *menu; /* Array of created menus */
|
||||
int menuItems; /* How big? */
|
||||
|
||||
/* Taskbar menu settings */
|
||||
char rootMenuName[MENU_MAX + 1]; /* Menu for taskbar icon */
|
||||
|
||||
/* System menu addition menus */
|
||||
SYSMENUITEM *sysMenu;
|
||||
int sysMenuItems;
|
||||
|
||||
/* Which menu to add to unmatched windows? */
|
||||
char defaultSysMenuName[MENU_MAX + 1];
|
||||
MENUPOSITION defaultSysMenuPos; /* Where to place it */
|
||||
|
||||
/* Icon information */
|
||||
char iconDirectory[PATH_MAX + 1]; /* Where do the .icos lie? (Win32 path) */
|
||||
char defaultIconName[NAME_MAX + 1]; /* Replacement for x.ico */
|
||||
char trayIconName[NAME_MAX + 1]; /* Replacement for tray icon */
|
||||
|
||||
ICONITEM *icon;
|
||||
int iconItems;
|
||||
|
||||
STYLEITEM *style;
|
||||
int styleItems;
|
||||
|
||||
/* Force exit flag */
|
||||
Bool fForceExit;
|
||||
|
||||
/* Silent exit flag */
|
||||
Bool fSilentExit;
|
||||
|
||||
} WINPREFS;
|
||||
|
||||
/* The global pref settings structure loaded by the winprefyacc.y parser */
|
||||
extern WINPREFS pref;
|
||||
|
||||
/* Functions */
|
||||
void
|
||||
LoadPreferences(void);
|
||||
|
||||
void
|
||||
SetupRootMenu(HMENU root);
|
||||
|
||||
void
|
||||
SetupSysMenu(HWND hwnd);
|
||||
|
||||
void
|
||||
HandleCustomWM_INITMENU(HWND hwnd, HMENU hmenu);
|
||||
|
||||
Bool
|
||||
HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv);
|
||||
|
||||
int
|
||||
winIconIsOverride(HICON hicon);
|
||||
|
||||
HICON winOverrideIcon(char *res_name, char *res_class, char *wmName);
|
||||
|
||||
unsigned long
|
||||
winOverrideStyle(char *res_name, char *res_class, char *wmName);
|
||||
|
||||
HICON winTaskbarIcon(void);
|
||||
|
||||
HICON winOverrideDefaultIcon(int size);
|
||||
|
||||
HICON LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags);
|
||||
|
||||
#endif
|
|
@ -1,128 +0,0 @@
|
|||
%{ # -*- C -*-
|
||||
/*
|
||||
* Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
* Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* 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 XFREE86 PROJECT 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 XFree86 Project
|
||||
* 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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
* Colin Harrison
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "winprefsyacc.h"
|
||||
|
||||
extern void ErrorF (const char* /*f*/, ...);
|
||||
|
||||
/* Copy the parsed string, must be free()d in yacc parser */
|
||||
static char *makestr(char *str)
|
||||
{
|
||||
char *ptr;
|
||||
ptr = malloc(strlen(str)+1);
|
||||
if (!ptr)
|
||||
{
|
||||
ErrorF ("winMultiWindowLex:makestr() out of memory\n");
|
||||
exit (-1);
|
||||
}
|
||||
strcpy(ptr, str);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%option yylineno
|
||||
%option nounput
|
||||
%option noinput
|
||||
%option never-interactive
|
||||
|
||||
%%
|
||||
\#.*[\r\n] { /* comment */ return NEWLINE; }
|
||||
\/\/.*[\r\n] { /* comment */ return NEWLINE; }
|
||||
[\r\n] { return NEWLINE; }
|
||||
[ \t]+ { /* ignore whitespace */ }
|
||||
MENU { return MENU; }
|
||||
ICONDIRECTORY { return ICONDIRECTORY; }
|
||||
DEFAULTICON { return DEFAULTICON; }
|
||||
ICONS { return ICONS; }
|
||||
STYLES { return STYLES; }
|
||||
TOPMOST { return TOPMOST; }
|
||||
MAXIMIZE { return MAXIMIZE; }
|
||||
MINIMIZE { return MINIMIZE; }
|
||||
BOTTOM { return BOTTOM; }
|
||||
NOTITLE { return NOTITLE; }
|
||||
OUTLINE { return OUTLINE; }
|
||||
NOFRAME { return NOFRAME; }
|
||||
ROOTMENU { return ROOTMENU; }
|
||||
DEFAULTSYSMENU { return DEFAULTSYSMENU; }
|
||||
SYSMENU { return SYSMENU; }
|
||||
SEPARATOR { return SEPARATOR; }
|
||||
ATSTART { return ATSTART; }
|
||||
ATEND { return ATEND; }
|
||||
EXEC { return EXEC; }
|
||||
ALWAYSONTOP { return ALWAYSONTOP; }
|
||||
DEBUG { return DEBUGOUTPUT; }
|
||||
RELOAD { return RELOAD; }
|
||||
TRAYICON { return TRAYICON; }
|
||||
FORCEEXIT { return FORCEEXIT; }
|
||||
SILENTEXIT { return SILENTEXIT; }
|
||||
"{" { return LB; }
|
||||
"}" { return RB; }
|
||||
"\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \
|
||||
yylval.sVal[strlen(yylval.sVal)-1] = 0; \
|
||||
return STRING; }
|
||||
[^ \t\r\n]+ { yylval.sVal = makestr(yytext); \
|
||||
return STRING; }
|
||||
%%
|
||||
|
||||
/*
|
||||
* Run-of-the mill requirement for yacc
|
||||
*/
|
||||
int
|
||||
yywrap (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run a file through the yacc parser
|
||||
*/
|
||||
int
|
||||
parse_file (FILE *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!file)
|
||||
return 1;
|
||||
|
||||
yylineno = 1;
|
||||
yyin = file;
|
||||
ret = yyparse ();
|
||||
yylex_destroy ();
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,451 +0,0 @@
|
|||
%{
|
||||
/*
|
||||
* Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
* Copyright (C) Colin Harrison 2005-2008
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* 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 XFREE86 PROJECT 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 XFree86 Project
|
||||
* 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 XFree86 Project.
|
||||
*
|
||||
* Authors: Earle F. Philhower, III
|
||||
* Colin Harrison
|
||||
*/
|
||||
/* $XFree86: $ */
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define _STDLIB_H 1 /* bison checks this to know if stdlib has been included */
|
||||
#include <string.h>
|
||||
#include "winprefs.h"
|
||||
|
||||
/* The following give better error messages in bison at the cost of a few KB */
|
||||
#define YYERROR_VERBOSE 1
|
||||
|
||||
/* YYLTYPE_IS_TRIVIAL and YYENABLE_NLS defined to suppress warnings */
|
||||
#define YYLTYPE_IS_TRIVIAL 1
|
||||
#define YYENABLE_NLS 0
|
||||
|
||||
/* The global pref settings */
|
||||
WINPREFS pref;
|
||||
|
||||
/* The working menu */
|
||||
static MENUPARSED menu;
|
||||
|
||||
/* Functions for parsing the tokens into out structure */
|
||||
/* Defined at the end section of this file */
|
||||
|
||||
static void SetIconDirectory (char *path);
|
||||
static void SetDefaultIcon (char *fname);
|
||||
static void SetRootMenu (char *menu);
|
||||
static void SetDefaultSysMenu (char *menu, int pos);
|
||||
static void SetTrayIcon (char *fname);
|
||||
|
||||
static void OpenMenu(char *menuname);
|
||||
static void AddMenuLine(const char *name, MENUCOMMANDTYPE cmd, const char *param);
|
||||
static void CloseMenu(void);
|
||||
|
||||
static void OpenIcons(void);
|
||||
static void AddIconLine(char *matchstr, char *iconfile);
|
||||
static void CloseIcons(void);
|
||||
|
||||
static void OpenStyles(void);
|
||||
static void AddStyleLine(char *matchstr, unsigned long style);
|
||||
static void CloseStyles(void);
|
||||
|
||||
static void OpenSysMenu(void);
|
||||
static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
|
||||
static void CloseSysMenu(void);
|
||||
|
||||
static int yyerror (const char *s);
|
||||
|
||||
extern char *yytext;
|
||||
extern int yylineno;
|
||||
extern int yylex(void);
|
||||
|
||||
%}
|
||||
|
||||
%union {
|
||||
char *sVal;
|
||||
unsigned long uVal;
|
||||
int iVal;
|
||||
}
|
||||
|
||||
%token NEWLINE
|
||||
%token MENU
|
||||
%token LB
|
||||
%token RB
|
||||
%token ICONDIRECTORY
|
||||
%token DEFAULTICON
|
||||
%token ICONS
|
||||
%token STYLES
|
||||
%token TOPMOST
|
||||
%token MAXIMIZE
|
||||
%token MINIMIZE
|
||||
%token BOTTOM
|
||||
%token NOTITLE
|
||||
%token OUTLINE
|
||||
%token NOFRAME
|
||||
%token DEFAULTSYSMENU
|
||||
%token SYSMENU
|
||||
%token ROOTMENU
|
||||
%token SEPARATOR
|
||||
%token ATSTART
|
||||
%token ATEND
|
||||
%token EXEC
|
||||
%token ALWAYSONTOP
|
||||
%token DEBUGOUTPUT "DEBUG"
|
||||
%token RELOAD
|
||||
%token TRAYICON
|
||||
%token FORCEEXIT
|
||||
%token SILENTEXIT
|
||||
|
||||
%token <sVal> STRING
|
||||
%type <uVal> group1
|
||||
%type <uVal> group2
|
||||
%type <uVal> stylecombo
|
||||
%type <iVal> atspot
|
||||
|
||||
%%
|
||||
|
||||
input: /* empty */
|
||||
| input line
|
||||
;
|
||||
|
||||
line: NEWLINE
|
||||
| command
|
||||
;
|
||||
|
||||
|
||||
newline_or_nada:
|
||||
| NEWLINE newline_or_nada
|
||||
;
|
||||
|
||||
command: defaulticon
|
||||
| icondirectory
|
||||
| menu
|
||||
| icons
|
||||
| styles
|
||||
| sysmenu
|
||||
| rootmenu
|
||||
| defaultsysmenu
|
||||
| debug
|
||||
| trayicon
|
||||
| forceexit
|
||||
| silentexit
|
||||
;
|
||||
|
||||
trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); }
|
||||
;
|
||||
|
||||
rootmenu: ROOTMENU STRING NEWLINE { SetRootMenu($2); free($2); }
|
||||
;
|
||||
|
||||
defaultsysmenu: DEFAULTSYSMENU STRING atspot NEWLINE { SetDefaultSysMenu($2, $3); free($2); }
|
||||
;
|
||||
|
||||
defaulticon: DEFAULTICON STRING NEWLINE { SetDefaultIcon($2); free($2); }
|
||||
;
|
||||
|
||||
icondirectory: ICONDIRECTORY STRING NEWLINE { SetIconDirectory($2); free($2); }
|
||||
;
|
||||
|
||||
menuline: SEPARATOR NEWLINE newline_or_nada { AddMenuLine("-", CMD_SEPARATOR, ""); }
|
||||
| STRING ALWAYSONTOP NEWLINE newline_or_nada { AddMenuLine($1, CMD_ALWAYSONTOP, ""); free($1); }
|
||||
| STRING EXEC STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_EXEC, $3); free($1); free($3); }
|
||||
| STRING MENU STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_MENU, $3); free($1); free($3); }
|
||||
| STRING RELOAD NEWLINE newline_or_nada { AddMenuLine($1, CMD_RELOAD, ""); free($1); }
|
||||
;
|
||||
|
||||
menulist: menuline
|
||||
| menuline menulist
|
||||
;
|
||||
|
||||
menu: MENU STRING LB { OpenMenu($2); free($2); } newline_or_nada menulist RB {CloseMenu();}
|
||||
;
|
||||
|
||||
iconline: STRING STRING NEWLINE newline_or_nada { AddIconLine($1, $2); free($1); free($2); }
|
||||
;
|
||||
|
||||
iconlist: iconline
|
||||
| iconline iconlist
|
||||
;
|
||||
|
||||
icons: ICONS LB {OpenIcons();} newline_or_nada iconlist RB {CloseIcons();}
|
||||
;
|
||||
|
||||
group1: TOPMOST { $$=STYLE_TOPMOST; }
|
||||
| MAXIMIZE { $$=STYLE_MAXIMIZE; }
|
||||
| MINIMIZE { $$=STYLE_MINIMIZE; }
|
||||
| BOTTOM { $$=STYLE_BOTTOM; }
|
||||
;
|
||||
|
||||
group2: NOTITLE { $$=STYLE_NOTITLE; }
|
||||
| OUTLINE { $$=STYLE_OUTLINE; }
|
||||
| NOFRAME { $$=STYLE_NOFRAME; }
|
||||
;
|
||||
|
||||
stylecombo: group1 { $$=$1; }
|
||||
| group2 { $$=$1; }
|
||||
| group1 group2 { $$=$1|$2; }
|
||||
| group2 group1 { $$=$1|$2; }
|
||||
;
|
||||
|
||||
styleline: STRING stylecombo NEWLINE newline_or_nada { AddStyleLine($1, $2); free($1); }
|
||||
;
|
||||
|
||||
stylelist: styleline
|
||||
| styleline stylelist
|
||||
;
|
||||
|
||||
styles: STYLES LB {OpenStyles();} newline_or_nada stylelist RB {CloseStyles();}
|
||||
;
|
||||
|
||||
atspot: { $$=AT_END; }
|
||||
| ATSTART { $$=AT_START; }
|
||||
| ATEND { $$=AT_END; }
|
||||
;
|
||||
|
||||
sysmenuline: STRING STRING atspot NEWLINE newline_or_nada { AddSysMenuLine($1, $2, $3); free($1); free($2); }
|
||||
;
|
||||
|
||||
sysmenulist: sysmenuline
|
||||
| sysmenuline sysmenulist
|
||||
;
|
||||
|
||||
sysmenu: SYSMENU LB NEWLINE {OpenSysMenu();} newline_or_nada sysmenulist RB {CloseSysMenu();}
|
||||
;
|
||||
|
||||
forceexit: FORCEEXIT NEWLINE { pref.fForceExit = TRUE; }
|
||||
;
|
||||
|
||||
silentexit: SILENTEXIT NEWLINE { pref.fSilentExit = TRUE; }
|
||||
;
|
||||
|
||||
debug: DEBUGOUTPUT STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($2); }
|
||||
;
|
||||
|
||||
|
||||
%%
|
||||
/*
|
||||
* Errors in parsing abort and print log messages
|
||||
*/
|
||||
static int
|
||||
yyerror (const char *s)
|
||||
{
|
||||
ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Miscellaneous functions to store TOKENs into the structure */
|
||||
static void
|
||||
SetIconDirectory (char *path)
|
||||
{
|
||||
strncpy (pref.iconDirectory, path, PATH_MAX);
|
||||
pref.iconDirectory[PATH_MAX] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SetDefaultIcon (char *fname)
|
||||
{
|
||||
strncpy (pref.defaultIconName, fname, NAME_MAX);
|
||||
pref.defaultIconName[NAME_MAX] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SetTrayIcon (char *fname)
|
||||
{
|
||||
strncpy (pref.trayIconName, fname, NAME_MAX);
|
||||
pref.trayIconName[NAME_MAX] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SetRootMenu (char *menuname)
|
||||
{
|
||||
strncpy (pref.rootMenuName, menuname, MENU_MAX);
|
||||
pref.rootMenuName[MENU_MAX] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SetDefaultSysMenu (char *menuname, int pos)
|
||||
{
|
||||
strncpy (pref.defaultSysMenuName, menuname, MENU_MAX);
|
||||
pref.defaultSysMenuName[MENU_MAX] = 0;
|
||||
pref.defaultSysMenuPos = pos;
|
||||
}
|
||||
|
||||
static void
|
||||
OpenMenu (char *menuname)
|
||||
{
|
||||
if (menu.menuItem) free(menu.menuItem);
|
||||
menu.menuItem = NULL;
|
||||
strncpy(menu.menuName, menuname, MENU_MAX);
|
||||
menu.menuName[MENU_MAX] = 0;
|
||||
menu.menuItems = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param)
|
||||
{
|
||||
if (menu.menuItem==NULL)
|
||||
menu.menuItem = malloc(sizeof(MENUITEM));
|
||||
else
|
||||
menu.menuItem = realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
|
||||
|
||||
strncpy (menu.menuItem[menu.menuItems].text, text, MENU_MAX);
|
||||
menu.menuItem[menu.menuItems].text[MENU_MAX] = 0;
|
||||
|
||||
menu.menuItem[menu.menuItems].cmd = cmd;
|
||||
|
||||
strncpy(menu.menuItem[menu.menuItems].param, param, PARAM_MAX);
|
||||
menu.menuItem[menu.menuItems].param[PARAM_MAX] = 0;
|
||||
|
||||
menu.menuItem[menu.menuItems].commandID = 0;
|
||||
|
||||
menu.menuItems++;
|
||||
}
|
||||
|
||||
static void
|
||||
CloseMenu (void)
|
||||
{
|
||||
if (menu.menuItem==NULL || menu.menuItems==0)
|
||||
{
|
||||
ErrorF("LoadPreferences: Empty menu detected\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pref.menuItems)
|
||||
pref.menu = realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
|
||||
else
|
||||
pref.menu = malloc (sizeof(MENUPARSED));
|
||||
|
||||
memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
|
||||
pref.menuItems++;
|
||||
|
||||
memset (&menu, 0, sizeof(MENUPARSED));
|
||||
}
|
||||
|
||||
static void
|
||||
OpenIcons (void)
|
||||
{
|
||||
if (pref.icon != NULL) {
|
||||
ErrorF("LoadPreferences: Redefining icon mappings\n");
|
||||
free(pref.icon);
|
||||
pref.icon = NULL;
|
||||
}
|
||||
pref.iconItems = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
AddIconLine (char *matchstr, char *iconfile)
|
||||
{
|
||||
if (pref.icon==NULL)
|
||||
pref.icon = malloc(sizeof(ICONITEM));
|
||||
else
|
||||
pref.icon = realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
|
||||
|
||||
strncpy(pref.icon[pref.iconItems].match, matchstr, MENU_MAX);
|
||||
pref.icon[pref.iconItems].match[MENU_MAX] = 0;
|
||||
|
||||
strncpy(pref.icon[pref.iconItems].iconFile, iconfile, PATH_MAX+NAME_MAX+1);
|
||||
pref.icon[pref.iconItems].iconFile[PATH_MAX+NAME_MAX+1] = 0;
|
||||
|
||||
pref.icon[pref.iconItems].hicon = 0;
|
||||
|
||||
pref.iconItems++;
|
||||
}
|
||||
|
||||
static void
|
||||
CloseIcons (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
OpenStyles (void)
|
||||
{
|
||||
if (pref.style != NULL) {
|
||||
ErrorF("LoadPreferences: Redefining window style\n");
|
||||
free(pref.style);
|
||||
pref.style = NULL;
|
||||
}
|
||||
pref.styleItems = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
AddStyleLine (char *matchstr, unsigned long style)
|
||||
{
|
||||
if (pref.style==NULL)
|
||||
pref.style = malloc(sizeof(STYLEITEM));
|
||||
else
|
||||
pref.style = realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1));
|
||||
|
||||
strncpy(pref.style[pref.styleItems].match, matchstr, MENU_MAX);
|
||||
pref.style[pref.styleItems].match[MENU_MAX] = 0;
|
||||
|
||||
pref.style[pref.styleItems].type = style;
|
||||
|
||||
pref.styleItems++;
|
||||
}
|
||||
|
||||
static void
|
||||
CloseStyles (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
OpenSysMenu (void)
|
||||
{
|
||||
if (pref.sysMenu != NULL) {
|
||||
ErrorF("LoadPreferences: Redefining system menu\n");
|
||||
free(pref.sysMenu);
|
||||
pref.sysMenu = NULL;
|
||||
}
|
||||
pref.sysMenuItems = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
AddSysMenuLine (char *matchstr, char *menuname, int pos)
|
||||
{
|
||||
if (pref.sysMenu==NULL)
|
||||
pref.sysMenu = malloc(sizeof(SYSMENUITEM));
|
||||
else
|
||||
pref.sysMenu = realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
|
||||
|
||||
strncpy (pref.sysMenu[pref.sysMenuItems].match, matchstr, MENU_MAX);
|
||||
pref.sysMenu[pref.sysMenuItems].match[MENU_MAX] = 0;
|
||||
|
||||
strncpy (pref.sysMenu[pref.sysMenuItems].menuName, menuname, MENU_MAX);
|
||||
pref.sysMenu[pref.sysMenuItems].menuName[MENU_MAX] = 0;
|
||||
|
||||
pref.sysMenu[pref.sysMenuItems].menuPos = pos;
|
||||
|
||||
pref.sysMenuItems++;
|
||||
}
|
||||
|
||||
static void
|
||||
CloseSysMenu (void)
|
||||
{
|
||||
}
|
||||
|
1193
hw/xwin/winprocarg.c
1193
hw/xwin/winprocarg.c
File diff suppressed because it is too large
Load Diff
|
@ -1,304 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
|
||||
*Copyright (C) 2009-2010 Jon TURNEY
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
*a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 author(s)
|
||||
*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 author(s)
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Jon TURNEY
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* Answer queries about the RandR features supported.
|
||||
*/
|
||||
|
||||
static Bool
|
||||
winRandRGetInfo(ScreenPtr pScreen, Rotation * pRotations)
|
||||
{
|
||||
winDebug("winRandRGetInfo ()\n");
|
||||
|
||||
/* Don't support rotations */
|
||||
*pRotations = RR_Rotate_0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
winRandRUpdateMode(ScreenPtr pScreen, RROutputPtr output)
|
||||
{
|
||||
/* Delete previous mode */
|
||||
if (output->modes[0])
|
||||
{
|
||||
RRModeDestroy(output->modes[0]);
|
||||
RRModeDestroy(output->crtc->mode);
|
||||
}
|
||||
|
||||
/* Register current mode */
|
||||
{
|
||||
xRRModeInfo modeInfo;
|
||||
RRModePtr mode;
|
||||
char name[100];
|
||||
|
||||
memset(&modeInfo, '\0', sizeof(modeInfo));
|
||||
snprintf(name, sizeof(name), "%dx%d", pScreen->width, pScreen->height);
|
||||
|
||||
modeInfo.width = pScreen->width;
|
||||
modeInfo.height = pScreen->height;
|
||||
modeInfo.hTotal = pScreen->width;
|
||||
modeInfo.vTotal = pScreen->height;
|
||||
modeInfo.dotClock = 0;
|
||||
modeInfo.nameLength = strlen(name);
|
||||
mode = RRModeGet(&modeInfo, name);
|
||||
|
||||
output->modes[0] = mode;
|
||||
output->numModes = 1;
|
||||
|
||||
mode = RRModeGet(&modeInfo, name);
|
||||
output->crtc->mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
void
|
||||
winDoRandRScreenSetSize(ScreenPtr pScreen,
|
||||
CARD16 width,
|
||||
CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
|
||||
{
|
||||
rrScrPrivPtr pRRScrPriv;
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
WindowPtr pRoot = pScreen->root;
|
||||
|
||||
/* Ignore changes which do nothing */
|
||||
if ((pScreen->width == width) && (pScreen->height == height) &&
|
||||
(pScreen->mmWidth == mmWidth) && (pScreen->mmHeight == mmHeight))
|
||||
return;
|
||||
|
||||
// Prevent screen updates while we change things around
|
||||
SetRootClip(pScreen, ROOT_CLIP_NONE);
|
||||
|
||||
/* Update the screen size as requested */
|
||||
pScreenInfo->dwWidth = width;
|
||||
pScreenInfo->dwHeight = height;
|
||||
|
||||
/* Reallocate the framebuffer used by the drawing engine */
|
||||
(*pScreenPriv->pwinFreeFB) (pScreen);
|
||||
if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) {
|
||||
ErrorF("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
|
||||
}
|
||||
|
||||
pScreen->width = width;
|
||||
pScreen->height = height;
|
||||
pScreen->mmWidth = mmWidth;
|
||||
pScreen->mmHeight = mmHeight;
|
||||
|
||||
/* Update the screen pixmap to point to the new framebuffer */
|
||||
winUpdateFBPointer(pScreen, pScreenInfo->pfb);
|
||||
|
||||
// pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
|
||||
// resize the root window
|
||||
//pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
|
||||
// does this emit a ConfigureNotify??
|
||||
|
||||
// Restore the ability to update screen, now with new dimensions
|
||||
SetRootClip(pScreen, ROOT_CLIP_FULL);
|
||||
|
||||
// and arrange for it to be repainted
|
||||
pScreen->PaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
|
||||
|
||||
// Set mode to current display size
|
||||
pRRScrPriv = rrGetScrPriv(pScreen);
|
||||
winRandRUpdateMode(pScreen, pRRScrPriv->primaryOutput);
|
||||
|
||||
/* Indicate that a screen size change took place */
|
||||
RRScreenSizeNotify(pScreen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Respond to resize request
|
||||
*/
|
||||
static
|
||||
Bool
|
||||
winRandRScreenSetSize(ScreenPtr pScreen,
|
||||
CARD16 width,
|
||||
CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
|
||||
winDebug("winRandRScreenSetSize ()\n");
|
||||
|
||||
/*
|
||||
It doesn't currently make sense to allow resize in fullscreen mode
|
||||
(we'd actually have to list the supported resolutions)
|
||||
*/
|
||||
if (pScreenInfo->fFullScreen) {
|
||||
ErrorF
|
||||
("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
Client resize requests aren't allowed in rootless modes, even if
|
||||
the X screen is monitor or virtual desktop size, we'd need to
|
||||
resize the native display size
|
||||
*/
|
||||
if (FALSE
|
||||
|| pScreenInfo->fRootless
|
||||
|| pScreenInfo->fMultiWindow
|
||||
) {
|
||||
ErrorF
|
||||
("winRandRScreenSetSize - resize not supported in rootless modes\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
|
||||
|
||||
/* Cause the native window for the screen to resize itself */
|
||||
{
|
||||
DWORD dwStyle, dwExStyle;
|
||||
RECT rcClient;
|
||||
|
||||
rcClient.left = 0;
|
||||
rcClient.top = 0;
|
||||
rcClient.right = width;
|
||||
rcClient.bottom = height;
|
||||
|
||||
ErrorF("winRandRScreenSetSize new client area w: %d h: %d\n", width,
|
||||
height);
|
||||
|
||||
/* Get the Windows window style and extended style */
|
||||
dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
|
||||
dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
|
||||
|
||||
/*
|
||||
* Calculate the window size needed for the given client area
|
||||
* adjusting for any decorations it will have
|
||||
*/
|
||||
AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
|
||||
|
||||
ErrorF("winRandRScreenSetSize new window area w: %d h: %d\n",
|
||||
(int)(rcClient.right - rcClient.left),
|
||||
(int)(rcClient.bottom - rcClient.top));
|
||||
|
||||
SetWindowPos(pScreenPriv->hwndScreen, NULL,
|
||||
0, 0, rcClient.right - rcClient.left,
|
||||
rcClient.bottom - rcClient.top, SWP_NOZORDER | SWP_NOMOVE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the RandR layer.
|
||||
*/
|
||||
|
||||
Bool
|
||||
winRandRInit(ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPrivPtr pRRScrPriv;
|
||||
|
||||
winDebug("winRandRInit ()\n");
|
||||
|
||||
if (!RRScreenInit(pScreen)) {
|
||||
ErrorF("winRandRInit () - RRScreenInit () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Set some RandR function pointers */
|
||||
pRRScrPriv = rrGetScrPriv(pScreen);
|
||||
pRRScrPriv->rrGetInfo = winRandRGetInfo;
|
||||
pRRScrPriv->rrSetConfig = NULL;
|
||||
pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
|
||||
pRRScrPriv->rrCrtcSet = NULL;
|
||||
pRRScrPriv->rrCrtcSetGamma = NULL;
|
||||
|
||||
/* Create a CRTC and an output for the screen, and hook them together */
|
||||
{
|
||||
RRCrtcPtr crtc;
|
||||
RROutputPtr output;
|
||||
|
||||
crtc = RRCrtcCreate(pScreen, NULL);
|
||||
if (!crtc)
|
||||
return FALSE;
|
||||
|
||||
crtc->rotations = RR_Rotate_0;
|
||||
|
||||
output = RROutputCreate(pScreen, "default", 7, NULL);
|
||||
if (!output)
|
||||
return FALSE;
|
||||
|
||||
RROutputSetCrtcs(output, &crtc, 1);
|
||||
RROutputSetConnection(output, RR_Connected);
|
||||
RROutputSetSubpixelOrder(output, PictureGetSubpixelOrder(pScreen));
|
||||
|
||||
output->crtc = crtc;
|
||||
|
||||
/* Set crtc outputs (should use RRCrtcNotify?) */
|
||||
crtc->outputs = malloc(sizeof(RROutputPtr));
|
||||
crtc->outputs[0] = output;
|
||||
crtc->numOutputs = 1;
|
||||
|
||||
pRRScrPriv->primaryOutput = output;
|
||||
|
||||
/* Ensure we have space for exactly one mode */
|
||||
output->modes = malloc(sizeof(RRModePtr));
|
||||
output->modes[0] = NULL;
|
||||
|
||||
/* Set mode to current display size */
|
||||
winRandRUpdateMode(pScreen, output);
|
||||
|
||||
/* Make up some physical dimensions */
|
||||
output->mmWidth = (pScreen->width * 25.4)/monitorResolution;
|
||||
output->mmHeight = (pScreen->height * 25.4)/monitorResolution;
|
||||
|
||||
/* Allocate and make up a (fixed, linear) gamma ramp */
|
||||
{
|
||||
int i;
|
||||
RRCrtcGammaSetSize(crtc, 256);
|
||||
for (i = 0; i < crtc->gammaSize; i++) {
|
||||
crtc->gammaRed[i] = i << 8;
|
||||
crtc->gammaBlue[i] = i << 8;
|
||||
crtc->gammaGreen[i] = i << 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
The screen doesn't have to be limited to the actual
|
||||
monitor size (we can have scrollbars :-), so set the
|
||||
upper limit to the maximum coordinates X11 can use.
|
||||
*/
|
||||
RRScreenSetSizeRange(pScreen, 0, 0, 32768, 32768);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
#if !defined(WINRESOURCE_H)
|
||||
#define WINRESOURCE_H
|
||||
/*
|
||||
*Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
/*
|
||||
* Local defines
|
||||
*/
|
||||
|
||||
#define IDC_STATIC -1
|
||||
#define IDI_XWIN 101
|
||||
#define IDM_TRAYICON_MENU 103
|
||||
#define IDC_CLIENTS_CONNECTED 104
|
||||
|
||||
#define ID_APP_EXIT 200
|
||||
#define ID_APP_HIDE_ROOT 201
|
||||
#define ID_APP_ALWAYS_ON_TOP 202
|
||||
#define ID_APP_ABOUT 203
|
||||
#define ID_APP_MONITOR_PRIMARY 204
|
||||
|
||||
#define ID_ABOUT_WEBSITE 303
|
||||
|
||||
#endif
|
|
@ -1,504 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Dakshinamurthy Karra
|
||||
* Suhaib M Siddiqi
|
||||
* Peter Busch
|
||||
* Harold L Hunt II
|
||||
* Kensuke Matsuzaki
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
/*
|
||||
* Determine what type of screen we are initializing
|
||||
* and call the appropriate procedure to initialize
|
||||
* that type of screen.
|
||||
*/
|
||||
|
||||
Bool
|
||||
winScreenInit(ScreenPtr pScreen, int argc, char **argv)
|
||||
{
|
||||
winScreenInfoPtr pScreenInfo = &g_ScreenInfo[pScreen->myNum];
|
||||
winPrivScreenPtr pScreenPriv;
|
||||
HDC hdc;
|
||||
DWORD dwInitialBPP;
|
||||
|
||||
#if CYGDEBUG || YES
|
||||
winDebug("winScreenInit - dwWidth: %u dwHeight: %u\n",
|
||||
(unsigned int)pScreenInfo->dwWidth, (unsigned int)pScreenInfo->dwHeight);
|
||||
#endif
|
||||
|
||||
/* Allocate privates for this screen */
|
||||
if (!winAllocatePrivates(pScreen)) {
|
||||
ErrorF("winScreenInit - Couldn't allocate screen privates\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get a pointer to the privates structure that was allocated */
|
||||
pScreenPriv = winGetScreenPriv(pScreen);
|
||||
|
||||
/* Save a pointer to this screen in the screen info structure */
|
||||
pScreenInfo->pScreen = pScreen;
|
||||
|
||||
/* Save a pointer to the screen info in the screen privates structure */
|
||||
/* This allows us to get back to the screen info from a screen pointer */
|
||||
pScreenPriv->pScreenInfo = pScreenInfo;
|
||||
|
||||
/*
|
||||
* Determine which engine to use.
|
||||
*
|
||||
* NOTE: This is done once per screen because each screen possibly has
|
||||
* a preferred engine specified on the command line.
|
||||
*/
|
||||
if (!winSetEngine(pScreen)) {
|
||||
ErrorF("winScreenInit - winSetEngine () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Horribly misnamed function: Allow engine to adjust BPP for screen */
|
||||
dwInitialBPP = pScreenInfo->dwBPP;
|
||||
|
||||
if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen)) {
|
||||
ErrorF("winScreenInit - winAdjustVideoMode () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (dwInitialBPP == WIN_DEFAULT_BPP) {
|
||||
/* No -depth parameter was passed, let the user know the depth being used */
|
||||
ErrorF
|
||||
("winScreenInit - Using Windows display depth of %d bits per pixel\n",
|
||||
(int) pScreenInfo->dwBPP);
|
||||
}
|
||||
else if (dwInitialBPP != pScreenInfo->dwBPP) {
|
||||
/* Warn user if engine forced a depth different to -depth parameter */
|
||||
ErrorF
|
||||
("winScreenInit - Command line depth of %d bpp overridden by engine, using %d bpp\n",
|
||||
(int) dwInitialBPP, (int) pScreenInfo->dwBPP);
|
||||
}
|
||||
else {
|
||||
ErrorF("winScreenInit - Using command line depth of %d bpp\n",
|
||||
(int) pScreenInfo->dwBPP);
|
||||
}
|
||||
|
||||
/* Check for supported display depth */
|
||||
if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1)))) {
|
||||
ErrorF("winScreenInit - Unsupported display depth: %d\n"
|
||||
"Change your Windows display depth to 15, 16, 24, or 32 bits "
|
||||
"per pixel.\n", (int) pScreenInfo->dwBPP);
|
||||
ErrorF("winScreenInit - Supported depths: %08x\n", WIN_SUPPORTED_BPPS);
|
||||
#if WIN_CHECK_DEPTH
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that all monitors have the same display depth if we are using
|
||||
* multiple monitors
|
||||
*/
|
||||
if (pScreenInfo->fMultipleMonitors
|
||||
&& !GetSystemMetrics(SM_SAMEDISPLAYFORMAT)) {
|
||||
ErrorF("winScreenInit - Monitors do not all have same pixel format / "
|
||||
"display depth.\n");
|
||||
if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI) {
|
||||
ErrorF
|
||||
("winScreenInit - Performance may suffer off primary display.\n");
|
||||
}
|
||||
else {
|
||||
ErrorF("winScreenInit - Using primary display only.\n");
|
||||
pScreenInfo->fMultipleMonitors = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create display window */
|
||||
if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen)) {
|
||||
ErrorF("winScreenInit - pwinCreateBoundingWindow () " "failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get a device context */
|
||||
hdc = GetDC(pScreenPriv->hwndScreen);
|
||||
|
||||
/* Are we using multiple monitors? */
|
||||
if (pScreenInfo->fMultipleMonitors) {
|
||||
/*
|
||||
* In this case, some of the defaults set in
|
||||
* winInitializeScreenDefaults() are not correct ...
|
||||
*/
|
||||
if (!pScreenInfo->fUserGaveHeightAndWidth) {
|
||||
pScreenInfo->dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
pScreenInfo->dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/* Release the device context */
|
||||
ReleaseDC(pScreenPriv->hwndScreen, hdc);
|
||||
|
||||
/* Clear the visuals list */
|
||||
miClearVisualTypes();
|
||||
|
||||
/* Call the engine dependent screen initialization procedure */
|
||||
if (!((*pScreenPriv->pwinFinishScreenInit) (pScreen->myNum, pScreen, argc, argv))) {
|
||||
ErrorF("winScreenInit - winFinishScreenInit () failed\n");
|
||||
|
||||
/* call the engine dependent screen close procedure to clean up from a failure */
|
||||
pScreenPriv->pwinCloseScreen(pScreen);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!g_fSoftwareCursor)
|
||||
winInitCursor(pScreen);
|
||||
else
|
||||
winErrorFVerb(2, "winScreenInit - Using software cursor\n");
|
||||
|
||||
if (!noPanoramiXExtension) {
|
||||
/*
|
||||
Note the screen origin in a normalized coordinate space where (0,0) is at the top left
|
||||
of the native virtual desktop area
|
||||
*/
|
||||
pScreen->x =
|
||||
pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
pScreen->y =
|
||||
pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
|
||||
ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n",
|
||||
pScreen->myNum, pScreen->x, pScreen->y);
|
||||
}
|
||||
|
||||
#if CYGDEBUG || YES
|
||||
winDebug("winScreenInit - returning\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
winCreateScreenResources(ScreenPtr pScreen)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
Bool result;
|
||||
|
||||
result = pScreenPriv->pwinCreateScreenResources(pScreen);
|
||||
|
||||
/* Now the screen bitmap has been wrapped in a pixmap,
|
||||
add that to the Shadow framebuffer */
|
||||
if (!shadowAdd(pScreen, pScreen->devPrivate,
|
||||
pScreenPriv->pwinShadowUpdate, NULL, 0, 0)) {
|
||||
ErrorF("winCreateScreenResources - shadowAdd () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 20 */
|
||||
Bool
|
||||
winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
|
||||
{
|
||||
winScreenPriv(pScreen);
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
VisualPtr pVisual = NULL;
|
||||
|
||||
int iReturn;
|
||||
|
||||
/* Create framebuffer */
|
||||
if (!(*pScreenPriv->pwinInitScreen) (pScreen)) {
|
||||
ErrorF("winFinishScreenInitFB - Could not allocate framebuffer\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the number of bits that are used to represent color in each pixel,
|
||||
* the color depth for the screen
|
||||
*/
|
||||
if (pScreenInfo->dwBPP == 8)
|
||||
pScreenInfo->dwDepth = 8;
|
||||
else
|
||||
pScreenInfo->dwDepth = winCountBits(pScreenPriv->dwRedMask)
|
||||
+ winCountBits(pScreenPriv->dwGreenMask)
|
||||
+ winCountBits(pScreenPriv->dwBlueMask);
|
||||
|
||||
winErrorFVerb(2, "winFinishScreenInitFB - Masks: %08x %08x %08x\n",
|
||||
(unsigned int) pScreenPriv->dwRedMask,
|
||||
(unsigned int) pScreenPriv->dwGreenMask,
|
||||
(unsigned int) pScreenPriv->dwBlueMask);
|
||||
|
||||
/* Init visuals */
|
||||
if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) {
|
||||
ErrorF("winFinishScreenInitFB - winInitVisuals failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((pScreenInfo->dwBPP == 8) && (pScreenInfo->fCompositeWM)) {
|
||||
ErrorF("-compositewm disabled due to 8bpp depth\n");
|
||||
pScreenInfo->fCompositeWM = FALSE;
|
||||
}
|
||||
|
||||
/* Apparently we need this for the render extension */
|
||||
miSetPixmapDepths();
|
||||
|
||||
/* Start fb initialization */
|
||||
if (!fbSetupScreen(pScreen,
|
||||
pScreenInfo->pfb,
|
||||
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
|
||||
monitorResolution, monitorResolution,
|
||||
pScreenInfo->dwStride, pScreenInfo->dwBPP)) {
|
||||
ErrorF("winFinishScreenInitFB - fbSetupScreen failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Override default colormap routines if visual class is dynamic */
|
||||
if (pScreenInfo->dwDepth == 8
|
||||
&& (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
|
||||
|| (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
|
||||
&& pScreenInfo->fFullScreen))) {
|
||||
winSetColormapFunctions(pScreen);
|
||||
|
||||
/*
|
||||
* NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
|
||||
* own colormap, as it cannot allocate 7 planes in the default
|
||||
* colormap. Setting whitePixel to 1 allows Magic to get 7
|
||||
* planes in the default colormap, so it doesn't create its
|
||||
* own colormap. This latter situation is highly desirable,
|
||||
* as it keeps the Magic window viewable when switching to
|
||||
* other X clients that use the default colormap.
|
||||
*/
|
||||
pScreen->blackPixel = 0;
|
||||
pScreen->whitePixel = 1;
|
||||
}
|
||||
|
||||
/* Finish fb initialization */
|
||||
if (!fbFinishScreenInit(pScreen,
|
||||
pScreenInfo->pfb,
|
||||
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
|
||||
monitorResolution, monitorResolution,
|
||||
pScreenInfo->dwStride, pScreenInfo->dwBPP)) {
|
||||
ErrorF("winFinishScreenInitFB - fbFinishScreenInit failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Save a pointer to the root visual */
|
||||
for (pVisual = pScreen->visuals;
|
||||
pVisual->vid != pScreen->rootVisual; pVisual++);
|
||||
pScreenPriv->pRootVisual = pVisual;
|
||||
|
||||
/*
|
||||
* Setup points to the block and wakeup handlers. Pass a pointer
|
||||
* to the current screen as pWakeupdata.
|
||||
*/
|
||||
pScreen->BlockHandler = winBlockHandler;
|
||||
pScreen->WakeupHandler = winWakeupHandler;
|
||||
|
||||
/* Render extension initialization, calls miPictureInit */
|
||||
if (!fbPictureInit(pScreen, NULL, 0)) {
|
||||
ErrorF("winFinishScreenInitFB - fbPictureInit () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef RANDR
|
||||
/* Initialize resize and rotate support */
|
||||
if (!winRandRInit(pScreen)) {
|
||||
ErrorF("winFinishScreenInitFB - winRandRInit () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Setup the cursor routines */
|
||||
#if CYGDEBUG
|
||||
winDebug("winFinishScreenInitFB - Calling miDCInitialize ()\n");
|
||||
#endif
|
||||
miDCInitialize(pScreen, &g_winPointerCursorFuncs);
|
||||
|
||||
/* KDrive does winCreateDefColormap right after miDCInitialize */
|
||||
/* Create a default colormap */
|
||||
#if CYGDEBUG
|
||||
winDebug("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
|
||||
#endif
|
||||
if (!winCreateDefColormap(pScreen)) {
|
||||
ErrorF("winFinishScreenInitFB - Could not create colormap\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize the shadow framebuffer layer */
|
||||
if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
|
||||
|| pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
|
||||
#if CYGDEBUG
|
||||
winDebug("winFinishScreenInitFB - Calling shadowSetup ()\n");
|
||||
#endif
|
||||
if (!shadowSetup(pScreen)) {
|
||||
ErrorF("winFinishScreenInitFB - shadowSetup () failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Wrap CreateScreenResources so we can add the screen pixmap
|
||||
to the Shadow framebuffer after it's been created */
|
||||
pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
|
||||
pScreen->CreateScreenResources = winCreateScreenResources;
|
||||
}
|
||||
|
||||
/* Handle rootless mode */
|
||||
if (pScreenInfo->fRootless) {
|
||||
/* Define the WRAP macro temporarily for local use */
|
||||
#define WRAP(a) \
|
||||
if (pScreen->a) { \
|
||||
pScreenPriv->a = pScreen->a; \
|
||||
} else { \
|
||||
winDebug("winScreenInit - null screen fn " #a "\n"); \
|
||||
pScreenPriv->a = NULL; \
|
||||
}
|
||||
|
||||
/* Save a pointer to each lower-level window procedure */
|
||||
WRAP(CreateWindow);
|
||||
WRAP(DestroyWindow);
|
||||
WRAP(RealizeWindow);
|
||||
WRAP(UnrealizeWindow);
|
||||
WRAP(PositionWindow);
|
||||
WRAP(ChangeWindowAttributes);
|
||||
WRAP(SetShape);
|
||||
|
||||
/* Assign rootless window procedures to be top level procedures */
|
||||
pScreen->CreateWindow = winCreateWindowRootless;
|
||||
pScreen->DestroyWindow = winDestroyWindowRootless;
|
||||
pScreen->PositionWindow = winPositionWindowRootless;
|
||||
/*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless; */
|
||||
pScreen->RealizeWindow = winMapWindowRootless;
|
||||
pScreen->UnrealizeWindow = winUnmapWindowRootless;
|
||||
pScreen->SetShape = winSetShapeRootless;
|
||||
|
||||
/* Undefine the WRAP macro, as it is not needed elsewhere */
|
||||
#undef WRAP
|
||||
}
|
||||
|
||||
/* Handle multi window mode */
|
||||
else if (pScreenInfo->fMultiWindow) {
|
||||
/* Define the WRAP macro temporarily for local use */
|
||||
#define WRAP(a) \
|
||||
if (pScreen->a) { \
|
||||
pScreenPriv->a = pScreen->a; \
|
||||
} else { \
|
||||
winDebug("null screen fn " #a "\n"); \
|
||||
pScreenPriv->a = NULL; \
|
||||
}
|
||||
|
||||
/* Save a pointer to each lower-level window procedure */
|
||||
WRAP(CreateWindow);
|
||||
WRAP(DestroyWindow);
|
||||
WRAP(RealizeWindow);
|
||||
WRAP(UnrealizeWindow);
|
||||
WRAP(PositionWindow);
|
||||
WRAP(ChangeWindowAttributes);
|
||||
WRAP(ReparentWindow);
|
||||
WRAP(RestackWindow);
|
||||
WRAP(ResizeWindow);
|
||||
WRAP(MoveWindow);
|
||||
WRAP(CopyWindow);
|
||||
WRAP(SetShape);
|
||||
WRAP(ModifyPixmapHeader);
|
||||
|
||||
/* Assign multi-window window procedures to be top level procedures */
|
||||
pScreen->CreateWindow = winCreateWindowMultiWindow;
|
||||
pScreen->DestroyWindow = winDestroyWindowMultiWindow;
|
||||
pScreen->PositionWindow = winPositionWindowMultiWindow;
|
||||
/*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow; */
|
||||
pScreen->RealizeWindow = winMapWindowMultiWindow;
|
||||
pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
|
||||
pScreen->ReparentWindow = winReparentWindowMultiWindow;
|
||||
pScreen->RestackWindow = winRestackWindowMultiWindow;
|
||||
pScreen->ResizeWindow = winResizeWindowMultiWindow;
|
||||
pScreen->MoveWindow = winMoveWindowMultiWindow;
|
||||
pScreen->CopyWindow = winCopyWindowMultiWindow;
|
||||
pScreen->SetShape = winSetShapeMultiWindow;
|
||||
|
||||
if (pScreenInfo->fCompositeWM) {
|
||||
pScreen->CreatePixmap = winCreatePixmapMultiwindow;
|
||||
pScreen->DestroyPixmap = winDestroyPixmapMultiwindow;
|
||||
pScreen->ModifyPixmapHeader = winModifyPixmapHeaderMultiwindow;
|
||||
}
|
||||
|
||||
/* Undefine the WRAP macro, as it is not needed elsewhere */
|
||||
#undef WRAP
|
||||
}
|
||||
|
||||
/* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
|
||||
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
||||
pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
|
||||
|
||||
/* Create a mutex for modules in separate threads to wait for */
|
||||
iReturn = pthread_mutex_init(&pScreenPriv->pmServerStarted, NULL);
|
||||
if (iReturn != 0) {
|
||||
ErrorF("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
|
||||
iReturn);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Own the mutex for modules in separate threads */
|
||||
iReturn = pthread_mutex_lock(&pScreenPriv->pmServerStarted);
|
||||
if (iReturn != 0) {
|
||||
ErrorF("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
|
||||
iReturn);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Set the ServerStarted flag to false */
|
||||
pScreenPriv->fServerStarted = FALSE;
|
||||
|
||||
|
||||
if (pScreenInfo->fMultiWindow) {
|
||||
#if CYGDEBUG || YES
|
||||
winDebug("winFinishScreenInitFB - Calling winInitWM.\n");
|
||||
#endif
|
||||
|
||||
/* Initialize multi window mode */
|
||||
if (!winInitWM(&pScreenPriv->pWMInfo,
|
||||
&pScreenPriv->ptWMProc,
|
||||
&pScreenPriv->ptXMsgProc,
|
||||
&pScreenPriv->pmServerStarted,
|
||||
pScreenInfo->dwScreen,
|
||||
(HWND) &pScreenPriv->hwndScreen,
|
||||
pScreenInfo->fCompositeWM)) {
|
||||
ErrorF("winFinishScreenInitFB - winInitWM () failed.\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tell the server that we are enabled */
|
||||
pScreenPriv->fEnabled = TRUE;
|
||||
|
||||
/* Tell the server that we have a valid depth */
|
||||
pScreenPriv->fBadDepth = FALSE;
|
||||
|
||||
#if CYGDEBUG || YES
|
||||
winDebug("winFinishScreenInitFB - returning\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
1285
hw/xwin/winshadgdi.c
1285
hw/xwin/winshadgdi.c
File diff suppressed because it is too large
Load Diff
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "win.h"
|
||||
#include "winwindow.h"
|
||||
|
||||
const GUID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
|
||||
const GUID IID_ITaskbarList = {0x56fdf342,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
|
||||
|
||||
#ifdef INTERFACE
|
||||
#undef INTERFACE
|
||||
#endif
|
||||
|
||||
#define INTERFACE ITaskbarList
|
||||
DECLARE_INTERFACE_(ITaskbarList, IUnknown)
|
||||
{
|
||||
/* IUnknown methods */
|
||||
STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
|
||||
STDMETHOD_(ULONG, AddRef) (THIS) PURE;
|
||||
STDMETHOD_(ULONG, Release) (THIS) PURE;
|
||||
|
||||
/* ITaskbarList methods */
|
||||
STDMETHOD(HrInit) (THIS) PURE;
|
||||
STDMETHOD(AddTab) (THIS_ HWND hWnd) PURE;
|
||||
STDMETHOD(DeleteTab) (THIS_ HWND hWnd) PURE;
|
||||
STDMETHOD(ActivateTab) (THIS_ HWND hWnd) PURE;
|
||||
STDMETHOD(SetActiveAlt) (THIS_ HWND hWnd) PURE;
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
/*
|
||||
The stuff above needs to be in win32api headers, not defined here,
|
||||
or at least generated from the MIDL :-)
|
||||
*/
|
||||
|
||||
/*
|
||||
This is unnecessarily heavyweight, we could just call CoInitialize() once at
|
||||
startup and CoUninitialize() once at shutdown
|
||||
*/
|
||||
|
||||
/*
|
||||
The documentation for ITaskbarList::AddTab says that we are responsible for
|
||||
deleting the tab ourselves when the window is deleted, but that doesn't actually
|
||||
seem to be the case
|
||||
*/
|
||||
|
||||
void winShowWindowOnTaskbar(HWND hWnd, Bool show)
|
||||
{
|
||||
ITaskbarList* pTaskbarList = NULL;
|
||||
|
||||
if (SUCCEEDED(CoInitialize(NULL)))
|
||||
{
|
||||
if (SUCCEEDED(CoCreateInstance((const CLSID *)&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, (const IID *)&IID_ITaskbarList, (void**)&pTaskbarList)))
|
||||
{
|
||||
if (SUCCEEDED(pTaskbarList->lpVtbl->HrInit(pTaskbarList)))
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
pTaskbarList->lpVtbl->AddTab(pTaskbarList,hWnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
pTaskbarList->lpVtbl->DeleteTab(pTaskbarList,hWnd);
|
||||
}
|
||||
}
|
||||
pTaskbarList->lpVtbl->Release(pTaskbarList);
|
||||
}
|
||||
CoUninitialize();
|
||||
}
|
||||
}
|
|
@ -1,203 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Early Ehlinger
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
|
||||
#include "win.h"
|
||||
#include <shellapi.h>
|
||||
#include "winprefs.h"
|
||||
#include "winclipboard/winclipboard.h"
|
||||
|
||||
/*
|
||||
* Initialize the tray icon
|
||||
*/
|
||||
|
||||
void
|
||||
winInitNotifyIcon(winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
NOTIFYICONDATA nid = { 0 };
|
||||
|
||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
nid.hWnd = pScreenPriv->hwndScreen;
|
||||
nid.uID = pScreenInfo->dwScreen;
|
||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
nid.uCallbackMessage = WM_TRAYICON;
|
||||
nid.hIcon = winTaskbarIcon();
|
||||
|
||||
/* Save handle to the icon so it can be freed later */
|
||||
pScreenPriv->hiconNotifyIcon = nid.hIcon;
|
||||
|
||||
/* Set display and screen-specific tooltip text */
|
||||
snprintf(nid.szTip,
|
||||
sizeof(nid.szTip),
|
||||
PROJECT_NAME " Server:%s.%d",
|
||||
display, (int) pScreenInfo->dwScreen);
|
||||
|
||||
/* Add the tray icon */
|
||||
if (!Shell_NotifyIcon(NIM_ADD, &nid))
|
||||
ErrorF("winInitNotifyIcon - Shell_NotifyIcon Failed\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete the tray icon
|
||||
*/
|
||||
|
||||
void
|
||||
winDeleteNotifyIcon(winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
NOTIFYICONDATA nid = { 0 };
|
||||
|
||||
#if 0
|
||||
ErrorF("winDeleteNotifyIcon\n");
|
||||
#endif
|
||||
|
||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
nid.hWnd = pScreenPriv->hwndScreen;
|
||||
nid.uID = pScreenInfo->dwScreen;
|
||||
|
||||
/* Delete the tray icon */
|
||||
if (!Shell_NotifyIcon(NIM_DELETE, &nid)) {
|
||||
ErrorF("winDeleteNotifyIcon - Shell_NotifyIcon failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Free the icon that was loaded */
|
||||
if (pScreenPriv->hiconNotifyIcon != NULL
|
||||
&& DestroyIcon(pScreenPriv->hiconNotifyIcon) == 0) {
|
||||
ErrorF("winDeleteNotifyIcon - DestroyIcon failed\n");
|
||||
}
|
||||
pScreenPriv->hiconNotifyIcon = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process messages intended for the tray icon
|
||||
*/
|
||||
|
||||
LRESULT
|
||||
winHandleIconMessage(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam, winPrivScreenPtr pScreenPriv)
|
||||
{
|
||||
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
|
||||
|
||||
switch (lParam) {
|
||||
case WM_LBUTTONUP:
|
||||
/* Restack and bring all windows to top */
|
||||
SetForegroundWindow (pScreenPriv->hwndScreen);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
/* Display Exit dialog box */
|
||||
winDisplayExitDialog(pScreenPriv);
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
POINT ptCursor;
|
||||
HMENU hmenuPopup;
|
||||
HMENU hmenuTray;
|
||||
|
||||
/* Get cursor position */
|
||||
GetCursorPos(&ptCursor);
|
||||
|
||||
/* Load tray icon menu resource */
|
||||
hmenuPopup = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_TRAYICON_MENU));
|
||||
if (!hmenuPopup)
|
||||
ErrorF("winHandleIconMessage - LoadMenu failed\n");
|
||||
|
||||
/* Get actual tray icon menu */
|
||||
hmenuTray = GetSubMenu(hmenuPopup, 0);
|
||||
|
||||
/* Check for MultiWindow mode */
|
||||
if (pScreenInfo->fMultiWindow) {
|
||||
MENUITEMINFO mii = { 0 };
|
||||
|
||||
/* Root is shown, remove the check box */
|
||||
|
||||
/* Setup menu item info structure */
|
||||
mii.cbSize = sizeof(MENUITEMINFO);
|
||||
mii.fMask = MIIM_STATE;
|
||||
mii.fState = MFS_CHECKED;
|
||||
|
||||
/* Unheck box if root is shown */
|
||||
if (pScreenPriv->fRootWindowShown)
|
||||
mii.fState = MFS_UNCHECKED;
|
||||
|
||||
/* Set menu state */
|
||||
SetMenuItemInfo(hmenuTray, ID_APP_HIDE_ROOT, FALSE, &mii);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remove Hide Root Window button */
|
||||
RemoveMenu(hmenuTray, ID_APP_HIDE_ROOT, MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
if (g_fClipboard) {
|
||||
/* Set menu state to indicate if 'Monitor Primary' is enabled or not */
|
||||
MENUITEMINFO mii = { 0 };
|
||||
mii.cbSize = sizeof(MENUITEMINFO);
|
||||
mii.fMask = MIIM_STATE;
|
||||
mii.fState = fPrimarySelection ? MFS_CHECKED : MFS_UNCHECKED;
|
||||
SetMenuItemInfo(hmenuTray, ID_APP_MONITOR_PRIMARY, FALSE, &mii);
|
||||
}
|
||||
else {
|
||||
/* Remove 'Monitor Primary' menu item */
|
||||
RemoveMenu(hmenuTray, ID_APP_MONITOR_PRIMARY, MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
SetupRootMenu(hmenuTray);
|
||||
|
||||
/*
|
||||
* NOTE: This three-step procedure is required for
|
||||
* proper popup menu operation. Without the
|
||||
* call to SetForegroundWindow the
|
||||
* popup menu will often not disappear when you click
|
||||
* outside of it. Without the PostMessage the second
|
||||
* time you display the popup menu it might immediately
|
||||
* disappear.
|
||||
*/
|
||||
SetForegroundWindow(hwnd);
|
||||
TrackPopupMenuEx(hmenuTray,
|
||||
TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
|
||||
ptCursor.x, ptCursor.y, hwnd, NULL);
|
||||
PostMessage(hwnd, WM_NULL, 0, 0);
|
||||
|
||||
/* Free menu */
|
||||
DestroyMenu(hmenuPopup);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 HAROLD L HUNT II 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 Harold L Hunt II
|
||||
*shall not be used in advertising or otherwise to promote the sale, use
|
||||
*or other dealings in this Software without prior written authorization
|
||||
*from Harold L Hunt II.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
#include "winmsg.h"
|
||||
|
||||
/*
|
||||
* Verify all screens have been explicitly specified
|
||||
*/
|
||||
static BOOL
|
||||
isEveryScreenExplicit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < g_iNumScreens; i++)
|
||||
if (!g_ScreenInfo[i].fExplicitScreen)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* winValidateArgs - Look for invalid argument combinations
|
||||
*/
|
||||
|
||||
Bool
|
||||
winValidateArgs(void)
|
||||
{
|
||||
int i;
|
||||
BOOL fHasNormalScreen0 = FALSE;
|
||||
|
||||
/*
|
||||
* Check for a malformed set of -screen parameters.
|
||||
* Examples of malformed parameters:
|
||||
* XWin -screen 1
|
||||
* XWin -screen 0 -screen 2
|
||||
* XWin -screen 1 -screen 2
|
||||
*/
|
||||
if (!isEveryScreenExplicit()) {
|
||||
ErrorF("winValidateArgs - Malformed set of screen parameter(s). "
|
||||
"Screens must be specified consecutively starting with "
|
||||
"screen 0. That is, you cannot have only a screen 1, nor "
|
||||
"could you have screen 0 and screen 2. You instead must "
|
||||
"have screen 0, or screen 0 and screen 1, respectively. "
|
||||
"You can specify as many screens as you want.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Loop through all screens */
|
||||
for (i = 0; i < g_iNumScreens; ++i) {
|
||||
/*
|
||||
* Check for any combination of
|
||||
* -multiwindow and -rootless.
|
||||
*/
|
||||
{
|
||||
int iCount = 0;
|
||||
|
||||
/* Count conflicting options */
|
||||
if (g_ScreenInfo[i].fMultiWindow)
|
||||
++iCount;
|
||||
|
||||
if (g_ScreenInfo[i].fRootless)
|
||||
++iCount;
|
||||
|
||||
/* Check if the first screen is without rootless and multiwindow */
|
||||
if (iCount == 0 && i == 0)
|
||||
fHasNormalScreen0 = TRUE;
|
||||
|
||||
/* Fail if two or more conflicting options */
|
||||
if (iCount > 1) {
|
||||
ErrorF("winValidateArgs - Only one of -multiwindow "
|
||||
"and -rootless can be specific at a time.\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for -multiwindow and Xdmcp */
|
||||
/* allow xdmcp if screen 0 is normal. */
|
||||
if (g_fXdmcpEnabled && !fHasNormalScreen0 && (FALSE
|
||||
|| g_ScreenInfo[i].
|
||||
fMultiWindow
|
||||
|
||||
)
|
||||
) {
|
||||
ErrorF("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
|
||||
"is invalid with -multiwindow.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check for -multiwindow or -rootless and -fullscreen */
|
||||
if (g_ScreenInfo[i].fFullScreen && (FALSE
|
||||
|| g_ScreenInfo[i].fMultiWindow
|
||||
|| g_ScreenInfo[i].fRootless)
|
||||
) {
|
||||
ErrorF("winValidateArgs - -fullscreen is invalid with "
|
||||
"-multiwindow or -rootless.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check for -multiwindow or -rootless and -nodecoration */
|
||||
if (!g_ScreenInfo[i].fDecoration && (FALSE
|
||||
|| g_ScreenInfo[i].fMultiWindow
|
||||
|| g_ScreenInfo[i].fRootless)
|
||||
) {
|
||||
ErrorF("winValidateArgs - -nodecoration is invalid with "
|
||||
"-multiwindow or -rootless.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check for !fullscreen and any fullscreen-only parameters */
|
||||
if (!g_ScreenInfo[i].fFullScreen
|
||||
&& (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH
|
||||
|| g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP)) {
|
||||
ErrorF("winValidateArgs - -refresh and -depth are only valid "
|
||||
"with -fullscreen.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check for fullscreen and any non-fullscreen parameters */
|
||||
if (g_ScreenInfo[i].fFullScreen
|
||||
&& ((g_ScreenInfo[i].iResizeMode != resizeNotAllowed)
|
||||
|| !g_ScreenInfo[i].fDecoration
|
||||
|| g_ScreenInfo[i].fLessPointer)) {
|
||||
ErrorF("winValidateArgs - -fullscreen is invalid with "
|
||||
"-scrollbars, -resize, -nodecoration, or -lesspointer.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Ignore -swcursor if -multiwindow -compositewm is requested */
|
||||
if (g_ScreenInfo[i].fMultiWindow && g_ScreenInfo[i].fCompositeWM) {
|
||||
if (g_fSoftwareCursor) {
|
||||
g_fSoftwareCursor = FALSE;
|
||||
winMsg(X_WARNING, "Ignoring -swcursor due to -compositewm\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
winDebug("winValidateArgs - Returning.\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Dakshinamurthy Karra
|
||||
* Suhaib M Siddiqi
|
||||
* Peter Busch
|
||||
* Harold L Hunt II
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/* See Porting Layer Definition - p. 7 */
|
||||
void
|
||||
winWakeupHandler(ScreenPtr pScreen, int iResult)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
/* Process one message from our queue */
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if ((g_hDlgDepthChange == 0
|
||||
|| !IsDialogMessage(g_hDlgDepthChange, &msg))
|
||||
&& (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))
|
||||
&& (g_hDlgAbout == 0 || !IsDialogMessage(g_hDlgAbout, &msg))) {
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,381 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Harold L Hunt II
|
||||
* Kensuke Matsuzaki
|
||||
*/
|
||||
|
||||
#ifdef HAVE_XWIN_CONFIG_H
|
||||
#include <xwin-config.h>
|
||||
#endif
|
||||
#include "win.h"
|
||||
|
||||
/*
|
||||
* Prototypes for local functions
|
||||
*/
|
||||
|
||||
static int
|
||||
winAddRgn(WindowPtr pWindow, void *data);
|
||||
|
||||
static
|
||||
void
|
||||
winUpdateRgnRootless(WindowPtr pWindow);
|
||||
|
||||
static
|
||||
void
|
||||
winReshapeRootless(WindowPtr pWin);
|
||||
|
||||
/* See Porting Layer Definition - p. 37 */
|
||||
/* See mfb/mfbwindow.c - mfbCreateWindow() */
|
||||
|
||||
Bool
|
||||
winCreateWindowRootless(WindowPtr pWin)
|
||||
{
|
||||
Bool fResult = FALSE;
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winWindowPriv(pWin);
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winCreateWindowRootless (%p)\n", pWin);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(CreateWindow);
|
||||
fResult = (*pScreen->CreateWindow) (pWin);
|
||||
WIN_WRAP(CreateWindow, winCreateWindowRootless);
|
||||
|
||||
pWinPriv->hRgn = NULL;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 37 */
|
||||
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
|
||||
|
||||
Bool
|
||||
winDestroyWindowRootless(WindowPtr pWin)
|
||||
{
|
||||
Bool fResult = FALSE;
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winWindowPriv(pWin);
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winDestroyWindowRootless (%p)\n", pWin);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(DestroyWindow);
|
||||
fResult = (*pScreen->DestroyWindow) (pWin);
|
||||
WIN_WRAP(DestroyWindow, winDestroyWindowRootless);
|
||||
|
||||
if (pWinPriv->hRgn != NULL) {
|
||||
DeleteObject(pWinPriv->hRgn);
|
||||
pWinPriv->hRgn = NULL;
|
||||
}
|
||||
|
||||
winUpdateRgnRootless(pWin);
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 37 */
|
||||
/* See mfb/mfbwindow.c - mfbPositionWindow() */
|
||||
|
||||
Bool
|
||||
winPositionWindowRootless(WindowPtr pWin, int x, int y)
|
||||
{
|
||||
Bool fResult = FALSE;
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winPositionWindowRootless (%p)\n", pWin);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(PositionWindow);
|
||||
fResult = (*pScreen->PositionWindow) (pWin, x, y);
|
||||
WIN_WRAP(PositionWindow, winPositionWindowRootless);
|
||||
|
||||
winUpdateRgnRootless(pWin);
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 37 */
|
||||
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
|
||||
|
||||
Bool
|
||||
winChangeWindowAttributesRootless(WindowPtr pWin, unsigned long mask)
|
||||
{
|
||||
Bool fResult = FALSE;
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winChangeWindowAttributesRootless (%p)\n", pWin);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(ChangeWindowAttributes);
|
||||
fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask);
|
||||
WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless);
|
||||
|
||||
winUpdateRgnRootless(pWin);
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 37
|
||||
* Also referred to as UnrealizeWindow
|
||||
*/
|
||||
|
||||
Bool
|
||||
winUnmapWindowRootless(WindowPtr pWin)
|
||||
{
|
||||
Bool fResult = FALSE;
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winWindowPriv(pWin);
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winUnmapWindowRootless (%p)\n", pWin);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(UnrealizeWindow);
|
||||
fResult = (*pScreen->UnrealizeWindow) (pWin);
|
||||
WIN_WRAP(UnrealizeWindow, winUnmapWindowRootless);
|
||||
|
||||
if (pWinPriv->hRgn != NULL) {
|
||||
DeleteObject(pWinPriv->hRgn);
|
||||
pWinPriv->hRgn = NULL;
|
||||
}
|
||||
|
||||
winUpdateRgnRootless(pWin);
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
/* See Porting Layer Definition - p. 37
|
||||
* Also referred to as RealizeWindow
|
||||
*/
|
||||
|
||||
Bool
|
||||
winMapWindowRootless(WindowPtr pWin)
|
||||
{
|
||||
Bool fResult = FALSE;
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winMapWindowRootless (%p)\n", pWin);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(RealizeWindow);
|
||||
fResult = (*pScreen->RealizeWindow) (pWin);
|
||||
WIN_WRAP(RealizeWindow, winMapWindowRootless);
|
||||
|
||||
winReshapeRootless(pWin);
|
||||
|
||||
winUpdateRgnRootless(pWin);
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
void
|
||||
winSetShapeRootless(WindowPtr pWin, int kind)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
winScreenPriv(pScreen);
|
||||
|
||||
#if CYGDEBUG
|
||||
winTrace("winSetShapeRootless (%p, %i)\n", pWin, kind);
|
||||
#endif
|
||||
|
||||
WIN_UNWRAP(SetShape);
|
||||
(*pScreen->SetShape) (pWin, kind);
|
||||
WIN_WRAP(SetShape, winSetShapeRootless);
|
||||
|
||||
winReshapeRootless(pWin);
|
||||
winUpdateRgnRootless(pWin);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local function for adding a region to the Windows window region
|
||||
*/
|
||||
|
||||
static
|
||||
int
|
||||
winAddRgn(WindowPtr pWin, void *data)
|
||||
{
|
||||
int iX, iY, iWidth, iHeight, iBorder;
|
||||
HRGN hRgn = *(HRGN *) data;
|
||||
HRGN hRgnWin;
|
||||
|
||||
winWindowPriv(pWin);
|
||||
|
||||
/* If pWin is not Root */
|
||||
if (pWin->parent != NULL) {
|
||||
#if CYGDEBUG
|
||||
winDebug("winAddRgn ()\n");
|
||||
#endif
|
||||
if (pWin->mapped) {
|
||||
iBorder = wBorderWidth(pWin);
|
||||
|
||||
iX = pWin->drawable.x - iBorder;
|
||||
iY = pWin->drawable.y - iBorder;
|
||||
|
||||
iWidth = pWin->drawable.width + iBorder * 2;
|
||||
iHeight = pWin->drawable.height + iBorder * 2;
|
||||
|
||||
hRgnWin = CreateRectRgn(0, 0, iWidth, iHeight);
|
||||
|
||||
if (hRgnWin == NULL) {
|
||||
ErrorF("winAddRgn - CreateRectRgn () failed\n");
|
||||
ErrorF(" Rect %d %d %d %d\n",
|
||||
iX, iY, iX + iWidth, iY + iHeight);
|
||||
}
|
||||
|
||||
if (pWinPriv->hRgn) {
|
||||
if (CombineRgn(hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
|
||||
== ERROR) {
|
||||
ErrorF("winAddRgn - CombineRgn () failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
OffsetRgn(hRgnWin, iX, iY);
|
||||
|
||||
if (CombineRgn(hRgn, hRgn, hRgnWin, RGN_OR) == ERROR) {
|
||||
ErrorF("winAddRgn - CombineRgn () failed\n");
|
||||
}
|
||||
|
||||
DeleteObject(hRgnWin);
|
||||
}
|
||||
return WT_DONTWALKCHILDREN;
|
||||
}
|
||||
else {
|
||||
return WT_WALKCHILDREN;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local function to update the Windows window's region
|
||||
*/
|
||||
|
||||
static
|
||||
void
|
||||
winUpdateRgnRootless(WindowPtr pWin)
|
||||
{
|
||||
HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
|
||||
|
||||
if (hRgn != NULL) {
|
||||
WalkTree(pWin->drawable.pScreen, winAddRgn, &hRgn);
|
||||
SetWindowRgn(winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
|
||||
hRgn, TRUE);
|
||||
}
|
||||
else {
|
||||
ErrorF("winUpdateRgnRootless - CreateRectRgn failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
winReshapeRootless(WindowPtr pWin)
|
||||
{
|
||||
int nRects;
|
||||
RegionRec rrNewShape;
|
||||
BoxPtr pShape, pRects, pEnd;
|
||||
HRGN hRgn, hRgnRect;
|
||||
|
||||
winWindowPriv(pWin);
|
||||
|
||||
#if CYGDEBUG
|
||||
winDebug("winReshapeRootless ()\n");
|
||||
#endif
|
||||
|
||||
/* Bail if the window is the root window */
|
||||
if (pWin->parent == NULL)
|
||||
return;
|
||||
|
||||
/* Bail if the window is not top level */
|
||||
if (pWin->parent->parent != NULL)
|
||||
return;
|
||||
|
||||
/* Free any existing window region stored in the window privates */
|
||||
if (pWinPriv->hRgn != NULL) {
|
||||
DeleteObject(pWinPriv->hRgn);
|
||||
pWinPriv->hRgn = NULL;
|
||||
}
|
||||
|
||||
/* Bail if the window has no bounding region defined */
|
||||
if (!wBoundingShape(pWin))
|
||||
return;
|
||||
|
||||
RegionNull(&rrNewShape);
|
||||
RegionCopy(&rrNewShape, wBoundingShape(pWin));
|
||||
RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth);
|
||||
|
||||
nRects = RegionNumRects(&rrNewShape);
|
||||
pShape = RegionRects(&rrNewShape);
|
||||
|
||||
if (nRects > 0) {
|
||||
/* Create initial empty Windows region */
|
||||
hRgn = CreateRectRgn(0, 0, 0, 0);
|
||||
|
||||
/* Loop through all rectangles in the X region */
|
||||
for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) {
|
||||
/* Create a Windows region for the X rectangle */
|
||||
hRgnRect = CreateRectRgn(pRects->x1, pRects->y1,
|
||||
pRects->x2, pRects->y2);
|
||||
if (hRgnRect == NULL) {
|
||||
ErrorF("winReshapeRootless - CreateRectRgn() failed\n");
|
||||
}
|
||||
|
||||
/* Merge the Windows region with the accumulated region */
|
||||
if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) {
|
||||
ErrorF("winReshapeRootless - CombineRgn() failed\n");
|
||||
}
|
||||
|
||||
/* Delete the temporary Windows region */
|
||||
DeleteObject(hRgnRect);
|
||||
}
|
||||
|
||||
/* Save a handle to the composite region in the window privates */
|
||||
pWinPriv->hRgn = hRgn;
|
||||
}
|
||||
|
||||
RegionUninit(&rrNewShape);
|
||||
|
||||
return;
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*Copyright (C) Colin Harrison 2005-2009
|
||||
*
|
||||
*Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
*"Software"), to deal in the Software without restriction, including
|
||||
*without limitation the rights to use, copy, modify, merge, publish,
|
||||
*distribute, sublicense, and/or sell copies of the Software, and to
|
||||
*permit persons to whom the Software is furnished to do so, subject to
|
||||
*the following conditions:
|
||||
*
|
||||
*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 XFREE86 PROJECT 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 XFree86 Project
|
||||
*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 XFree86 Project.
|
||||
*
|
||||
* Authors: Kensuke Matsuzaki
|
||||
* Colin Harrison
|
||||
*/
|
||||
#if !defined(_WINWINDOW_H_)
|
||||
#define _WINWINDOW_H_
|
||||
|
||||
#ifndef NO
|
||||
#define NO 0
|
||||
#endif
|
||||
#ifndef YES
|
||||
#define YES 1
|
||||
#endif
|
||||
|
||||
/* Constant strings */
|
||||
#ifndef PROJECT_NAME
|
||||
#define PROJECT_NAME "Cygwin/X"
|
||||
#endif
|
||||
#define EXECUTABLE_NAME "XWin"
|
||||
#define WINDOW_CLASS "cygwin/x"
|
||||
#define WINDOW_TITLE PROJECT_NAME ":%s.%d"
|
||||
#define WINDOW_TITLE_XDMCP "%s:%s.%d"
|
||||
#define WIN_SCR_PROP "cyg_screen_prop rl"
|
||||
#define WINDOW_CLASS_X "cygwin/x X rl"
|
||||
#define WINDOW_CLASS_X_MSG "cygwin/x X msg"
|
||||
#define WINDOW_TITLE_X PROJECT_NAME " X"
|
||||
#define WIN_WINDOW_PROP "cyg_window_prop_rl"
|
||||
#ifdef HAS_DEVWINDOWS
|
||||
#define WIN_MSG_QUEUE_FNAME "/dev/windows"
|
||||
#endif
|
||||
#define WIN_WID_PROP "cyg_wid_prop_rl"
|
||||
#define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl"
|
||||
#ifndef CYGMULTIWINDOW_DEBUG
|
||||
#define CYGMULTIWINDOW_DEBUG NO
|
||||
#endif
|
||||
#ifndef CYGWINDOWING_DEBUG
|
||||
#define CYGWINDOWING_DEBUG NO
|
||||
#endif
|
||||
|
||||
#define XMING_SIGNATURE 0x12345678L
|
||||
|
||||
typedef struct _winPrivScreenRec *winPrivScreenPtr;
|
||||
|
||||
/*
|
||||
* Window privates
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
DWORD dwDummy;
|
||||
HRGN hRgn;
|
||||
HWND hWnd;
|
||||
winPrivScreenPtr pScreenPriv;
|
||||
Bool fXKilled;
|
||||
HDWP hDwp;
|
||||
#ifdef XWIN_GLX_WINDOWS
|
||||
Bool fWglUsed;
|
||||
#endif
|
||||
} winPrivWinRec, *winPrivWinPtr;
|
||||
|
||||
typedef struct _winWMMessageRec {
|
||||
DWORD dwID;
|
||||
DWORD msg;
|
||||
int iWindow;
|
||||
HWND hwndWindow;
|
||||
int iX, iY;
|
||||
int iWidth, iHeight;
|
||||
} winWMMessageRec, *winWMMessagePtr;
|
||||
|
||||
/*
|
||||
* winmultiwindowwm.c
|
||||
*/
|
||||
|
||||
#define WM_WM_MOVE (WM_USER + 1)
|
||||
#define WM_WM_SIZE (WM_USER + 2)
|
||||
#define WM_WM_RAISE (WM_USER + 3)
|
||||
#define WM_WM_LOWER (WM_USER + 4)
|
||||
#define WM_WM_UNMAP (WM_USER + 6)
|
||||
#define WM_WM_KILL (WM_USER + 7)
|
||||
#define WM_WM_ACTIVATE (WM_USER + 8)
|
||||
#define WM_WM_NAME_EVENT (WM_USER + 9)
|
||||
#define WM_WM_ICON_EVENT (WM_USER + 10)
|
||||
#define WM_WM_CHANGE_STATE (WM_USER + 11)
|
||||
#define WM_WM_MAP_UNMANAGED (WM_USER + 12)
|
||||
#define WM_WM_MAP_MANAGED (WM_USER + 13)
|
||||
#define WM_WM_HINTS_EVENT (WM_USER + 14)
|
||||
|
||||
#define MwmHintsDecorations (1L << 1)
|
||||
|
||||
#define MwmDecorAll (1L << 0)
|
||||
#define MwmDecorBorder (1L << 1)
|
||||
#define MwmDecorHandle (1L << 2)
|
||||
#define MwmDecorTitle (1L << 3)
|
||||
#define MwmDecorMenu (1L << 4)
|
||||
#define MwmDecorMinimize (1L << 5)
|
||||
#define MwmDecorMaximize (1L << 6)
|
||||
|
||||
/*
|
||||
This structure only contains 3 elements. The Motif 2.0 structure contains 5,
|
||||
but we only need the first 3, so that is all we will define
|
||||
|
||||
This structure represents xcb_get_property()'s view of the property as a
|
||||
sequence of ints, rather than XGetWindowProperty()'s view of the property as a
|
||||
sequence of arch-dependent longs.
|
||||
*/
|
||||
typedef struct MwmHints {
|
||||
unsigned int flags, functions, decorations;
|
||||
} MwmHints;
|
||||
|
||||
#define PropMwmHintsElements 3
|
||||
|
||||
void
|
||||
winSendMessageToWM(void *pWMInfo, winWMMessagePtr msg);
|
||||
|
||||
Bool
|
||||
|
||||
winInitWM(void **ppWMInfo,
|
||||
pthread_t * ptWMProc,
|
||||
pthread_t * ptXMsgProc,
|
||||
pthread_mutex_t * ppmServerStarted,
|
||||
int dwScreen, HWND hwndScreen, Bool compositeWM);
|
||||
|
||||
void
|
||||
winDeinitMultiWindowWM(void);
|
||||
|
||||
void
|
||||
winPropertyStoreInit(void);
|
||||
|
||||
void
|
||||
winPropertyStoreDestroy(void);
|
||||
|
||||
void
|
||||
winSetAppUserModelID(HWND hWnd, const char *AppID);
|
||||
|
||||
void
|
||||
winShowWindowOnTaskbar(HWND hWnd, Bool show);
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user