unixsite.cpp

来自「symbian 下的helix player源代码」· C++ 代码 · 共 2,150 行 · 第 1/5 页

CPP
2,150
字号
               
               InternalForceRedraw();
            }
            //Only throw away the event if it had something to do with
            //scolling.
            if( m_bScrollingInProgress )
            {
                m_bScrollingInProgress = FALSE;
                m_nScrollDir = 0;
               return TRUE;
            }
         }
         ////////////////////////////////////////////////////////
         // END SCROLLING GARBAGE
         ////////////////////////////////////////////////////////
         point.x = -1;
         point.y = -1;

         if( pEvent->event == MotionNotify)
         {
            point.x = ((XMotionEvent*)pXEvent)->x;
            point.y = ((XMotionEvent*)pXEvent)->y;
         }
         else if( pEvent->event == ButtonPress )
         {
            point.x = ((XMotionEvent*)pXEvent)->x;
            point.y = ((XMotionEvent*)pXEvent)->y;
         }

         //
         //Give the user a chance at the native event.
         //
         if( m_RegionWithoutChildren && HXPointInRegion(m_RegionWithoutChildren, point.x, point.y ))
         {
            if( m_Region && HXPointInRegion(m_Region, point.x, point.y) )
            {
                if (m_pUser)
                    m_pUser->HandleEvent(pEvent);
            }
            else
            {
               INT32 handledCount = 0;
               INT32 mapCount     = 0;
               
               //try send this to all of our children
              _unixsitecpp1: 
               mapCount = m_ChildrenMap.GetCount();
               CHXMapPtrToPtr::Iterator i;
               for(i=m_ChildrenMap.Begin() ; i!=m_ChildrenMap.End() ; ++i)
               {
                  CHXBaseSite* pSite = (CHXBaseSite*) *i;
                  pSite->_HandleOSEvents(pEvent);
                  if (pEvent->handled)
                  {                      
                     break;
                  }
                  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 |
     

⌨️ 快捷键说明

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