Home | History | Annotate | Download | only in brew
      1 /*
      2  * Copyright (C) 2009 Company 100, Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #include "config.h"
     27 #include "PlatformMouseEvent.h"
     28 
     29 #include <AEEEvent.h>
     30 #include <AEEPointerHelpers.h>
     31 #include <AEEStdDef.h>
     32 #include <AEEVCodes.h>
     33 
     34 namespace WebCore {
     35 
     36 PlatformMouseEvent::PlatformMouseEvent(AEEEvent event, uint16 wParam, uint32 dwParam)
     37 {
     38     switch (event) {
     39     case EVT_POINTER_DOWN:
     40         m_eventType = MouseEventPressed;
     41         break;
     42     case EVT_POINTER_UP:
     43         m_eventType = MouseEventReleased;
     44         break;
     45     case EVT_POINTER_MOVE:
     46     case EVT_POINTER_STALE_MOVE:
     47         m_eventType = MouseEventMoved;
     48         break;
     49     default:
     50         m_eventType = MouseEventMoved;
     51         break;
     52     };
     53 
     54     char* dwParamStr = reinterpret_cast<char*>(dwParam);
     55 
     56     int x, y;
     57     AEE_POINTER_GET_XY(dwParamStr, &x, &y);
     58     m_position = IntPoint(x, y);
     59     // Use IDisplay, so position and global position are the same.
     60     m_globalPosition = m_position;
     61 
     62     uint32 keyModifiers = AEE_POINTER_GET_KEY_MODIFIERS(dwParamStr);
     63     m_shiftKey = keyModifiers & (KB_LSHIFT | KB_RSHIFT);
     64     m_ctrlKey  = keyModifiers & (KB_LCTRL | KB_RCTRL);
     65     m_altKey   = keyModifiers & (KB_LALT | KB_RALT);
     66     m_metaKey  = m_altKey;
     67 
     68     // AEE_POINTER_GET_MOUSE_MODIFIERS(dwParamStr) always returns 0,
     69     // so it is impossible to know which button is pressed or released.
     70     // Just use LeftButton because Brew MP usually runs on touch device.
     71     m_button = LeftButton;
     72 
     73     // AEE_POINTER_GET_TIME returns milliseconds
     74     m_timestamp = AEE_POINTER_GET_TIME(dwParamStr) * 0.001;
     75 
     76     m_clickCount = AEE_POINTER_GET_CLICKCOUNT(dwParamStr);
     77 }
     78 
     79 } // namespace WebCore
     80 
     81