Home | History | Annotate | Download | only in haiku
      1 /*
      2  * Copyright (C) 2006 Zack Rusin <zack (at) kde.org>
      3  * Copyright (C) 2007 Ryan Leavengood <leavengood (at) gmail.com>
      4  * Copyright (C) 2009 Maxime Simon <simon.maxime (at) gmail.com>
      5  * Copyright (C) 2010 Stephan Amus <superstippi (at) gmx.de>
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #include "config.h"
     30 #include "EventHandler.h"
     31 
     32 #include "ClipboardHaiku.h"
     33 #include "EventNames.h"
     34 #include "FocusController.h"
     35 #include "Frame.h"
     36 #include "FrameView.h"
     37 #include "HitTestResult.h"
     38 #include "KeyboardEvent.h"
     39 #include "MouseEventWithHitTestResults.h"
     40 #include "NotImplemented.h"
     41 #include "Page.h"
     42 #include "PlatformKeyboardEvent.h"
     43 #include "PlatformWheelEvent.h"
     44 #include "RenderWidget.h"
     45 
     46 #include <interface/View.h>
     47 
     48 
     49 namespace WebCore {
     50 
     51 const double EventHandler::TextDragDelay = 0.0;
     52 
     53 bool EventHandler::tabsToAllFormControls(KeyboardEvent* event) const
     54 {
     55     bool handlingOptionTab = isKeyboardOptionTab(event);
     56 
     57     return handlingOptionTab;
     58 }
     59 
     60 void EventHandler::focusDocumentView()
     61 {
     62     BView* view = m_frame->view()->platformWidget();
     63     if (view && view->LockLooperWithTimeout(5000) == B_OK) {
     64         view->MakeFocus(true);
     65         view->UnlockLooper();
     66     }
     67 
     68     Page* page = m_frame->page();
     69     if (page)
     70         page->focusController()->setFocusedFrame(m_frame);
     71 }
     72 
     73 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
     74 {
     75     // Figure out which view to send the event to.
     76     RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0;
     77     if (!target || !target->isWidget())
     78         return false;
     79     return passMouseDownEventToWidget(toRenderWidget(target)->widget());
     80 }
     81 
     82 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
     83 {
     84     return passMouseDownEventToWidget(renderWidget->widget());
     85 }
     86 
     87 bool EventHandler::passMouseDownEventToWidget(Widget* widget)
     88 {
     89     notImplemented();
     90     return false;
     91 }
     92 
     93 bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
     94 {
     95     // On Haiku, clicks which activate the window in non focus-follows-mouse mode
     96     // are not passed to the window, so any event we generate is not the activation
     97     // event.
     98     return false;
     99 }
    100 
    101 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget)
    102 {
    103     if (!widget->isFrameView())
    104         return false;
    105 
    106     return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(event);
    107 }
    108 
    109 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
    110 {
    111     return ClipboardHaiku::create(ClipboardWritable, Clipboard::DragAndDrop);
    112 }
    113 
    114 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
    115 {
    116     subframe->eventHandler()->handleMousePressEvent(mev.event());
    117     return true;
    118 }
    119 
    120 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode)
    121 {
    122     subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode);
    123     return true;
    124 }
    125 
    126 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
    127 {
    128     subframe->eventHandler()->handleMouseReleaseEvent(mev.event());
    129     return true;
    130 }
    131 
    132 unsigned EventHandler::accessKeyModifiers()
    133 {
    134     // NOTE: On Haiku, the user can choose Alt or Ctrl as access key, but
    135     // the PlatformKeyboardEvent already takes care of this, internally,
    136     // we always use Alt.
    137     return PlatformKeyboardEvent::AltKey;
    138 }
    139 
    140 } // namespace WebCore
    141 
    142