예제 #1
0
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;

        winDebug("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 {
            winDebug ("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;
}
예제 #2
0
static
    int
winAddRgn(WindowPtr pWin, pointer data)
{
    int iX, iY, iWidth, iHeight, iBorder;
    HRGN hRgn = *(HRGN *) data;
    HRGN hRgnWin;

    winWindowPriv(pWin);

    /* If pWin is not Root */
    if (pWin->parent != NULL) {
        winDebug("winAddRgn ()\n");
        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) {
                 winDebug ("winAddRgn - CreateRectRgn () failed\n");
                 winDebug ("  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;
    }
}
예제 #3
0
파일: winshaddd.c 프로젝트: L3oV1nc3/VMGL
static Bool
winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  HRESULT		ddrval = DD_OK;
  DDSURFACEDESC		ddsd;

  /* Describe the primary surface */
  ZeroMemory (&ddsd, sizeof (ddsd));
  ddsd.dwSize = sizeof (ddsd);
  ddsd.dwFlags = DDSD_CAPS;
  ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
  
  /* Create the primary surface */
  ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
				       &ddsd,
				       &pScreenPriv->pddsPrimary,
				       NULL);
  if (FAILED (ddrval))
    {
      ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
	      "surface: %08x\n", (unsigned int) ddrval);
      return FALSE;
    }
  
#if CYGDEBUG
  winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
#endif

  /*
   * Attach a clipper to the primary surface that will clip our blits to our
   * display window.
   */
  ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
					   pScreenPriv->pddcPrimary);
  if (FAILED (ddrval))
    {
      ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
	      "failed: %08x\n",
	      (unsigned int) ddrval);
      return FALSE;
    }

#if CYGDEBUG
  winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
	  "primary surface\n");
#endif

  /* Everything was correct */
  return TRUE;
}
예제 #4
0
파일: winengine.c 프로젝트: theqvd/vcxsrv
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 */
            winDebug (
                          "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 */
            winDebug (
                      "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);
    }

    winDebug (
                  "winDetectSupportedEngines - Returning, supported engines %08x\n",
                  (unsigned int) g_dwEnginesSupported);
}
예제 #5
0
파일: winauth.c 프로젝트: cubanismo/xserver
Bool
winGenerateAuthorization(void)
{
    Bool fFreeAuth = FALSE;
    SecurityAuthorizationPtr pAuth = NULL;

    /* 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");
        goto auth_bailout;
    }

    else {
        winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
                 "AuthDataLen: %d AuthData: %s\n",
                 g_uiAuthDataLen, g_pAuthData);
    }

#ifdef XCSECURITY
    /* Allocate structure for additional auth information */
    pAuth = (SecurityAuthorizationPtr)
        malloc(sizeof(SecurityAuthorizationRec));
    if (!(pAuth)) {
        ErrorF("winGenerateAuthorization - Failed allocating "
               "SecurityAuthorizationPtr.\n");
        goto auth_bailout;
    }

    /* 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");
        fFreeAuth = TRUE;
        goto auth_bailout;
    }

    /* Don't free the auth data, since it is still used internally */
    pAuth = NULL;
#endif

    return TRUE;

 auth_bailout:
    if (fFreeAuth)
        free(pAuth);

    return FALSE;
}
예제 #6
0
Bool
winAllocatePrivates(ScreenPtr pScreen)
{
    winPrivScreenPtr pScreenPriv;

#if CYGDEBUG
    winDebug("winAllocateScreenPrivates - g_ulServerGeneration: %d "
             "serverGeneration: %d\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 = (winPrivScreenPtr) malloc(sizeof(winPrivScreenRec));
    if (!pScreenPriv) {
        ErrorF("winAllocateScreenPrivates - malloc () failed\n");
        return FALSE;
    }

    /* Initialize the memory of the private structure */
    ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec));

    /* Intialize 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 GC memory for our privates */
    if (!dixRegisterPrivateKey
        (g_iGCPrivateKey, PRIVATE_GC, sizeof(winPrivGCRec))) {
        ErrorF("winAllocatePrivates - AllocateGCPrivate () failed\n");
        return FALSE;
    }

    /* 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;
}
예제 #7
0
void
winSetAppUserModelID(HWND hWnd, const char *AppID)
{
    PROPVARIANT pv;
    IPropertyStore *pps = NULL;
    HRESULT hr;

    if (g_pSHGetPropertyStoreForWindow == NULL) {
        return;
    }

    winDebug("winSetAppUserMOdelID - hwnd 0x%08x 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);
    }
}
예제 #8
0
static Bool
winCloseScreenShadowGDI(ScreenPtr pScreen)
{
    winScreenPriv(pScreen);
    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
    Bool fReturn;

#if CYGDEBUG
    winDebug("winCloseScreenShadowGDI - Freeing screen resources\n");
#endif

    /* Flag that the screen is closed */
    pScreenPriv->fClosed = TRUE;
    pScreenPriv->fActive = FALSE;

    /* Call the wrapped CloseScreen procedure */
    WIN_UNWRAP(CloseScreen);
    if (pScreen->CloseScreen)
        fReturn = (*pScreen->CloseScreen) (pScreen);

    /* Delete the window property */
    RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);

    /* Free the shadow DC; which allows the bitmap to be freed */
    DeleteDC(pScreenPriv->hdcShadow);

    winFreeFBShadowGDI(pScreen);

    /* Free the screen DC */
    ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);

    /* Delete tray icon, if we have one */
    if (!pScreenInfo->fNoTrayIcon)
        winDeleteNotifyIcon(pScreenPriv);

    /* Free the exit confirmation dialog box, if it exists */
    if (g_hDlgExit != NULL) {
        DestroyWindow(g_hDlgExit);
        g_hDlgExit = NULL;
    }

    /* Kill our window */
    if (pScreenPriv->hwndScreen) {
        DestroyWindow(pScreenPriv->hwndScreen);
        pScreenPriv->hwndScreen = NULL;
    }

#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    /* Destroy the thread startup mutex */
    pthread_mutex_destroy(&pScreenPriv->pmServerStarted);
#endif

    /* Invalidate our screeninfo's pointer to the screen */
    pScreenInfo->pScreen = NULL;

    /* Free the screen privates for this screen */
    free((void *) pScreenPriv);

    return fReturn;
}
예제 #9
0
/* See Porting Layer Definition - p. 17 */
void
InitInput(int argc, char *argv[])
{
#if CYGDEBUG
    winDebug("InitInput\n");
#endif

#ifdef XWIN_CLIPBOARD
    /*
     * Wrap some functions at every generation of the server.
     */
    if (InitialVector[2] != winProcEstablishConnection) {
        winProcEstablishConnectionOrig = InitialVector[2];
        InitialVector[2] = winProcEstablishConnection;
    }
#endif

    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
}
예제 #10
0
파일: InitOutput.c 프로젝트: csulmone/X11
/* See Porting Layer Definition - p. 57 */
void
AbortDDX(enum ExitCode error)
{
#if CYGDEBUG
    winDebug("AbortDDX\n");
#endif
    ddxGiveUp(error);
}
예제 #11
0
파일: InitOutput.c 프로젝트: Agnarr/xserver
/* See Porting Layer Definition - p. 57 */
void
AbortDDX (void)
{
#if CYGDEBUG
  winDebug ("AbortDDX\n");
#endif
  ddxGiveUp ();
}
예제 #12
0
/* See mfb/mfbfont.c - mfbUnrealizeFont() - which is empty :) */
Bool
winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont)
{
#if CYGDEBUG
  winDebug ("winUnrealizeFont()\n");
#endif
  return TRUE;
}
예제 #13
0
파일: InitOutput.c 프로젝트: csulmone/X11
void
ddxBeforeReset(void)
{
    winDebug("ddxBeforeReset - Hello\n");

#ifdef XWIN_CLIPBOARD
    winClipboardShutdown();
#endif
}
예제 #14
0
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 = (winPrivCmapPtr) 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;
}
예제 #15
0
/* See Porting Layer Definition - p. 57 */
void
ddxGiveUp (enum ExitCode error)
{
  int		i;

#if CYGDEBUG
  winDebug ("ddxGiveUp\n");
#endif

  /* Perform per-screen deinitialization */
  for (i = 0; i < g_iNumScreens; ++i)
    {
      /* Delete the tray icon */
      if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
 	winDeleteNotifyIcon (winGetScreenPriv (g_ScreenInfo[i].pScreen));
    }

#ifdef XWIN_MULTIWINDOW
  /* Notify the worker threads we're exiting */
  winDeinitMultiWindowWM ();
#endif

#ifdef HAS_DEVWINDOWS
  /* Close our handle to our message queue */
  if (g_fdMessageQueue != WIN_FD_INVALID)
    {
      /* Close /dev/windows */
      close (g_fdMessageQueue);

      /* Set the file handle to invalid */
      g_fdMessageQueue = WIN_FD_INVALID;
    }
#endif

  if (!g_fLogInited) {
    g_pszLogFile = LogInit (g_pszLogFile, NULL);
    g_fLogInited = TRUE;
  }  
  LogClose (error);

  /*
   * At this point we aren't creating any new screens, so
   * we are guaranteed to not need the DirectDraw functions.
   */
  winReleaseDDProcAddresses();
  
  /* Free concatenated command line */
  free(g_pszCommandLine);
  g_pszCommandLine = NULL;

  /* Remove our keyboard hook if it is installed */
  winRemoveKeyboardHookLL ();

  /* Tell Windows that we want to end the app */
  PostQuitMessage (0);
}
예제 #16
0
파일: winshadgdi.c 프로젝트: Agnarr/xserver
static Bool
winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winPrivCmapPtr	pCmapPriv = NULL;

#if CYGDEBUG
  winDebug ("winRealizeInstalledPaletteShadowGDI\n");
#endif

  /* Don't do anything if there is not a colormap */
  if (pScreenPriv->pcmapInstalled == NULL)
    {
#if CYGDEBUG
      winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
	      "installed\n");
#endif
      return TRUE;
    }

  pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
  
  /* Realize our palette for the screen */
  if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
    {
      ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
	      "failed\n");
      return FALSE;
    }
  
  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			0,
			WIN_NUM_PALETTE_ENTRIES,
			pCmapPriv->rgbColors) == 0)
    {
      ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
	      "failed\n");
      return FALSE;
    }
  
  return TRUE;
}
예제 #17
0
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);
}
예제 #18
0
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", wParam, 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;
}
예제 #19
0
/* See Porting Layer Definition - p. 6 */
void
winBlockHandler(ScreenPtr pScreen,
                pointer pTimeout, pointer pReadMask)
{
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    winScreenPriv(pScreen);
#endif
    MSG msg;

#ifndef HAS_DEVWINDOWS
    struct timeval **tvp = pTimeout;

    if (*tvp != NULL) {
        (*tvp)->tv_sec = 0;
        (*tvp)->tv_usec = 100;
    }
#endif

#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    /* Signal threaded modules to begin */
    if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) {
        int iReturn;

        ErrorF("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);
            goto winBlockHandler_ProcessMessages;
        }

        winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
    }

winBlockHandler_ProcessMessages:
#endif

    /* Process all messages on our queue */
    while (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);
        }
    }
}
예제 #20
0
static
    Bool
winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
{
    winScreenPriv(pScreen);
    HBITMAP hbmp;

#if CYGDEBUG
    LPDWORD pdw = NULL;
#endif

    /* Create a memory bitmap compatible with the screen */
    hbmp = CreateCompatibleBitmap(pScreenPriv->hdcScreen, 1, 1);
    if (hbmp == NULL) {
        ErrorF("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
        return FALSE;
    }

    /* Initialize our bitmap info header */
    ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
    pbmih->biSize = sizeof(BITMAPINFOHEADER);

    /* Get the biBitCount */
    if (!GetDIBits(pScreenPriv->hdcScreen,
                   hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) {
        ErrorF("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
        DeleteObject(hbmp);
        return FALSE;
    }

#if CYGDEBUG
    /* Get a pointer to bitfields */
    pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));

    winDebug("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
             pdw[0], pdw[1], pdw[2]);
#endif

    /* Get optimal color table, or the optimal bitfields */
    if (!GetDIBits(pScreenPriv->hdcScreen,
                   hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) {
        ErrorF("winQueryScreenDIBFormat - Second call to GetDIBits "
               "failed\n");
        DeleteObject(hbmp);
        return FALSE;
    }

    /* Free memory */
    DeleteObject(hbmp);

    return TRUE;
}
예제 #21
0
void
OsVendorInit (void)
{
  /* Re-initialize global variables on server reset */
  winInitializeGlobals ();

  winFixupPaths();

#ifdef DDXOSVERRORF
  if (!OsVendorVErrorFProc)
    OsVendorVErrorFProc = OsVendorVErrorF;
#endif

  if (!g_fLogInited) {
    /* keep this order. If LogInit fails it calls Abort which then calls
     * ddxGiveUp where LogInit is called again and creates an infinite 
     * recursion. If we set g_fLogInited to TRUE before the init we 
     * avoid the second call 
     */  
    g_fLogInited = TRUE;
    g_pszLogFile = LogInit (g_pszLogFile, NULL);
  } 
  LogSetParameter (XLOG_FLUSH, 1);
  LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
  LogSetParameter (XLOG_FILE_VERBOSITY, g_iLogVerbose);

  /* Log the version information */
  if (serverGeneration == 1)
    winLogVersionInfo ();

  winCheckMount();  

  /* Add a default screen if no screens were specified */
  if (g_iNumScreens == 0)
    {
      winDebug ("OsVendorInit - Creating default screen 0\n");

      /*
       * We need to initialize the default screen 0 if no -screen
       * arguments were processed.
       *
       * Add a screen 0 using the defaults set by winInitializeDefaultScreens()
       * and any additional default screen parameters given
       */
      winInitializeScreens(1);

      /* We have to flag this as an explicit screen, even though it isn't */
      g_ScreenInfo[0].fExplicitScreen = TRUE;
    }
}
예제 #22
0
파일: winshaddd.c 프로젝트: L3oV1nc3/VMGL
static Bool
winDestroyColormapShadowDD (ColormapPtr pColormap)
{
  winScreenPriv(pColormap->pScreen);
  winCmapPriv(pColormap);
  HRESULT		ddrval = DD_OK;

  /*
   * Is colormap to be destroyed the default?
   *
   * Non-default colormaps should have had winUninstallColormap
   * called on them before we get here.  The default colormap
   * will not have had winUninstallColormap called on it.  Thus,
   * we need to handle the default colormap in a special way.
   */
  if (pColormap->flags & IsDefault)
    {
#if CYGDEBUG
      winDebug ("winDestroyColormapShadowDD - Destroying default "
	      "colormap\n");
#endif
      
      /*
       * FIXME: Walk the list of all screens, popping the default
       * palette out of each screen device context.
       */
      
      /* Pop the palette out of the primary surface */
      ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
					       NULL);
      if (FAILED (ddrval))
	{
	  ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
		  "default colormap DirectDraw palette.\n");
	  return FALSE;
	}

      /* Clear our private installed colormap pointer */
      pScreenPriv->pcmapInstalled = NULL;
    }
  
  /* Release the palette */
  IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
 
  /* Invalidate the colormap privates */
  pCmapPriv->lpDDPalette = NULL;

  return TRUE;
}
예제 #23
0
static Bool
IsMouseActive (WindowPtr pWin)
{

  struct _Window	*pwin;
  struct _Property	*prop;
  /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
   * Which pointer's current window do we want? */
  WindowPtr		pRoot = GetCurrentRootWindow (inputInfo.pointer);

  if (!pWin)
    {
      ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
	      MOUSE_ACTIVATE_DEFAULT);
      return MOUSE_ACTIVATE_DEFAULT;
    } 

  pwin = (struct _Window*) pWin;

  if (pwin->optional)
    prop = (struct _Property *) pwin->optional->userProps;
  else
    prop = NULL;

  while (prop)
    {
      if (prop->propertyName == AtmWindowsWMMouseActivate ()
	  && prop->type == XA_INTEGER
	  && prop->format == 32)
	{
	  return *(int*)prop->data;
	}
      else
	prop = prop->next;
    }

  if (pWin != pRoot)
    {
      return IsMouseActive (pRoot);
    }
  else
    {
#if CYGMULTIWINDOW_DEBUG
      winDebug ("IsMouseActive - no prop use default value:%d\n",
		MOUSE_ACTIVATE_DEFAULT);
#endif
      return MOUSE_ACTIVATE_DEFAULT;
    }
}
예제 #24
0
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);

  winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
           iEventType, iButton);
}
예제 #25
0
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;

        winDebug (
                      "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
#ifdef XWIN_MULTIWINDOW
        || pScreenPriv->pScreenInfo->fMultiWindow
#endif
        ) {
        /* 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);
}
예제 #26
0
static HWND
winCreateMsgWindow(void)
{
    HWND hwndMsg;
    wATOM winClass;

    // 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;
        winClass = 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%x\n", hwndMsg);

    return hwndMsg;
}
예제 #27
0
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;
}
예제 #28
0
Bool
winDestroyWindowNativeGDI(WindowPtr pWin)
{
    Bool fResult = TRUE;
    ScreenPtr pScreen = pWin->drawable.pScreen;

    winScreenPriv(pScreen);

    winDebug ("winDestroyWindowNativeGDI (%p)\n", pWin);

    WIN_UNWRAP(DestroyWindow);
    fResult = (*pScreen->DestroyWindow) (pWin);
    WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI);

    return fResult;
}
예제 #29
0
Bool
winPositionWindowNativeGDI(WindowPtr pWin, int x, int y)
{
    Bool fResult = TRUE;
    ScreenPtr pScreen = pWin->drawable.pScreen;

    winScreenPriv(pScreen);

    winDebug ("winPositionWindowNativeGDI (%p)\n", pWin);

    WIN_UNWRAP(PositionWindow);
    fResult = (*pScreen->PositionWindow) (pWin, x, y);
    WIN_WRAP(PositionWindow, winPositionWindowNativeGDI);

    return fResult;
}
예제 #30
0
파일: winshadgdi.c 프로젝트: Agnarr/xserver
static Bool
winDestroyColormapShadowGDI (ColormapPtr pColormap)
{
  winScreenPriv(pColormap->pScreen);
  winCmapPriv(pColormap);

  /*
   * Is colormap to be destroyed the default?
   *
   * Non-default colormaps should have had winUninstallColormap
   * called on them before we get here.  The default colormap
   * will not have had winUninstallColormap called on it.  Thus,
   * we need to handle the default colormap in a special way.
   */
  if (pColormap->flags & IsDefault)
    {
#if CYGDEBUG
      winDebug ("winDestroyColormapShadowGDI - Destroying default "
	      "colormap\n");
#endif
      
      /*
       * FIXME: Walk the list of all screens, popping the default
       * palette out of each screen device context.
       */
      
      /* Pop the palette out of the device context */
      SelectPalette (pScreenPriv->hdcScreen,
		     GetStockObject (DEFAULT_PALETTE),
		     FALSE);

      /* Clear our private installed colormap pointer */
      pScreenPriv->pcmapInstalled = NULL;
    }
  
  /* Try to delete the logical palette */
  if (DeleteObject (pCmapPriv->hPalette) == 0)
    {
      ErrorF ("winDestroyColormap - DeleteObject () failed\n");
      return FALSE;
    }
  
  /* Invalidate the colormap privates */
  pCmapPriv->hPalette = NULL;

  return TRUE;
}