⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unixsite.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                  handledCount+=pEvent->handled;                  pEvent->handled=0;                                    if (m_ChildrenMap.GetCount() != mapCount)                  {                     goto _unixsitecpp1;                  }               }               if (handledCount)               {                  pEvent->handled = 1;               }               HX_ASSERT(handledCount<2);            }         }         pEvent->handled=FALSE;      }   }      return FALSE;}void CHXUnixSite::_GenerateOSEvent(HXxEvent* pEvent, HXxEvent* pEvent2){   //XXXgfw Not needed on UNIX I guess???}void CHXUnixSite::_GenerateSetCursorEvent(){#ifdef _DEBUG      fprintf( stderr, "CHXUnixSite::_GenerateSetCursorEvent\n" );#endif      //XXXgfw do we need this??}void CHXUnixSite::_TryCreateXSlider(){   if( !m_ScrollHorizButtonL && IsSiteVisible() )      _CreateHorizScrollBar();}void CHXUnixSite::_SetXSliderValues(INT32 range, INT32 pageSize){   //XXXgfw this is a do nothing as long as we only have   //scroll buttons on unix and not real scroll bars.}void CHXUnixSite::_TryCreateYSlider(){   if( !m_ScrollVertButtonT && IsSiteVisible() )      _CreateVertScrollBar();}void CHXUnixSite::_SetYSliderValues(INT32 range, INT32 pageSize){   //XXXgfw this is a do nothing as long as we only have   //scroll buttons on unix and not real scroll bars.}void CHXUnixSite::_GetSystemSizeOfSliders(INT32* pWidth, INT32* pHeight){   *pWidth = *pHeight = SCROLL_BAR_WIDTH;}BOOL CHXUnixSite::_IsWindowVisible(){   HX_RESULT retVal = FALSE;   //XXXgfw do this for now...   retVal = IsSiteVisible();   return retVal;}void CHXUnixSite::_ShowXSlider(BOOL bShow){   if( GetWindow() )   {      if( bShow )         _MapHorzScroll();      else         _UnmapHorzScroll();   }}void CHXUnixSite::_MoveXSlider( INT32 left,                                INT32 top,                                INT32 right,                                INT32 bottom,                                BOOL bRedraw ){   //Do nothing right now....}void CHXUnixSite::_ShowYSlider(BOOL bShow){   if( GetWindow() )   {      if( bShow )         _MapVertScroll();      else         _UnmapVertScroll();   }}void CHXUnixSite::_MoveYSlider( INT32 left,                                INT32 top,                                INT32 right,                                INT32 bottom,                                BOOL bRedraw){   //do nothing right now...}BOOL CHXUnixSite::_DoesXSliderExist(){   return (m_ScrollHorizButtonL!=0);}void* CHXUnixSite::_GetContainingWindow(){   //XXXgfw Do we need this???   return NULL;}void CHXUnixSite::_GetCursorPos(HXxPoint* pPoint){   //Return the cursor pos in screen coords.   Window rootWin;   Window childWin;   int rootX=0;   int rootY=0;   int childX=0;   int childY=0;   unsigned int mask=0;   Bool ret=FALSE;      HX_ASSERT(GetWindow());   Display* pDis = (Display*)GetWindow()->display;   XLockDisplay(pDis);   ret = XQueryPointer(pDis,                       (Window)GetWindow()->window,                       &rootWin,                       &childWin,                       &rootX, &rootY,                       &childX, &childY,                       &mask);   XUnlockDisplay(pDis);   if(ret)   {      pPoint->x = rootX;      pPoint->y = rootY;   }}void* CHXUnixSite::_GetWindowWithCursor(){   //Return the cursor pos in screen coords.   void*        pRet  = NULL;   int          rootX = 0;   int          rootY = 0;   int          childX= 0;   int          childY= 0;   unsigned int mask  = 0;   Bool         ret   = FALSE;   Window       rootWin;   Window       childWin;      HX_ASSERT(GetWindow());   Display* pDis = (Display*)GetWindow()->display;   XLockDisplay(pDis);   ret = XQueryPointer(pDis,                       (Window)GetWindow()->window,                       &rootWin,                       &childWin,                       &rootX, &rootY,                       &childX, &childY,                       &mask);   XUnlockDisplay(pDis);   if(ret)   {      pRet = (void*)childWin;   }   return pRet;}void CHXUnixSite::_MapPointToOSWindow(HXxPoint* pPt, void** pWindowHandle){   //XXXgfw we could query the window tree and traverse down but that   //is really slow and this isn't used right now.   HX_ASSERT( "Not implemented..." == NULL );}void CHXUnixSite::_ReInitPrimarySurface(){   //Nothing to do in unix here right?}BOOL CHXUnixSite::_MoveWindow( void* win,                               INT32 X,                               INT32 Y,                               INT32 nWidth,                               INT32 nHeight,                               BOOL bRepaint){   //XXXgfw we still have to do bRepaint....   HX_ASSERT( m_pWindow && m_pWindow->window && m_pWindow->display);   _DestroyScrollButtons();   XLockDisplay((Display*) m_pWindow->display);   XMoveResizeWindow( (Display*)m_pWindow->display,                      (Window)m_pWindow->window,                      X,                      Y,                      nWidth,                      nHeight                      );   XUnlockDisplay((Display*) m_pWindow->display);   return TRUE;}BOOL CHXUnixSite::_UpdateWindow(void* hWnd){   //We need to generate a repaint here of the window....   return TRUE;}BOOL CHXUnixSite::_ShowWindow(void* hWnd, INT32 nCmdShow){   HX_ASSERT( nCmdShow==HX_SHOW_WINDOW || nCmdShow==HX_HIDE_WINDOW);   if( !m_pWindow || !m_pWindow->window || !m_pWindow->display )      return FALSE;   if( nCmdShow == HX_SHOW_WINDOW )   {      _MapScrollButtons();      XLockDisplay((Display*) m_pWindow->display);      XMapWindow( (Display*)m_pWindow->display, (Window)m_pWindow->window );      XUnlockDisplay((Display*) m_pWindow->display);   }   else   {      _UnmapScrollButtons();      XLockDisplay((Display*) m_pWindow->display);      XUnmapWindow( (Display*)m_pWindow->display, (Window)m_pWindow->window );      XUnlockDisplay((Display*) m_pWindow->display);   }   return TRUE;}BOOL CHXUnixSite::_SetWindowPos(void* hWnd,                                void* hWndInsertAfter,                                INT32 X,                                INT32 Y,                                INT32 cx,                                INT32 cy,                                INT32 uFlags){#ifdef _DEBUG   fprintf( stderr, "Now what on earth is this suppose to do??\n" );#endif   return TRUE;}BOOL CHXUnixSite::_SetWindowRgn(void* hWnd, HXREGION* hRgn, BOOL bRedraw){   HX_ASSERT( GetWindow() );   Display* pDis = (Display*)GetWindow()->display;   XLockDisplay(pDis);   XSetRegion( pDis,               (GC)m_pVideoSurface->_GetDC(NULL),               (Region)hRgn               );   XUnlockDisplay(pDis);   if( bRedraw )   {      HX_ASSERT("Redraw asked for here"==NULL );   }      return TRUE;}void CHXUnixSite::_SetFocus(void* pWindow){   XWindowAttributes attr;   HXxWindow*        pWin = GetWindow();      HX_ASSERT(pWin);   HX_ASSERT(pWindow);     XLockDisplay((Display*) pWin->display);   XGetWindowAttributes((Display*)pWin->display, (Window)pWindow, &attr);   XUnlockDisplay((Display*) pWin->display);   if( attr.map_state == IsViewable )   {      XLockDisplay((Display*) pWin->display);      XSetInputFocus( (Display*)pWin->display,                      (Window)pWindow,                      RevertToParent,                      CurrentTime                      );      XUnlockDisplay((Display*) pWin->display);   }      return;}HX_RESULT CHXUnixSite::_EnterFullScreen(){   HXxWindow* pWin = GetWindow();   HX_ASSERT( pWin && pWin->display && pWin->display);   HX_ASSERT( this == m_pTopLevelSite );   if( 0 != m_winFullScreenWindow || IsFullScreen() )   {      //We are already in full screen      return HXR_FAIL;   }      //Create a override redirect window to fill the root.   XSizeHints           size_hints;   XLockDisplay((Display*) pWin->display);   Screen*              pScreen = XDefaultScreenOfDisplay((Display*)pWin->display);   XUnlockDisplay((Display*) pWin->display);   UINT16               uHorzRes = WidthOfScreen(pScreen);   UINT16               uVertRes = HeightOfScreen(pScreen);   int                  attrMask = 0;   XSetWindowAttributes attr;       memset(&attr, 0, sizeof(XSetWindowAttributes));   attrMask = CWOverrideRedirect | CWBorderPixel |      CWBackPixel | CWCursor;   attr.cursor = None;   attr.override_redirect = True;   XLockDisplay((Display*)pWin->display);   attr.background_pixel = BlackPixel((Display*)pWin->display,                                      DefaultScreen((Display*)pWin->display));   attr.border_pixel     = BlackPixel((Display*)pWin->display,                                      DefaultScreen((Display*)pWin->display));   XUnlockDisplay((Display*)pWin->display);   size_hints.flags  = PPosition | PSize;   size_hints.x      = 0;   size_hints.y      = 0;   size_hints.width  = uHorzRes;   size_hints.height = uVertRes;   //Create it.   XLockDisplay((Display*) pWin->display);   Window window = XCreateWindow((Display*)pWin->display,                                  DefaultRootWindow((Display*)pWin->display),                                 size_hints.x,                                 size_hints.y,                                 size_hints.width,                                 size_hints.height,                                  0,                                 CopyFromParent,                                 InputOutput,                                 CopyFromParent,                                 attrMask,                                 &attr);      //Tell the WM about this window.   XSetStandardProperties( (Display*)pWin->display,                           window,                           "unixfullscreen",                           "unixfullscreen",                           None,                           NULL, 0,                           &size_hints                           );      int result = XSelectInput( zm_display, window,                              ButtonPressMask   | ButtonReleaseMask | KeyPressMask    |                              KeyReleaseMask    | EnterWindowMask   | LeaveWindowMask |                              PointerMotionMask | ButtonMotionMask  | KeymapStateMask |                              ExposureMask      | StructureNotifyMask | FocusChangeMask                              );   //Map the window.   XMapWindow((Display*)pWin->display, window);   XUnlockDisplay((Display*) pWin->display);   //Get ready to resize the presentation....   m_pTopLevelSite->m_bDisableForceRedraw = TRUE;   //Maintain aspect ratio and Scale it.   float fXScale   = (float)uHorzRes/(float)(m_size.cx);   float fYScale   = (float)uVertRes/(float)(m_size.cy);   float fScale    = (fXScale<fYScale) ? fXScale : fYScale;   int nWidth      = (int)(fScale*m_size.cx+.5);   int nHeight     = (int)(fScale*m_size.cy+.5);   //Center the presentation and save the old size   memcpy( &m_PreFullScreenSize, &m_size, sizeof( HXxSize) ); /* Flawfinder: ignore */   HXxSize size = {nWidth, nHeight};      if( nWidth<uHorzRes )      m_ptFullScreenOffset.x = (uHorzRes-nWidth)/2;      if( nHeight<uVertRes )      m_ptFullScreenOffset.y = (uVertRes-nHeight)/2;   //Reparent our main window.......   Window       winRootParent = 0;   Window       winParent     = 0;   Window*      pwinChildren  = NULL;   unsigned int nNumChildren  = 0;   XLockDisplay((Display*) pWin->display);   XQueryTree( (Display*)pWin->display,               (Window)pWin->window,               &winRootParent,               &winParent,               &pwinChildren,               &nNumChildren               );   //Free unused children list.   XFree( pwinChildren );   XUnlockDisplay((Display*) pWin->display);   HX_ASSERT( winParent );   m_winOldParent = winParent;   XLockDisplay((Display*) pWin->display);   XReparentWindow( (Display*)pWin->display,                    (Window)pWin->window,                    window,                    m_ptFullScreenOffset.x,                    m_ptFullScreenOffset.y                    );      //Flush event queue.   XSync((Display*)pWin->display, False);   XUnlockDisplay((Display*) pWin->display);   //Save it   m_winFullScreenWindow = window;   m_bInFullScreen = TRUE;      //Now resize

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -