Commit b4ec741e authored by kov@webkit.org's avatar kov@webkit.org
Browse files

[GTK] WebKit should properly set the input method context window location

https://bugs.webkit.org/show_bug.cgi?id=84981

Patch by Martin Robinson <mrobinson@igalia.com> on 2012-05-05
Reviewed by Gustavo Noronha Silva.

Source/WebCore:

* platform/gtk/GtkInputMethodFilter.cpp:
(WebCore::GtkInputMethodFilter::setCursorRect): Add this method to plumb the
cursor rect through to the input method.
* platform/gtk/GtkInputMethodFilter.h: Add the new method declaration.

Source/WebKit/gtk:

* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::ChromeClient::paint): During painting, update the cursor rectangle
if possible.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@116231 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2c7328e7
2012-05-05 Martin Robinson <mrobinson@igalia.com>
[GTK] WebKit should properly set the input method context window location
https://bugs.webkit.org/show_bug.cgi?id=84981
Reviewed by Gustavo Noronha Silva.
* platform/gtk/GtkInputMethodFilter.cpp:
(WebCore::GtkInputMethodFilter::setCursorRect): Add this method to plumb the
cursor rect through to the input method.
* platform/gtk/GtkInputMethodFilter.h: Add the new method declaration.
2012-05-05 Dean Jackson <dino@apple.com>
 
Add new Setting/Preference to disable requestAnimationFrame
......@@ -72,6 +72,27 @@ void GtkInputMethodFilter::setWidget(GtkWidget* widget)
g_signal_connect_after(widget, "realize", G_CALLBACK(handleWidgetRealize), this);
}
void GtkInputMethodFilter::setCursorRect(const IntRect& cursorRect)
{
// Don't move the window unless the cursor actually moves more than 10
// pixels. This prevents us from making the window flash during minor
// cursor adjustments.
static const int windowMovementThreshold = 10 * 10;
if (cursorRect.location().distanceSquaredToPoint(m_lastCareLocation) < windowMovementThreshold)
return;
m_lastCareLocation = cursorRect.location();
IntRect translatedRect = cursorRect;
ASSERT(m_widget);
GtkAllocation allocation;
gtk_widget_get_allocation(m_widget, &allocation);
translatedRect.move(allocation.x, allocation.y);
GdkRectangle gdkCursorRect = cursorRect;
gtk_im_context_set_cursor_location(m_context.get(), &gdkCursorRect);
}
GtkInputMethodFilter::GtkInputMethodFilter()
: m_cursorOffset(0)
, m_context(adoptGRef(gtk_im_multicontext_new()))
......
......@@ -18,6 +18,7 @@
*/
#include "GRefPtrGtk.h"
#include "IntRect.h"
#include <gdk/gdk.h>
#include <wtf/text/WTFString.h>
......@@ -46,6 +47,7 @@ public:
void confirmComposition();
void cancelContextComposition();
void updatePreedit();
void setCursorRect(const IntRect& location);
GtkIMContext* context() { return m_context.get(); }
......@@ -81,6 +83,7 @@ private:
bool m_preventNextCommit;
bool m_justSentFakeKeyUp;
unsigned int m_lastFilteredKeyPressCodeWithNoResults;
IntPoint m_lastCareLocation;
};
} // namespace WebCore
......
2012-05-05 Martin Robinson <mrobinson@igalia.com>
[GTK] WebKit should properly set the input method context window location
https://bugs.webkit.org/show_bug.cgi?id=84981
Reviewed by Gustavo Noronha Silva.
* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::ChromeClient::paint): During painting, update the cursor rectangle
if possible.
2012-05-05 Gustavo Noronha Silva <gns@gnome.org>
 
Unreviewed preparation for 1.9.2.
......
......@@ -33,6 +33,7 @@
#include "FileIconLoader.h"
#include "FileSystem.h"
#include "FloatRect.h"
#include "FocusController.h"
#include "FrameLoadRequest.h"
#include "FrameView.h"
#include "GtkUtilities.h"
......@@ -598,6 +599,13 @@ void ChromeClient::paint(WebCore::Timer<ChromeClient>*)
m_dirtyRegion = Region();
m_lastDisplayTime = currentTime();
m_repaintSoonSourceId = 0;
// We update the IM context window location here, because we want it to be
// synced with cursor movement. For instance, a text field can move without
// the selection changing.
Frame* focusedFrame = core(m_webView)->focusController()->focusedOrMainFrame();
if (focusedFrame && focusedFrame->editor()->canEdit())
m_webView->priv->imFilter.setCursorRect(frame->selection()->absoluteCaretBounds());
}
void ChromeClient::invalidateRootView(const IntRect&, bool immediate)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment