Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Started mouse events implementation #26

Open
wants to merge 1 commit into
base: webkit2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/WebKit/PlatformHaiku.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ list(APPEND WebKit_SOURCES
Shared/haiku/WebCoreArgumentCodersHaiku.cpp
Shared/haiku/WebMemorySamplerHaiku.cpp
Shared/haiku/AuxiliaryProcessMainHaiku.cpp
Shared/haiku/NativeWebMouseEventHaiku.cpp
Shared/haiku/WebEventFactory.cpp

UIProcess/API/C/haiku/WKView.cpp
UIProcess/API/haiku/APIWebsiteDataStoreHaiku.cpp
Expand Down
37 changes: 25 additions & 12 deletions Source/WebKit/Shared/haiku/WebEventFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"

#include "WebEventFactory.h"
#include <WebCore/IntPoint.h>
#include <wtf/WallTime.h>

#include <Message.h>
#include <View.h>
#include <Point.h>

enum {
BUTTON_PRESS = 'btps',
BUTTON_RELEASE = 'btrl',
MOUSE_MOVEMENT = 'mmmv',
}
};
namespace WebKit
{
static inline int clickCount(WebEvent::Type type, WebMouseEvent::Button button, const POINT& position, int64_t timeStampSeconds)
static inline int clickCount(WebEvent::Type type, WebMouseEvent::Button button, const BPoint& position, int64 timeStampSeconds)
{
static int gLastClickCount;
static int64_t gLastClickTime;
static POINT lastClickPosition;
static int64 gLastClickTime;
static BPoint lastClickPosition;
static WebMouseEvent::Button lastClickButton = WebMouseEvent::LeftButton;

bool cancelPreviousClick = 0;
Expand All @@ -62,9 +68,14 @@ namespace WebKit

return gLastClickCount;
}
static inline OptionSet<WebEvent::Modifier> modifiersForEvent()
{
OptionSet<WebEvent::Modifier> modifier;
return modifier;
}
static inline WebMouseEvent::Button buttonForEvent(const BMessage* message)
{
int32_t buttonType;
int32 buttonType;
unsigned button = 0;
message->FindInt32("button",&buttonType);
switch(buttonType)
Expand All @@ -82,10 +93,10 @@ namespace WebKit

return static_cast<WebMouseEvent::Button>(button);
}
static WebMouseEvent createWebMouseEvent(const BMessage* message)
WebMouseEvent WebEventFactory::createWebMouseEvent(const BMessage* message)
{
WebEvent::Type type = static_cast<WebEvent::Type>(0);
int32_t mouseEventType;
int32 mouseEventType;
message->FindInt32("type",&mouseEventType);
switch(mouseEventType)
{
Expand All @@ -105,13 +116,15 @@ namespace WebKit
BPoint where;
message->FindPoint("where",&where);

int64_t when;
int64 when;
message->FindInt64("when",&when);

/*return WebMouseEvent(
type,buttonForEvent(message),0,IntPoint(where),IntPoint(where),
0,0,0,
)*/
WebMouseEvent::Button button = buttonForEvent(message);

return WebMouseEvent(
type,button,0,WebCore::IntPoint(where),WebCore::IntPoint(where),
0,0,0,clickCount(type,button,where,when),modifiersForEvent(),WTF::WallTime::now()
);
//it says some deltax delta y should it be added from be_deltax?

}
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/UIProcess/API/haiku/WebViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
#include "DrawingAreaProxyCoordinatedGraphics.h"
#include "WebProcessPool.h"
#include "WebPageGroup.h"

#include "NativeWebMouseEvent.h"

#include <WebCore/IntRect.h>
#include <Looper.h>

using namespace WebKit;
using namespace WebCore;
Expand Down Expand Up @@ -93,5 +97,7 @@ void WebViewBase::Draw(BRect update)
}
void WebViewBase::MouseMoved(BPoint where,uint32 code,const BMessage* dragMessage)
{
BMessage* mouseMessage = Looper()->DetachCurrentMessage();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't detach the message here or you'll have a memory leak.
Use Looper()->CurrentMessage() instead.

NativeWebMouseEvent mouseEvent = NativeWebMouseEvent(mouseMessage);
}