void
winReorderWindowsMultiWindow (void)
{
  HWND hwnd = NULL;
  WindowPtr pWin = NULL;
  WindowPtr pWinSib = NULL;
  XID vlist[2];
  static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
  DWORD dwCurrentProcessID = GetCurrentProcessId ();
  DWORD dwWindowProcessID = 0;

#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
  winTrace ("winReorderWindowsMultiWindow\n");
#endif

  if (fRestacking)
    {
      /* It is a recusive call so immediately exit */
#if CYGWINDOWING_DEBUG
      ErrorF ("winReorderWindowsMultiWindow - "
	      "exit because fRestacking == TRUE\n");
#endif
      return;
    }
  fRestacking = TRUE;

  /* Loop through top level Window windows, descending in Z order */
  for ( hwnd = GetTopWindow (NULL);
	hwnd;
	hwnd = GetNextWindow (hwnd, GW_HWNDNEXT) )
    {
      /* Don't take care of other Cygwin/X process's windows */
      GetWindowThreadProcessId (hwnd, &dwWindowProcessID);

      if ( GetProp (hwnd, WIN_WINDOW_PROP)
	   && (dwWindowProcessID == dwCurrentProcessID)
	   && !IsIconic (hwnd) ) /* ignore minimized windows */
	{
	  pWinSib = pWin;
	  pWin = GetProp (hwnd, WIN_WINDOW_PROP);
	      
	  if (!pWinSib)
	    { /* 1st window - raise to the top */
	      vlist[0] = Above;
		  
	      ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
	    }
	  else
	    { /* 2nd or deeper windows - just below the previous one */
	      vlist[0] = winGetWindowID (pWinSib);
	      vlist[1] = Below;

	      ConfigureWindow (pWin, CWSibling | CWStackMode,
			       vlist, wClient(pWin));
	    }
	}
    }

  fRestacking = FALSE;
}
void
winMWExtWMReorderWindows (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  HWND hwnd = NULL;
  win32RootlessWindowPtr pRLWin = NULL;
  win32RootlessWindowPtr pRLWinSib = NULL;
  DWORD dwCurrentProcessID = GetCurrentProcessId ();
  DWORD dwWindowProcessID = 0;
  XID vlist[2];

#if CYGMULTIWINDOW_DEBUG && FALSE
  winDebug ("winMWExtWMReorderWindows\n");
#endif

  pScreenPriv->fRestacking = TRUE;

  if (pScreenPriv->fWindowOrderChanged)
    {
#if CYGMULTIWINDOW_DEBUG
      winDebug ("winMWExtWMReorderWindows - Need to restack\n");
#endif
      hwnd = GetTopWindow (NULL);

      while (hwnd)
	{
	  GetWindowThreadProcessId (hwnd, &dwWindowProcessID);

	  if ((dwWindowProcessID == dwCurrentProcessID)
	      && GetProp (hwnd, WIN_WINDOW_PROP))
	    {
	      pRLWinSib = pRLWin;
	      pRLWin = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP);
	      
	      if (pRLWinSib)
		{
		  vlist[0] = pRLWinSib->pFrame->win->drawable.id;
		  vlist[1] = Below;

		  ConfigureWindow (pRLWin->pFrame->win, CWSibling | CWStackMode,
				   vlist, wClient(pRLWin->pFrame->win));
		}
	      else
		{
		  /* 1st window - raise to the top */
		  vlist[0] = Above;

		  ConfigureWindow (pRLWin->pFrame->win, CWStackMode,
				   vlist, wClient(pRLWin->pFrame->win));
		}
	    }
	  hwnd = GetNextWindow (hwnd, GW_HWNDNEXT);
	}
    }

  pScreenPriv->fRestacking = FALSE;
  pScreenPriv->fWindowOrderChanged = FALSE;
}
void
winMWExtWMResizeXWindow(WindowPtr pWin, int w, int h)
{
    CARD32 *vlist = malloc(sizeof(CARD32) * 2);

    vlist[0] = w;
    vlist[1] = h;
    ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
    free(vlist);
}
void
winMWExtWMMoveXWindow(WindowPtr pWin, int x, int y)
{
    CARD32 *vlist = malloc(sizeof(CARD32) * 2);

    vlist[0] = x;
    vlist[1] = y;
    ConfigureWindow(pWin, CWX | CWY, vlist, wClient(pWin));
    free(vlist);
}
void
winMWExtWMMoveResizeXWindow(WindowPtr pWin, int x, int y, int w, int h)
{
    CARD32 *vlist = malloc(sizeof(long) * 4);

    vlist[0] = x;
    vlist[1] = y;
    vlist[2] = w;
    vlist[3] = h;

    ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
    free(vlist);
}
static void
winRaiseWindow(WindowPtr pWin)
{
    if (!winInDestroyWindowsWindow && !winInRaiseWindow) {
        BOOL oldstate = winInRaiseWindow;
        XID vlist[1] = { 0 };
        winInRaiseWindow = TRUE;
        /* Call configure window directly to make sure it gets processed
         * in time
         */
        ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
        winInRaiseWindow = oldstate;
    }
}
Beispiel #7
0
bool NativeApp::BindDisplayDevice(const ::DisplayDeviceRef &display, const r::VidMode &mode) {
	RAD_VERIFY(!m_activeDisplay);
	RAD_ASSERT(display);

	int screenWidth, screenHeight;

	if (mode.fullscreen) {
		DDVars *vars = DDVars::Get(display->m_imp.m_vars);
		DEVMODEA dm;
		memcpy(&dm, &vars->dm, sizeof(DEVMODEA));

		dm.dmPelsWidth = mode.w;
		dm.dmPelsHeight = mode.h;

		if (mode.hz) {
			dm.dmFields |= DM_DISPLAYFREQUENCY;
			dm.dmDisplayFrequency = mode.hz;
		}

		if (ChangeDisplaySettingsA(&dm, 0) != DISP_CHANGE_SUCCESSFUL) {
			ChangeDisplaySettings(0, 0);
			return false;
		}

		screenWidth = mode.w;
		screenHeight = mode.h;
	} else {
		screenWidth = display->m_imp.m_defMode.w;
		screenHeight = display->m_imp.m_defMode.h;
	}

#if !defined(RAD_OPT_PC_TOOLS)
	ConfigureWindow(
		mode.w,
		mode.h,
		mode.fullscreen,
		screenWidth,
		screenHeight
	);

	ShowWindow(s_hWnd, SW_SHOW);
	UpdateWindow(s_hWnd);
#endif

	display->m_imp.m_curMode = mode;
	m_activeDisplay = display;

	return true;
}
Beispiel #8
0
void Application::SetUp()
{
  cfg::Config const config ( "default.conf" );

  ConfigureWindow(m_window, config);
  
  // Load resources
  {
    GraphicsSettings const graphicsSettings = { config.GetStringProperty( "Catalog::models" ),
                                                config.GetStringProperty( "Catalog::shaders" ),
                                                config.GetStringProperty( "Catalog::textures" ) };
    m_graphics.Initialize( graphicsSettings );

    m_graphics.AddModel( config.GetIntProperty( "Resource::Paddle::id" ),
                         glt::Model( obj::Object( config.GetStringProperty( "Resource::Paddle::model" ) ) ) );
    m_graphics.AddModel( config.GetIntProperty( "Resource::Ball::id" ),
                         glt::Model( obj::Object( config.GetStringProperty( "Resource::Ball::model" ) ) ) );
    m_graphics.AddModel( 3, glt::Model( obj::Object( config.GetStringProperty( "Resource::Numbers::model" ) ) ) );
    m_graphics.AddTexture( "Id1" );

  }
  // Initialize interface
  {
    // Commands: exit, move up, move down, stop
    m_interface.Init({4},{0,1,2,3});
  }
  // Load entities
  {
    MovementData movementData =
    {
      config.GetIntProperty( "Entity::PlayerPaddle::id" ),
      {
        config.GetFloatProperty( "Entity::PlayerPaddle::positionX" ),
        config.GetFloatProperty( "Entity::PlayerPaddle::positionY" ),
        config.GetFloatProperty( "Entity::PlayerPaddle::positionZ" )
      },
      {
        0.0f, 0.0f, 0.0f
      }
    };
    GraphicsData graphicsData =
    {
      1,  // entity id
      { { { 0, 0, 0 } }, { { 0, 0, 1 } }, { { 0, 1, 0 } } }, // Frame
      1, // ModelID
      0
    };
    CollisionData collisionData =
    {
      1, // entity id
      0.5f, 2.0f // size x, y
    };

    m_movement.AddEntity( movementData );
    m_graphics.AddEntity( graphicsData );
    m_collisionDetection.AddEntity( collisionData );

    movementData.m_entityID = config.GetIntProperty( "Entity::AIPaddle::id" );
    movementData.m_position[0] = config.GetFloatProperty( "Entity::AIPaddle::positionX" );
    graphicsData.m_id = config.GetIntProperty( "Entity::AIPaddle::id" );
    collisionData.m_entityID = config.GetIntProperty( "Entity::AIPaddle::id" );
    m_movement.AddEntity( movementData );
    m_graphics.AddEntity( graphicsData );
    m_collisionDetection.AddEntity( collisionData );

    movementData.m_entityID = config.GetIntProperty( "Entity::Ball::id" );
    movementData.m_position[0] = config.GetFloatProperty( "Entity::Ball::positionX" );
    movementData.m_speed[0] = -2.0f;
    movementData.m_speed[1] = -0.5f;
    graphicsData.m_id = config.GetIntProperty( "Entity::Ball::id" );
    graphicsData.m_modelID = config.GetIntProperty( "Entity::Ball::modelID" );
    collisionData.m_entityID = config.GetIntProperty( "Entity::Ball::id" );
    collisionData.m_sizeX = 0.5f;
    collisionData.m_sizeY = 0.5f;
    m_movement.AddEntity( movementData );
    m_graphics.AddEntity( graphicsData );
    m_collisionDetection.AddEntity( collisionData );
  }

  m_running = true;

  m_gameLogic.ResetLevel();
}
/*
 * winAdjustXWindow
 *
 * Move and resize X window with respect to corresponding Windows window.
 * This is called from WM_MOVE/WM_SIZE handlers when the user performs
 * any windowing operation (move, resize, minimize, maximize, restore).
 *
 * The functionality is the inverse of winPositionWindowMultiWindow, which
 * adjusts Windows window with respect to X window.
 */
int
winAdjustXWindow (WindowPtr pWin, HWND hwnd)
{
  RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
  RECT rcWin;  /* The source: WindowRect from hwnd */
  DrawablePtr pDraw;
  XID vlist[4];
  LONG dX, dY, dW, dH, x, y;
  DWORD dwStyle, dwExStyle;

#define WIDTH(rc) (rc.right - rc.left)
#define HEIGHT(rc) (rc.bottom - rc.top)
  
#if CYGWINDOWING_DEBUG
  ErrorF ("winAdjustXWindow\n");
#endif

  if (IsIconic (hwnd))
    {
#if CYGWINDOWING_DEBUG
      ErrorF ("\timmediately return because the window is iconized\n");
#endif
      /*
       * If the Windows window is minimized, its WindowRect has
       * meaningless values so we don't adjust X window to it.
       */
      vlist[0] = 0;
      vlist[1] = 0;
      return ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
    }
  
  pDraw = &pWin->drawable;

  /* Calculate the window rect from the drawable */
  x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN);
  y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN);
  SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
#ifdef CYGMULTIWINDOW_DEBUG
          winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n", 
              rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
              rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
#endif
  dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
  dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
#ifdef CYGMULTIWINDOW_DEBUG
          winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
#endif
  AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle);

  /* The source of adjust */
  GetWindowRect (hwnd, &rcWin);
#ifdef CYGMULTIWINDOW_DEBUG
          winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", 
              rcWin.left, rcWin.top, rcWin.right, rcWin.bottom,
              rcWin.right - rcWin.left, rcWin.bottom - rcWin.top);
          winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n", 
              rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
              rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
#endif

  if (EqualRect (&rcDraw, &rcWin)) {
    /* Bail if no adjust is needed */
#if CYGWINDOWING_DEBUG
    ErrorF ("\treturn because already adjusted\n");
#endif
    return 0;
  }
  
  /* Calculate delta values */
  dX = rcWin.left - rcDraw.left;
  dY = rcWin.top - rcDraw.top;
  dW = WIDTH(rcWin) - WIDTH(rcDraw);
  dH = HEIGHT(rcWin) - HEIGHT(rcDraw);

  /*
   * Adjust.
   * We may only need to move (vlist[0] and [1]), or only resize
   * ([2] and [3]) but currently we set all the parameters and leave
   * the decision to ConfigureWindow.  The reason is code simplicity.
  */
  vlist[0] = pDraw->x + dX - wBorderWidth(pWin);
  vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
  vlist[2] = pDraw->width + dW;
  vlist[3] = pDraw->height + dH;
#if CYGWINDOWING_DEBUG
  ErrorF ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
	  vlist[2], vlist[3]);
#endif
  return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight,
			  vlist, wClient(pWin));
  
#undef WIDTH
#undef HEIGHT
}