void winMWExtWMUpdateIcon(Window id) { WindowPtr pWin; HICON hIcon, hiconOld; dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess); hIcon = winOverrideIcon((unsigned long) pWin); if (!hIcon) hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON)); if (hIcon) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); if (pRLWinPriv->hWnd) { hiconOld = (HICON) SendMessage(pRLWinPriv->hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon); winDestroyIcon(hiconOld); } hIcon = NULL; } }
/* Return NULL if an error occurs. */ static DRIDrawablePrivPtr CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) { DRIDrawablePrivPtr pDRIDrawablePriv; xp_window_id wid = 0; *widPtr = 0; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv == NULL) { xp_error err; xp_window_changes wc; /* allocate a DRI Window Private record */ if (!(pDRIDrawablePriv = xalloc(sizeof(*pDRIDrawablePriv)))) { return NULL; } pDRIDrawablePriv->pDraw = (DrawablePtr)pWin; pDRIDrawablePriv->pScreen = pScreen; pDRIDrawablePriv->refCount = 0; pDRIDrawablePriv->drawableIndex = -1; pDRIDrawablePriv->notifiers = NULL; /* find the physical window */ wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE)); if (wid == 0) { xfree(pDRIDrawablePriv); return NULL; } /* allocate the physical surface */ err = xp_create_surface(wid, &pDRIDrawablePriv->sid); if (err != Success) { xfree(pDRIDrawablePriv); return NULL; } /* Make it visible */ wc.stack_mode = XP_MAPPED_ABOVE; wc.sibling = 0; err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); xfree(pDRIDrawablePriv); return NULL; } /* save private off of preallocated index */ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, pDRIDrawablePriv); } *widPtr = wid; return pDRIDrawablePriv; }
void winMWExtWMUpdateIcon (Window id) { WindowPtr pWin; HICON hIcon, hiconOld; pWin = LookupIDByType (id, RT_WINDOW); hIcon = (HICON)winOverrideIcon ((unsigned long)pWin); if (!hIcon) hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON)); if (hIcon) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); if (pRLWinPriv->hWnd) { hiconOld = (HICON) SetClassLong (pRLWinPriv->hWnd, GCL_HICON, (int) hIcon); winDestroyIcon(hiconOld); } } }
static int ProcWindowsWMFrameSetTitle(ClientPtr client) { unsigned int title_length, title_max; char *title_bytes; REQUEST(xWindowsWMFrameSetTitleReq); WindowPtr pWin; win32RootlessWindowPtr pRLWinPriv; int rc; #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameSetTitle\n"); #endif REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); if (rc != Success) return rc; #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameSetTitle - Window found\n"); #endif title_length = stuff->title_length; title_max = (stuff->length << 2) - sizeof(xWindowsWMFrameSetTitleReq); if (title_max < title_length) return BadValue; #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameSetTitle - length is valid\n"); #endif title_bytes = malloc(title_length + 1); strncpy(title_bytes, (char *) &stuff[1], title_length); title_bytes[title_length] = '\0'; pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); if (pRLWinPriv == 0) { free(title_bytes); return BadWindow; } /* Flush the window style */ SetWindowText(pRLWinPriv->hWnd, title_bytes); free(title_bytes); #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameSetTitle - done\n"); #endif return Success; }
void winMinimizeWindow (Window id) { WindowPtr pWin; winPrivWinPtr pWinPriv; #ifdef XWIN_MULTIWINDOWEXTWM win32RootlessWindowPtr pRLWinPriv; #endif HWND hWnd; ScreenPtr pScreen = NULL; winPrivScreenPtr pScreenPriv = NULL; winScreenInfo *pScreenInfo = NULL; #if CYGWINDOWING_DEBUG ErrorF ("winMinimizeWindow\n"); #endif pWin = LookupIDByType (id, RT_WINDOW); if (!pWin) { ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__); return; } pScreen = pWin->drawable.pScreen; if (pScreen) pScreenPriv = winGetScreenPriv(pScreen); if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo; #ifdef XWIN_MULTIWINDOWEXTWM if (pScreenPriv && pScreenInfo->fInternalWM) { pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); hWnd = pRLWinPriv->hWnd; } else #else if (pScreenPriv) #endif { pWinPriv = winGetWindowPriv (pWin); hWnd = pWinPriv->hWnd; } ShowWindow (hWnd, SW_MINIMIZE); }
void winMWExtWMRestackWindows(ScreenPtr pScreen) { winScreenPriv(pScreen); WindowPtr pRoot = pScreen->root; WindowPtr pWin = NULL; WindowPtr pWinPrev = NULL; win32RootlessWindowPtr pRLWin = NULL; win32RootlessWindowPtr pRLWinPrev = NULL; int nWindow = 0; HDWP hWinPosInfo = NULL; #if CYGMULTIWINDOW_DEBUG winDebug("winMWExtWMRestackWindows\n"); #endif pScreenPriv->fRestacking = TRUE; if (pRoot != NULL) { for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) nWindow++; hWinPosInfo = BeginDeferWindowPos(nWindow); for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) { if (pWin->realized) { UINT uFlags; pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); if (pRLWin == NULL) continue; if (pWinPrev) pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow(pWinPrev, FALSE); uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW; if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE; #if CYGMULTIWINDOW_DEBUG winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n", pRLWin->hWnd, pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP); #endif hWinPosInfo = DeferWindowPos(hWinPosInfo, pRLWin->hWnd, pRLWinPrev ? pRLWinPrev-> hWnd : HWND_TOP, 0, 0, 0, 0, uFlags); if (hWinPosInfo == NULL) { ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n", (int) GetLastError()); return; } pWinPrev = pWin; } } if (!EndDeferWindowPos(hWinPosInfo)) { ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n", (int) GetLastError()); return; } } #if CYGMULTIWINDOW_DEBUG winDebug("winMWExtWMRestackWindows - done\n"); #endif pScreenPriv->fRestacking = FALSE; }
Bool DRICreateSurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, xp_client_id client_id, xp_surface_id *surface_id, unsigned int ret_key[2], void (*notify) (void *arg, void *data), void *notify_data) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; xp_window_id wid = 0; if (pDrawable->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr)pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv == NULL) { xp_error err; xp_window_changes wc; /* allocate a DRI Window Private record */ if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) { return FALSE; } pDRIDrawablePriv->pDraw = pDrawable; pDRIDrawablePriv->pScreen = pScreen; pDRIDrawablePriv->refCount = 0; pDRIDrawablePriv->drawableIndex = -1; pDRIDrawablePriv->notifiers = NULL; /* find the physical window */ wid = (xp_window_id) RootlessFrameForWindow(pWin, TRUE); if (wid == 0) { xfree(pDRIDrawablePriv); return FALSE; } /* allocate the physical surface */ err = xp_create_surface(wid, &pDRIDrawablePriv->sid); if (err != Success) { xfree(pDRIDrawablePriv); return FALSE; } /* Make it visible */ wc.stack_mode = XP_MAPPED_ABOVE; wc.sibling = 0; err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); xfree(pDRIDrawablePriv); return FALSE; } /* save private off of preallocated index */ pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv; } } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 else if (pDrawable->type == DRAWABLE_PIXMAP) { PixmapPtr pPix = (PixmapPtr)pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix); if (pDRIDrawablePriv == NULL) { xp_error err; /* allocate a DRI Window Private record */ if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) { return FALSE; } pDRIDrawablePriv->pDraw = pDrawable; pDRIDrawablePriv->pScreen = pScreen; pDRIDrawablePriv->refCount = 0; pDRIDrawablePriv->drawableIndex = -1; pDRIDrawablePriv->notifiers = NULL; /* Passing a null window id to Xplugin in 10.3+ asks for an accelerated offscreen surface. */ err = xp_create_surface(0, &pDRIDrawablePriv->sid); if (err != Success) { xfree(pDRIDrawablePriv); return FALSE; } /* save private off of preallocated index */ pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv; } } #endif else { /* for GLX 1.3, a PBuffer */ /* NOT_DONE */ return FALSE; } /* Finish initialization of new surfaces */ if (pDRIDrawablePriv->refCount == 0) { unsigned int key[2] = {0}; xp_error err; /* try to give the client access to the surface */ if (client_id != 0 && wid != 0) { err = xp_export_surface(wid, pDRIDrawablePriv->sid, client_id, key); if (err != Success) { xp_destroy_surface(pDRIDrawablePriv->sid); xfree(pDRIDrawablePriv); return FALSE; } } pDRIDrawablePriv->key[0] = key[0]; pDRIDrawablePriv->key[1] = key[1]; ++pDRIPriv->nrWindows; /* and stash it by surface id */ if (surface_hash == NULL) surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); x_hash_table_insert(surface_hash, (void *) pDRIDrawablePriv->sid, pDRIDrawablePriv); /* track this in case this window is destroyed */ AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); /* Initialize shape */ DRIUpdateSurface(pDRIDrawablePriv, pDrawable); } pDRIDrawablePriv->refCount++; *surface_id = pDRIDrawablePriv->sid; if (ret_key != NULL) { ret_key[0] = pDRIDrawablePriv->key[0]; ret_key[1] = pDRIDrawablePriv->key[1]; } if (notify != NULL) { pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers, notify, notify_data); } return TRUE; }
static int ProcWindowsWMFrameDraw(ClientPtr client) { REQUEST(xWindowsWMFrameDrawReq); WindowPtr pWin; win32RootlessWindowPtr pRLWinPriv; RECT rcNew; int nCmdShow, rc; RegionRec newShape; REQUEST_SIZE_MATCH(xWindowsWMFrameDrawReq); #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameDraw\n"); #endif rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); if (rc != Success) return rc; #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameDraw - Window found\n"); #endif pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, TRUE); if (pRLWinPriv == 0) return BadWindow; #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameDraw - HWND %p 0x%08x 0x%08x\n", pRLWinPriv->hWnd, (int) stuff->frame_style, (int) stuff->frame_style_ex); ErrorF("ProcWindowsWMFrameDraw - %d %d %d %d\n", stuff->ix, stuff->iy, stuff->iw, stuff->ih); #endif /* Store the origin, height, and width in a rectangle structure */ SetRect(&rcNew, stuff->ix, stuff->iy, stuff->ix + stuff->iw, stuff->iy + stuff->ih); /* * Calculate the required size of the Windows window rectangle, * given the size of the Windows window client area. */ AdjustWindowRectEx(&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex); /* Set the window extended style flags */ if (!SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex)) { return BadValue; } /* Set the window standard style flags */ if (!SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style)) { return BadValue; } /* Flush the window style */ if (!SetWindowPos(pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE)) { return BadValue; } if (!IsWindowVisible(pRLWinPriv->hWnd)) nCmdShow = SW_HIDE; else nCmdShow = SW_SHOWNA; ShowWindow(pRLWinPriv->hWnd, nCmdShow); if (wBoundingShape(pWin) != NULL) { /* wBoundingShape is relative to *inner* origin of window. Translate by borderWidth to get the outside-relative position. */ RegionNull(&newShape); RegionCopy(&newShape, wBoundingShape(pWin)); RegionTranslate(&newShape, pWin->borderWidth, pWin->borderWidth); winMWExtWMReshapeFrame(pRLWinPriv, &newShape); RegionUninit(&newShape); } #if CYGMULTIWINDOW_DEBUG ErrorF("ProcWindowsWMFrameDraw - done\n"); #endif return Success; }
/** * 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; #ifdef XWIN_MULTIWINDOW /* 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; } #endif #ifdef XWIN_MULTIWINDOWEXTWM /* check for multiwindow external wm mode */ if (pScreenInfo->fMWExtWM) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); if (pRLWinPriv == NULL) { ErrorF("winGetWindowInfo: window has no privates\n"); return hwnd; } if (pRLWinPriv->hWnd != NULL) { /* copy window handle */ hwnd = pRLWinPriv->hWnd; } return hwnd; } #endif } 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; }