[Commits] [SCM] claws branch, master, updated. 3.17.3-146-g4e67984

ticho at claws-mail.org ticho at claws-mail.org
Wed Apr 10 21:17:06 CEST 2019


The branch, master has been updated
       via  4e679846fdb066e5d764fdee3bf0ea7c195b2d00 (commit)
       via  6f95b7eeb6e5778ec0be8889041c1a33602ed3c8 (commit)
      from  1efbdb3d9beea0137aeb304865dd061752a1e46f (commit)

Summary of changes:
 src/plugins/litehtml_viewer/lh_widget.cpp       |   42 +++++++++--------------
 src/plugins/litehtml_viewer/litehtml/document.h |    5 +++
 2 files changed, 21 insertions(+), 26 deletions(-)


- Log -----------------------------------------------------------------
commit 4e679846fdb066e5d764fdee3bf0ea7c195b2d00
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Wed Apr 10 21:00:01 2019 +0200

    Fix incorrect logic in lh_widget::set_cursor().

diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index 4e6d785..b02fa61 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -295,35 +295,31 @@ void lh_widget::clear()
 
 void lh_widget::set_cursor(const litehtml::tchar_t* cursor)
 {
-	litehtml::element::ptr over_el;
+	litehtml::element::ptr over_el = m_html->over_element();
 	gint x, y;
-	GdkWindow *w = gdk_display_get_window_at_pointer(gdk_display_get_default(),
-			&x, &y);
 
-	if (w != gtk_widget_get_window(m_drawing_area))
-		return;
-
-	over_el = m_html->root()->get_element_by_point(x, y, x, y);
-
-	if (!over_el) {
-		m_over_element = NULL;
-		return;
+	if (m_showing_url &&
+			(over_el == NULL || over_el != m_over_element)) {
+		lh_widget_statusbar_pop();
+		m_showing_url = FALSE;
 	}
 
-	if (cursor && over_el) {
-		if (over_el != m_over_element) {
-			m_over_element = over_el;
-			update_cursor(cursor);
-		}
+	if (over_el != m_over_element) {
+		m_over_element = over_el;
+		update_cursor(cursor);
 	}
 }
 
 void lh_widget::update_cursor(const litehtml::tchar_t* cursor)
 {
-	const litehtml::tchar_t *href;
 	GdkCursorType cursType = GDK_ARROW;
+	const litehtml::tchar_t *href = get_href_at(m_over_element);
 
-	if (cursor == _t("pointer")) {
+	/* If there is a href, and litehtml is okay with showing a pointer
+	 * cursor ("pointer" or "auto"), set it, otherwise keep the
+	 * default arrow cursor */
+	if ((!strcmp(cursor, "pointer") || !strcmp(cursor, "auto")) &&
+			href != NULL) {
 		cursType = GDK_HAND2;
 	}
 
@@ -333,14 +329,8 @@ void lh_widget::update_cursor(const litehtml::tchar_t* cursor)
 		gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), gdk_cursor_new(cursType));
 	}
 
-	/* If it's an anchor, show its "href" attribute in statusbar,
-	 * otherwise clear statusbar. */
-	if (m_showing_url) {
-		lh_widget_statusbar_pop();
-		m_showing_url = FALSE;
-	}
-
-	if ((href = get_href_at(m_over_element)) != NULL) {
+	/* If there is a href, show it in statusbar */
+	if (href != NULL) {
 		lh_widget_statusbar_push(fullurl(href).c_str());
 		m_showing_url = TRUE;
 	}

commit 6f95b7eeb6e5778ec0be8889041c1a33602ed3c8
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Wed Apr 10 21:12:57 2019 +0200

    Add a getter for litehtml::document's m_over_element member
    
    This allows us to avoid some expensive GDK calls in
    lh_widget::set_cursor().

diff --git a/src/plugins/litehtml_viewer/litehtml/document.h b/src/plugins/litehtml_viewer/litehtml/document.h
index db30793..4484c92 100644
--- a/src/plugins/litehtml_viewer/litehtml/document.h
+++ b/src/plugins/litehtml_viewer/litehtml/document.h
@@ -90,6 +90,7 @@ namespace litehtml
 		bool							on_mouse_leave(position::vector& redraw_boxes);
 		litehtml::element::ptr			create_element(const tchar_t* tag_name, const string_map& attributes);
 		element::ptr					root();
+		const element::ptr					over_element() const;
 		void							get_fixed_boxes(position::vector& fixed_boxes);
 		void							add_fixed_box(const position& pos);
 		void							add_media_list(media_query_list::ptr list);
@@ -115,6 +116,10 @@ namespace litehtml
 	{
 		return m_root;
 	}
+	inline const element::ptr document::over_element() const
+	{
+		return m_over_element;
+	}
 	inline void document::add_tabular(const element::ptr& el)
 	{
 		m_tabular_elements.push_back(el);

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list