aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winmultiwindowwindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwindow.c')
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c176
1 files changed, 57 insertions, 119 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 88e7700dc..e2b5ed291 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -44,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
@@ -76,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
@@ -270,7 +299,6 @@ winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
{
Bool fResult = TRUE;
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
@@ -363,7 +391,6 @@ void
winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
@@ -387,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
@@ -480,18 +508,15 @@ winCreateWindowsWindow (WindowPtr pWin)
int iHeight;
HWND hWnd;
HWND hFore = NULL;
- WNDCLASSEX wc;
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);
#endif
@@ -499,70 +524,20 @@ winCreateWindowsWindow (WindowPtr pWin)
iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* ensure window actually ends up somewhere visible */
- if (iX > GetSystemMetrics (SM_CXVIRTUALSCREEN))
- iX = CW_USEDEFAULT;
-
- if (iY > GetSystemMetrics (SM_CYVIRTUALSCREEN))
- iY = CW_USEDEFAULT;
-
- 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))
+ /* Default positions if none specified */
+ if (!winMultiWindowGetWMNormalHints(pWin, &hints))
+ hints.flags = 0;
+ if ( !(hints.flags & (USPosition|PPosition)) &&
+ !winMultiWindowGetTransientFor (pWin, NULL) &&
+ !pWin->overrideRedirect )
{
- 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);
+ iX = CW_USEDEFAULT;
+ iY = CW_USEDEFAULT;
}
- /* 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
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
- /* 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);
-
- if (!pWin->overrideRedirect)
- {
if (winMultiWindowGetTransientFor (pWin, &pDaddy))
{
if (pDaddy)
@@ -571,23 +546,12 @@ winCreateWindowsWindow (WindowPtr pWin)
if (hFore && (pDaddy != (WindowPtr)GetProp(hFore, WIN_WID_PROP))) hFore = NULL;
}
}
- else
- {
- /* Default positions if none specified */
- if (!winMultiWindowGetWMNormalHints(pWin, &hints)) hints.flags = 0;
- if (!(hints.flags & (USPosition|PPosition)))
- {
- iX = CW_USEDEFAULT;
- iY = CW_USEDEFAULT;
- }
- }
- }
/* 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 */
@@ -603,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);
@@ -636,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
@@ -653,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);
@@ -675,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
@@ -869,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__);
@@ -907,7 +848,6 @@ winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
RegionPtr oldRegion)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
winScreenPriv(pScreen);
#if CYGWINDOWING_DEBUG
@@ -927,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
@@ -948,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