Bug 754039 - Cannot scroll via keyboard in separate email window
This commit is contained in:
@ -748,9 +748,47 @@ static gboolean
|
||||
mail_browser_key_press_event (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
if (event->keyval == GDK_KEY_Escape) {
|
||||
e_mail_browser_close (E_MAIL_BROWSER (widget));
|
||||
return TRUE;
|
||||
EMailDisplay *mail_display;
|
||||
|
||||
g_return_val_if_fail (E_IS_MAIL_BROWSER (widget), FALSE);
|
||||
|
||||
mail_display = e_mail_reader_get_mail_display (E_MAIL_READER (widget));
|
||||
|
||||
switch (event->keyval) {
|
||||
case GDK_KEY_Escape:
|
||||
e_mail_browser_close (E_MAIL_BROWSER (widget));
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Home:
|
||||
case GDK_KEY_Left:
|
||||
case GDK_KEY_Up:
|
||||
case GDK_KEY_Right:
|
||||
case GDK_KEY_Down:
|
||||
case GDK_KEY_Next:
|
||||
case GDK_KEY_End:
|
||||
case GDK_KEY_Begin:
|
||||
/* If Caret mode is enabled don't try to process these keys */
|
||||
if (e_web_view_get_caret_mode (E_WEB_VIEW (mail_display)))
|
||||
break;
|
||||
case GDK_KEY_Prior:
|
||||
if (!e_mail_display_needs_key (mail_display, FALSE) &&
|
||||
webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (mail_display)) !=
|
||||
webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (mail_display))) {
|
||||
WebKitDOMDocument *document;
|
||||
WebKitDOMDOMWindow *window;
|
||||
|
||||
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (mail_display));
|
||||
window = webkit_dom_document_get_default_view (document);
|
||||
|
||||
/* Workaround WebKit bug for key navigation, when inner IFRAME is focused.
|
||||
* EMailView's inner IFRAMEs have disabled scrolling, but WebKit doesn't post
|
||||
* key navigation events to parent's frame, thus the view doesn't scroll.
|
||||
* This is a poor workaround for this issue, the main frame is focused,
|
||||
* which has scrolling enabled.
|
||||
*/
|
||||
webkit_dom_dom_window_focus (window);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Chain up to parent's key_press_event() method. */
|
||||
|
||||
@ -2524,3 +2524,37 @@ e_mail_display_set_remote_content (EMailDisplay *display,
|
||||
|
||||
g_mutex_unlock (&display->priv->remote_content_lock);
|
||||
}
|
||||
|
||||
gboolean
|
||||
e_mail_display_needs_key (EMailDisplay *mail_display,
|
||||
gboolean with_input)
|
||||
{
|
||||
gboolean needs_key = FALSE;
|
||||
|
||||
g_return_val_if_fail (E_IS_MAIL_DISPLAY (mail_display), FALSE);
|
||||
|
||||
if (gtk_widget_has_focus (GTK_WIDGET (mail_display))) {
|
||||
WebKitWebFrame *frame;
|
||||
WebKitDOMDocument *dom;
|
||||
WebKitDOMElement *element;
|
||||
gchar *name = NULL;
|
||||
|
||||
frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (mail_display));
|
||||
if (!frame)
|
||||
return FALSE;
|
||||
dom = webkit_web_frame_get_dom_document (frame);
|
||||
element = webkit_dom_html_document_get_active_element (WEBKIT_DOM_HTML_DOCUMENT (dom));
|
||||
|
||||
if (element)
|
||||
name = webkit_dom_node_get_node_name (WEBKIT_DOM_NODE (element));
|
||||
|
||||
/* if INPUT or TEXTAREA has focus, then any key press should go there */
|
||||
if (name && ((with_input && g_ascii_strcasecmp (name, "INPUT") == 0) || g_ascii_strcasecmp (name, "TEXTAREA") == 0)) {
|
||||
needs_key = TRUE;
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
return needs_key;
|
||||
}
|
||||
|
||||
@ -104,6 +104,8 @@ EMailRemoteContent *
|
||||
void e_mail_display_set_remote_content
|
||||
(EMailDisplay *display,
|
||||
EMailRemoteContent *remote_content);
|
||||
gboolean e_mail_display_needs_key (EMailDisplay *mail_display,
|
||||
gboolean with_input);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@ -249,38 +249,6 @@ mail_shell_view_folder_tree_popup_event_cb (EShellView *shell_view,
|
||||
shell_view, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mail_shell_view_mail_display_needs_key (EMailDisplay *mail_display,
|
||||
gboolean with_input)
|
||||
{
|
||||
gboolean needs_key = FALSE;
|
||||
|
||||
if (gtk_widget_has_focus (GTK_WIDGET (mail_display))) {
|
||||
WebKitWebFrame *frame;
|
||||
WebKitDOMDocument *dom;
|
||||
WebKitDOMElement *element;
|
||||
gchar *name = NULL;
|
||||
|
||||
frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (mail_display));
|
||||
if (!frame)
|
||||
return FALSE;
|
||||
dom = webkit_web_frame_get_dom_document (frame);
|
||||
element = webkit_dom_html_document_get_active_element (WEBKIT_DOM_HTML_DOCUMENT (dom));
|
||||
|
||||
if (element)
|
||||
name = webkit_dom_node_get_node_name (WEBKIT_DOM_NODE (element));
|
||||
|
||||
/* if INPUT or TEXTAREA has focus, then any key press should go there */
|
||||
if (name && ((with_input && g_ascii_strcasecmp (name, "INPUT") == 0) || g_ascii_strcasecmp (name, "TEXTAREA") == 0)) {
|
||||
needs_key = TRUE;
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
return needs_key;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mail_shell_view_key_press_event_cb (EMailShellView *mail_shell_view,
|
||||
GdkEventKey *event)
|
||||
@ -325,7 +293,7 @@ mail_shell_view_key_press_event_cb (EMailShellView *mail_shell_view,
|
||||
if (e_web_view_get_caret_mode (E_WEB_VIEW (mail_display)))
|
||||
return FALSE;
|
||||
case GDK_KEY_Prior:
|
||||
if (!mail_shell_view_mail_display_needs_key (mail_display, FALSE) &&
|
||||
if (!e_mail_display_needs_key (mail_display, FALSE) &&
|
||||
webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (mail_display)) !=
|
||||
webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (mail_display))) {
|
||||
WebKitDOMDocument *document;
|
||||
@ -348,7 +316,7 @@ mail_shell_view_key_press_event_cb (EMailShellView *mail_shell_view,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mail_shell_view_mail_display_needs_key (mail_display, TRUE))
|
||||
if (e_mail_display_needs_key (mail_display, TRUE))
|
||||
return FALSE;
|
||||
|
||||
gtk_action_activate (action);
|
||||
|
||||
Reference in New Issue
Block a user