summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-03 19:58:59 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-03 19:58:59 +0200
commit6e221adade45fa4dfc6408c2636b0ddc1a350911 (patch)
tree7dcf6a3230e85bbec5569181f6039a0fa3028529
parentea9ac3155d1774f13ac4e9a96605c0e85a8f299e (diff)
downloadserenity-6e221adade45fa4dfc6408c2636b0ddc1a350911.zip
LibWeb: Send key events to the WebContent process
This makes contenteditable work in multi-process mode. :^)
-rw-r--r--Libraries/LibWeb/WebContentView.cpp5
-rw-r--r--Libraries/LibWeb/WebContentView.h2
-rw-r--r--Services/WebContent/ClientConnection.cpp5
-rw-r--r--Services/WebContent/ClientConnection.h1
-rw-r--r--Services/WebContent/WebContentServer.ipc2
5 files changed, 15 insertions, 0 deletions
diff --git a/Libraries/LibWeb/WebContentView.cpp b/Libraries/LibWeb/WebContentView.cpp
index 3273c7b478..e2552f35d9 100644
--- a/Libraries/LibWeb/WebContentView.cpp
+++ b/Libraries/LibWeb/WebContentView.cpp
@@ -76,6 +76,11 @@ void WebContentView::resize_event(GUI::ResizeEvent& event)
request_repaint();
}
+void WebContentView::keydown_event(GUI::KeyEvent& event)
+{
+ client().post_message(Messages::WebContentServer::KeyDown(event.key(), event.modifiers(), event.code_point()));
+}
+
void WebContentView::mousedown_event(GUI::MouseEvent& event)
{
client().post_message(Messages::WebContentServer::MouseDown(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers()));
diff --git a/Libraries/LibWeb/WebContentView.h b/Libraries/LibWeb/WebContentView.h
index 07ed3f0359..c77e3aabcd 100644
--- a/Libraries/LibWeb/WebContentView.h
+++ b/Libraries/LibWeb/WebContentView.h
@@ -62,11 +62,13 @@ private:
WebContentView();
// ^Widget
+ virtual bool accepts_focus() const override { return true; }
virtual void paint_event(GUI::PaintEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void mouseup_event(GUI::MouseEvent&) override;
virtual void mousemove_event(GUI::MouseEvent&) override;
+ virtual void keydown_event(GUI::KeyEvent&) override;
// ^ScrollableWidget
virtual void did_scroll() override;
diff --git a/Services/WebContent/ClientConnection.cpp b/Services/WebContent/ClientConnection.cpp
index 462c5c555a..0a7eacbd85 100644
--- a/Services/WebContent/ClientConnection.cpp
+++ b/Services/WebContent/ClientConnection.cpp
@@ -153,4 +153,9 @@ void ClientConnection::handle(const Messages::WebContentServer::MouseUp& message
page().handle_mouseup(message.position(), message.button(), message.modifiers());
}
+void ClientConnection::handle(const Messages::WebContentServer::KeyDown& message)
+{
+ page().handle_keydown((KeyCode)message.key(), message.modifiers(), message.code_point());
+}
+
}
diff --git a/Services/WebContent/ClientConnection.h b/Services/WebContent/ClientConnection.h
index 8609bb8e62..22dfca2c51 100644
--- a/Services/WebContent/ClientConnection.h
+++ b/Services/WebContent/ClientConnection.h
@@ -57,6 +57,7 @@ private:
virtual void handle(const Messages::WebContentServer::MouseDown&) override;
virtual void handle(const Messages::WebContentServer::MouseMove&) override;
virtual void handle(const Messages::WebContentServer::MouseUp&) override;
+ virtual void handle(const Messages::WebContentServer::KeyDown&) override;
void flush_pending_paint_requests();
diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipc
index 1dd8e03913..aaef44c2bb 100644
--- a/Services/WebContent/WebContentServer.ipc
+++ b/Services/WebContent/WebContentServer.ipc
@@ -12,4 +12,6 @@ endpoint WebContentServer = 89
MouseDown(Gfx::IntPoint position, unsigned button, unsigned buttons, unsigned modifiers) =|
MouseMove(Gfx::IntPoint position, unsigned button, unsigned buttons, unsigned modifiers) =|
MouseUp(Gfx::IntPoint position, unsigned button, unsigned buttons, unsigned modifiers) =|
+
+ KeyDown(i32 key, unsigned modifiers, u32 code_point) =|
}