[Commits] [SCM] claws branch, litehtml, updated. 3.17.3-57-g2330467
ticho at claws-mail.org
ticho at claws-mail.org
Fri Jan 25 22:50:23 CET 2019
The branch, litehtml has been updated
via 2330467b71e9a4982f3dd35977449ac62f61d9a7 (commit)
from 4c352b426708c6204b1e9fc16eb9172556feaf48 (commit)
Summary of changes:
src/plugins/litehtml_viewer/lh_widget.cpp | 76 ++++++++++++++++++++---------
1 file changed, 52 insertions(+), 24 deletions(-)
- Log -----------------------------------------------------------------
commit 2330467b71e9a4982f3dd35977449ac62f61d9a7
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Fri Jan 25 22:49:49 2019 +0100
Fix URL display in statusbar when hovering over a link in litehtml_viewer
diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index 42b96dc..5e779fb 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -29,6 +29,9 @@
#include <sys/stat.h>
#include <curl/curl.h>
#include <gdk/gdk.h>
+
+#include "litehtml/litehtml.h"
+
#include "lh_widget.h"
#include "lh_widget_wrapped.h"
#include "http.h"
@@ -295,36 +298,61 @@ void lh_widget::clear()
void lh_widget::set_cursor(const litehtml::tchar_t* cursor)
{
- //g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget set_cursor %s:%s", m_cursor, cursor);
- if (cursor)
- {
- if (m_cursor != cursor)
- {
- m_cursor = cursor;
- update_cursor();
+ if (cursor) {
+ if (m_cursor != cursor) {
+ m_cursor = cursor;
+ update_cursor();
+ }
}
- }
}
void lh_widget::update_cursor()
{
- //g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget update_cursor %s", m_cursor);
- GdkCursorType cursType = GDK_ARROW;
- if(m_cursor == _t("pointer"))
- {
- cursType = GDK_HAND2;
- }
- if(cursType == GDK_ARROW)
- {
- lh_widget_statusbar_pop();
- gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), NULL);
- } else
- {
- if (!m_clicked_url.empty()) {
- lh_widget_statusbar_push(m_clicked_url.c_str());
+ gint x, y;
+ litehtml::element::ptr root_el, over_el, el;
+ GdkWindow *w = gdk_display_get_window_at_pointer(gdk_display_get_default(),
+ &x, &y);
+ GdkCursorType cursType = GDK_ARROW;
+
+ if (m_cursor == _t("pointer")) {
+ cursType = GDK_HAND2;
+ }
+
+ if (cursType == GDK_ARROW) {
+ gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), NULL);
+ } else {
+ gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), gdk_cursor_new(cursType));
+ }
+
+ if (w != gtk_widget_get_window(m_drawing_area))
+ return;
+
+ /* Find the element we are hovering over */
+ root_el = m_html->root();
+ g_return_if_fail(root_el != NULL);
+ over_el = root_el->get_element_by_point(x, y, x, y);
+ g_return_if_fail(over_el != NULL);
+
+ /* If it's not an anchor, check if it has a parent anchor
+ * (e.g. it's an image within an anchor) and grab a pointer
+ * to that. */
+ if (strcmp(over_el->get_tagName(), "a") && over_el->parent()) {
+ el = over_el->parent();
+ while (el && el != root_el && strcmp(el->get_tagName(), "a")) {
+ el = el->parent();
+ }
+
+ if (el && el != root_el)
+ over_el = el;
+ }
+
+ /* If it's an anchor, show its "href" attribute in statusbar,
+ * otherwise clear statusbar. */
+ if (!strcmp(over_el->get_tagName(), "a")) {
+ lh_widget_statusbar_push(over_el->get_attr(_t("href")));
+ } else {
+ lh_widget_statusbar_pop();
}
- gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), gdk_cursor_new(cursType));
- }
}
void lh_widget::print()
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list