aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winmultiwindowwindow.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
committermarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
commita915739887477b28d924ecc8417ee107d125bd6c (patch)
treec02f315476b61892d1fd89182e18943dce8d6277 /xorg-server/hw/xwin/winmultiwindowwindow.c
parent6f25a23db1df27e992c34f6fd4c82e83c44fc2e2 (diff)
downloadvcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.gz
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.bz2
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.zip
Switched to xorg-server-1.6.99.900.tar.gz
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwindow.c')
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c163
1 files changed, 58 insertions, 105 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 75bef9786..e2b5ed291 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -1,5 +1,6 @@
/*
*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
@@ -28,6 +29,7 @@
* Authors: Kensuke Matsuzaki
* Earle F. Philhower, III
* Harold L Hunt II
+ * Colin Harrison
*/
#ifdef HAVE_XWIN_CONFIG_H
@@ -42,9 +44,9 @@
* External global variables
*/
-extern HWND g_hDlgDepthChange;
-
-extern void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+extern HWND g_hDlgDepthChange;
/*
* Prototypes for local functions
@@ -63,13 +65,6 @@ static void
winFindWindow (pointer value, XID id, pointer cdata);
/*
- * Constant defines
- */
-
-#define MOUSE_POLLING_INTERVAL 500
-
-
-/*
* Macros
*/
@@ -81,6 +76,35 @@ winFindWindow (pointer value, XID id, pointer cdata);
#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
+static
+void winInitMultiWindowClass(void)
+{
+ static wATOM atomXWinClass=0;
+ WNDCLASSEX wcx;
+
+ if (atomXWinClass==0)
+ {
+ /* Setup our window class */
+ wcx.cbSize=sizeof(WNDCLASSEX);
+ wcx.style = CS_HREDRAW | CS_VREDRAW;
+ wcx.lpfnWndProc = winTopLevelWindowProc;
+ wcx.cbClsExtra = 0;
+ wcx.cbWndExtra = 0;
+ wcx.hInstance = g_hInstance;
+ wcx.hIcon = g_hIconX;
+ wcx.hCursor = 0;
+ wcx.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wcx.lpszMenuName = NULL;
+ wcx.lpszClassName = WINDOW_CLASS_X;
+ wcx.hIconSm = g_hSmallIconX;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X);
+#endif
+
+ atomXWinClass = RegisterClassEx (&wcx);
+ }
+}
/*
* CreateWindow - See Porting Layer Definition - p. 37
@@ -275,7 +299,6 @@ winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
{
Bool fResult = TRUE;
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
@@ -368,7 +391,6 @@ void
winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
@@ -392,12 +414,13 @@ winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
void
winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
{
+#if 0
WindowPtr pPrevWin;
UINT uFlags;
HWND hInsertAfter;
HWND hWnd = NULL;
+#endif
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
@@ -484,16 +507,15 @@ winCreateWindowsWindow (WindowPtr pWin)
int iWidth;
int iHeight;
HWND hWnd;
- WNDCLASSEX wc;
+ HWND hFore = NULL;
winWindowPriv(pWin);
HICON hIcon;
HICON hIconSmall;
-#define CLASS_NAME_LENGTH 512
- char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
- char *res_name, *res_class, *res_role;
- static int s_iWindowID = 0;
winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
WinXSizeHints hints;
+ WindowPtr pDaddy;
+
+ winInitMultiWindowClass();
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winCreateWindowsWindow - pWin: %08x\n", pWin);
@@ -516,70 +538,27 @@ winCreateWindowsWindow (WindowPtr pWin)
iWidth = pWin->drawable.width;
iHeight = pWin->drawable.height;
- winSelectIcons(pWin, &hIcon, &hIconSmall);
-
- /* Set standard class name prefix so we can identify window easily */
- strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
-
- if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ if (winMultiWindowGetTransientFor (pWin, &pDaddy))
{
- strncat (pszClass, "-", 1);
- strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
- strncat (pszClass, "-", 1);
- strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
-
- /* Check if a window class is provided by the WM_WINDOW_ROLE property,
- * if not use the WM_CLASS information.
- * For further information see:
- * http://tronche.com/gui/x/icccm/sec-5.html
- */
- if (winMultiWindowGetWindowRole (pWin, &res_role) )
- {
- strcat (pszClass, "-");
- strcat (pszClass, res_role);
- free (res_role);
- }
-
- free (res_name);
- free (res_class);
+ if (pDaddy)
+ {
+ hFore = GetForegroundWindow();
+ if (hFore && (pDaddy != (WindowPtr)GetProp(hFore, WIN_WID_PROP))) hFore = NULL;
+ }
}
- /* Add incrementing window ID to make unique class name */
- snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
- pszWindowID[sizeof(pszWindowID)-1] = 0;
- strcat (pszClass, pszWindowID);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
-#endif
-
- /* Setup our window class */
- wc.cbSize = sizeof(wc);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = winTopLevelWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = g_hInstance;
- wc.hIcon = hIcon;
- wc.hIconSm = hIconSmall;
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = pszClass;
- RegisterClassEx (&wc);
-
/* Create the window */
/* Make it OVERLAPPED in create call since WS_POPUP doesn't support */
/* CW_USEDEFAULT, change back to popup after creation */
hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
- pszClass, /* Class name */
+ WINDOW_CLASS_X, /* Class name */
WINDOW_TITLE_X, /* Window name */
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
iX, /* Horizontal position */
iY, /* Vertical position */
iWidth, /* Right edge */
iHeight, /* Bottom edge */
- (HWND) NULL, /* No parent or owner window */
+ hFore, /* Null or Parent window if transient*/
(HMENU) NULL, /* No menu */
GetModuleHandle (NULL), /* Instance handle */
pWin); /* ScreenPrivates */
@@ -588,23 +567,27 @@ winCreateWindowsWindow (WindowPtr pWin)
ErrorF ("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
(int) GetLastError ());
}
+ pWinPriv->hWnd = hWnd;
+
+ /* Set application or .XWinrc defined Icons */
+ winSelectIcons(pWin, &hIcon, &hIconSmall);
+ if (hIcon) SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ if (hIconSmall) SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
/* Change style back to popup, already placed... */
- SetWindowLong (hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
SetWindowPos (hWnd, 0, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
/* Make sure it gets the proper system menu for a WS_POPUP, too */
GetSystemMenu (hWnd, TRUE);
- pWinPriv->hWnd = hWnd;
-
/* Cause any .XWinrc menus to be added in main WNDPROC */
PostMessage (hWnd, WM_INIT_SYS_MENU, 0, 0);
- SetProp (pWinPriv->hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
+ SetProp (hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
/* Flag that this Windows window handles its own activation */
- SetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
+ SetProp (hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
/* Call engine-specific create window procedure */
(*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
@@ -621,11 +604,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
{
MSG msg;
winWindowPriv(pWin);
- HICON hiconClass;
- HICON hiconSmClass;
- HMODULE hInstance;
- int iReturn;
- char pszClass[512];
BOOL oldstate = winInDestroyWindowsWindow;
#if CYGMULTIWINDOW_DEBUG
@@ -638,12 +616,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
winInDestroyWindowsWindow = TRUE;
- /* Store the info we need to destroy after this window is gone */
- hInstance = (HINSTANCE) GetClassLong (pWinPriv->hWnd, GCL_HMODULE);
- hiconClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICON);
- hiconSmClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICONSM);
- iReturn = GetClassName (pWinPriv->hWnd, pszClass, 512);
-
SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL);
/* Destroy the Windows window */
DestroyWindow (pWinPriv->hWnd);
@@ -660,22 +632,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
}
}
- /* Only if we were able to get the name */
- if (iReturn)
- {
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winDestroyWindowsWindow - Unregistering %s: ", pszClass);
-#endif
- iReturn = UnregisterClass (pszClass, hInstance);
-
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winDestroyWindowsWindow - %d Deleting Icon: ", iReturn);
-#endif
-
- winDestroyIcon(hiconClass);
- winDestroyIcon(hiconSmClass);
- }
-
winInDestroyWindowsWindow = oldstate;
#if CYGMULTIWINDOW_DEBUG
@@ -854,7 +810,7 @@ winMinimizeWindow (Window id)
ErrorF ("winMinimizeWindow\n");
#endif
- pWin = LookupIDByType (id, RT_WINDOW);
+ pWin = (WindowPtr) LookupIDByType (id, RT_WINDOW);
if (!pWin)
{
ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__);
@@ -892,7 +848,6 @@ winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
RegionPtr oldRegion)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGWINDOWING_DEBUG
@@ -912,7 +867,6 @@ winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
WindowPtr pSib, VTKind kind)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGWINDOWING_DEBUG
@@ -933,7 +887,6 @@ winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
unsigned int h, WindowPtr pSib)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGWINDOWING_DEBUG