[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 09/09: Require GTK+ version 3.22.

noreply at xfce.org noreply at xfce.org
Sun Apr 15 01:13:28 CEST 2018


This is an automated email from the git hooks/post-receive script.

g   o   t   t   c   o   d   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 8c008dc5ff5b2e5dc5f2324ba2f5608fb84efac5
Author: Graeme Gott <graeme at gottcode.org>
Date:   Mon Apr 2 10:36:09 2018 -0400

    Require GTK+ version 3.22.
---
 panel-plugin/CMakeLists.txt     |  2 +-
 panel-plugin/page.cpp           | 39 --------------------------------
 panel-plugin/page.h             |  3 +--
 panel-plugin/plugin.cpp         | 50 -----------------------------------------
 panel-plugin/section-button.cpp |  6 +----
 panel-plugin/window.cpp         | 48 +++++----------------------------------
 6 files changed, 9 insertions(+), 139 deletions(-)

diff --git a/panel-plugin/CMakeLists.txt b/panel-plugin/CMakeLists.txt
index e7dee4e..d0825bd 100644
--- a/panel-plugin/CMakeLists.txt
+++ b/panel-plugin/CMakeLists.txt
@@ -13,7 +13,7 @@ if(ENABLE_LINKER_OPTIMIZED_HASH_TABLES)
 endif()
 
 find_package(PkgConfig REQUIRED)
-pkg_check_modules(GTK3 REQUIRED gtk+-3.0>=3.12)
+pkg_check_modules(GTK3 REQUIRED gtk+-3.0>=3.22)
 pkg_check_modules(exo REQUIRED exo-2>=0.11)
 pkg_check_modules(garcon REQUIRED garcon-1)
 pkg_check_modules(libxfce4panel REQUIRED libxfce4panel-2.0>=4.11)
diff --git a/panel-plugin/page.cpp b/panel-plugin/page.cpp
index d73ec7b..32cb845 100644
--- a/panel-plugin/page.cpp
+++ b/panel-plugin/page.cpp
@@ -276,26 +276,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 	// Show context menu
 	gtk_tree_view_set_hover_selection(GTK_TREE_VIEW(m_view->get_widget()), false);
 	gtk_menu_attach_to_widget(GTK_MENU(menu), m_view->get_widget(), NULL);
-#if GTK_CHECK_VERSION(3,22,0)
 	gtk_menu_popup_at_pointer(GTK_MENU(menu), event);
-#else
-	int button = 0;
-	int event_time;
-	GtkMenuPositionFunc position_func = NULL;
-	if (event)
-	{
-		GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event);
-		button = event_button->button;
-		event_time = event_button->time;
-	}
-	else
-	{
-		position_func = (GtkMenuPositionFunc)&Page::position_context_menu;
-		event_time = gtk_get_current_event_time ();
-	}
-
-	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, position_func, this, button, event_time);
-#endif
 }
 
 //-----------------------------------------------------------------------------
@@ -322,26 +303,6 @@ void Page::extend_context_menu(GtkWidget*)
 
 //-----------------------------------------------------------------------------
 
-void Page::position_context_menu(GtkMenu*, gint* x, gint* y, gboolean* push_in, Page* page)
-{
-	// Find rectangle of selected row
-	GtkTreeView* treeview = GTK_TREE_VIEW(page->m_view->get_widget());
-	GdkRectangle rect;
-	GtkTreeViewColumn* column = gtk_tree_view_get_column(treeview, 0);
-	gtk_tree_view_get_cell_area(treeview, page->m_selected_path, column, &rect);
-
-	int root_x;
-	int root_y;
-	gdk_window_get_root_coords(gtk_tree_view_get_bin_window(treeview), rect.x, rect.y, &root_x, &root_y);
-
-	// Position context menu centered on row
-	*push_in = false;
-	*x = root_x + (rect.width >> 2);
-	*y = root_y + (rect.height >> 1);
-}
-
-//-----------------------------------------------------------------------------
-
 void Page::add_selected_to_desktop()
 {
 	// Fetch desktop folder
diff --git a/panel-plugin/page.h b/panel-plugin/page.h
index a32352c..5ec3984 100644
--- a/panel-plugin/page.h
+++ b/panel-plugin/page.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2017 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2017, 2018 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -68,7 +68,6 @@ private:
 	Launcher* get_selected_launcher() const;
 	void create_context_menu(GtkTreeIter* iter, GdkEvent* event);
 	virtual void extend_context_menu(GtkWidget* menu);
-	static void position_context_menu(GtkMenu*, gint* x, gint* y, gboolean* push_in, Page* page);
 
 private:
 	Window* m_window;
diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index 0a84cf4..bc673a9 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -53,7 +53,6 @@ static bool panel_utils_grab_available()
 
 	GdkWindow* root = gdk_screen_get_root_window(xfce_gdk_screen_get_active(NULL));
 	GdkDisplay* display = gdk_display_get_default();
-#if GTK_CHECK_VERSION(3,20,0)
 	GdkSeat* seat = gdk_display_get_default_seat(display);
 
 	// Don't try to get the grab for longer then 1/4 second
@@ -67,51 +66,6 @@ static bool panel_utils_grab_available()
 		}
 		g_usleep(100);
 	}
-#else
-	GdkDeviceManager* device_manager = gdk_display_get_device_manager(display);
-	GdkDevice* pointer = gdk_device_manager_get_client_pointer(device_manager);
-	GdkDevice* keyboard = gdk_device_get_associated_device(pointer);
-
-	// Don't try to get the grab for longer then 1/4 second
-	GdkGrabStatus grab_pointer = GDK_GRAB_FROZEN;
-	GdkGrabStatus grab_keyboard = GDK_GRAB_FROZEN;
-	for (guint i = 0; i < (G_USEC_PER_SEC / 400); ++i)
-	{
-		grab_keyboard = gdk_device_grab(keyboard,
-				root,
-				GDK_OWNERSHIP_NONE,
-				true,
-				GDK_ALL_EVENTS_MASK,
-				NULL,
-				GDK_CURRENT_TIME);
-		if (grab_keyboard == GDK_GRAB_SUCCESS)
-		{
-			grab_pointer = gdk_device_grab(pointer,
-					root,
-					GDK_OWNERSHIP_NONE,
-					true,
-					GDK_ALL_EVENTS_MASK,
-					NULL,
-					GDK_CURRENT_TIME);
-			if (grab_pointer == GDK_GRAB_SUCCESS)
-			{
-				grab_succeed = true;
-				break;
-			}
-		}
-		g_usleep(100);
-	}
-
-	// Release the grab so the menu window can take it
-	if (grab_pointer == GDK_GRAB_SUCCESS)
-	{
-		gdk_device_ungrab(pointer, GDK_CURRENT_TIME);
-	}
-	if (grab_keyboard == GDK_GRAB_SUCCESS)
-	{
-		gdk_device_ungrab(keyboard, GDK_CURRENT_TIME);
-	}
-#endif
 
 	if (!grab_succeed)
 	{
@@ -164,11 +118,7 @@ Plugin::Plugin(XfcePanelPlugin* plugin) :
 #if !LIBXFCE4PANEL_CHECK_VERSION(4,13,0)
 	widget_add_css(m_button, ".xfce4-panel button { padding: 1px; }");
 	gtk_button_set_relief(GTK_BUTTON(m_button), GTK_RELIEF_NONE);
-#if GTK_CHECK_VERSION(3,20,0)
 	gtk_widget_set_focus_on_click(GTK_WIDGET(m_button), false);
-#else
-	gtk_button_set_focus_on_click(GTK_BUTTON(m_button), false);
-#endif
 #endif
 	g_signal_connect_slot(m_button, "toggled", &Plugin::button_toggled, this);
 	gtk_widget_show(m_button);
diff --git a/panel-plugin/section-button.cpp b/panel-plugin/section-button.cpp
index 8f073ea..dff5c56 100644
--- a/panel-plugin/section-button.cpp
+++ b/panel-plugin/section-button.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2016, 2017 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2016, 2017, 2018 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,11 +52,7 @@ SectionButton::SectionButton(const gchar* icon, const gchar* text) :
 	gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(m_button), false);
 	gtk_button_set_relief(GTK_BUTTON(m_button), GTK_RELIEF_NONE);
 	gtk_widget_set_tooltip_text(GTK_WIDGET(m_button), text);
-#if GTK_CHECK_VERSION(3,20,0)
 	gtk_widget_set_focus_on_click(GTK_WIDGET(m_button), false);
-#else
-	gtk_button_set_focus_on_click(GTK_BUTTON(m_button), false);
-#endif
 	g_signal_connect(m_button, "enter-notify-event", G_CALLBACK(on_enter_notify_event), GTK_TOGGLE_BUTTON(m_button));
 
 	m_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4));
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index c51bae1..b691e51 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -40,12 +40,11 @@ using namespace WhiskerMenu;
 
 //-----------------------------------------------------------------------------
 
-#if GTK_CHECK_VERSION(3,20,0)
-
-static void grab_pointer(GdkWindow* window, guint32)
+static void grab_pointer(GtkWidget* widget)
 {
 	GdkDisplay* display = gdk_display_get_default();
 	GdkSeat* seat = gdk_display_get_default_seat(display);
+	GdkWindow* window = gtk_widget_get_window(widget);
 	gdk_seat_grab(seat, window, GDK_SEAT_CAPABILITY_ALL_POINTING, true, NULL, NULL, NULL, NULL);
 }
 
@@ -56,31 +55,6 @@ static void ungrab_pointer()
 	gdk_seat_ungrab(seat);
 }
 
-#else
-
-static void grab_pointer(GdkWindow* window, guint32 time)
-{
-	GdkDisplay* display = gdk_display_get_default();
-	GdkDeviceManager* device_manager = gdk_display_get_device_manager(display);
-	GdkDevice* device = gdk_device_manager_get_client_pointer(device_manager);
-	gdk_device_grab(device, window, GDK_OWNERSHIP_NONE, true,
-		GdkEventMask(
-			GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
-			GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK
-		),
-		NULL, time);
-}
-
-static void ungrab_pointer()
-{
-	GdkDisplay* display = gdk_display_get_default();
-	GdkDeviceManager* device_manager = gdk_display_get_device_manager(display);
-	GdkDevice* device = gdk_device_manager_get_client_pointer(device_manager);
-	gdk_device_ungrab(device, gtk_get_current_event_time());
-}
-
-#endif
-
 //-----------------------------------------------------------------------------
 
 WhiskerMenu::Window::Window(Plugin* plugin) :
@@ -417,25 +391,15 @@ void WhiskerMenu::Window::show(const Position position)
 	else
 	{
 		GdkDisplay* display = gdk_display_get_default();
-#if GTK_CHECK_VERSION(3,20,0)
 		GdkSeat* seat = gdk_display_get_default_seat(display);
 		GdkDevice* device = gdk_seat_get_pointer(seat);
-#else
-		GdkDeviceManager* device_manager = gdk_display_get_device_manager(display);
-		GdkDevice* device = gdk_device_manager_get_client_pointer(device_manager);
-#endif
 		gdk_device_get_position(device, &screen, &parent_x, &parent_y);
 	}
 
 	// Fetch screen geomtry
 	GdkRectangle monitor;
-#if GTK_CHECK_VERSION(3,22,0)
 	GdkMonitor* monitor_gdk = gdk_display_get_monitor_at_point(gdk_display_get_default(), parent_x, parent_y);
 	gdk_monitor_get_geometry(monitor_gdk, &monitor);
-#else
-	int monitor_num = gdk_screen_get_monitor_at_point(screen, parent_x, parent_y);
-	gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor);
-#endif
 
 	// Prevent window from being larger than screen
 	if (m_geometry.width > monitor.width)
@@ -677,7 +641,7 @@ void WhiskerMenu::Window::save()
 
 void WhiskerMenu::Window::on_context_menu_destroyed()
 {
-	grab_pointer(gtk_widget_get_window(GTK_WIDGET(m_window)), gtk_get_current_event_time());
+	grab_pointer(GTK_WIDGET(m_window));
 }
 
 //-----------------------------------------------------------------------------
@@ -743,7 +707,7 @@ gboolean WhiskerMenu::Window::on_enter_notify_event(GtkWidget*, GdkEvent* event)
 		return false;
 	}
 
-	grab_pointer(gtk_widget_get_window(GTK_WIDGET(m_window)), crossing_event->time);
+	grab_pointer(GTK_WIDGET(m_window));
 
 	return false;
 }
@@ -759,7 +723,7 @@ gboolean WhiskerMenu::Window::on_leave_notify_event(GtkWidget*, GdkEvent* event)
 		return false;
 	}
 
-	grab_pointer(gtk_widget_get_window(GTK_WIDGET(m_window)), crossing_event->time);
+	grab_pointer(GTK_WIDGET(m_window));
 
 	return false;
 }
@@ -864,7 +828,7 @@ gboolean WhiskerMenu::Window::on_map_event(GtkWidget*, GdkEvent*)
 	gtk_window_set_keep_above(m_window, true);
 
 	// Track mouse clicks outside of menu
-	grab_pointer(gtk_widget_get_window(GTK_WIDGET(m_window)), gtk_get_current_event_time());
+	grab_pointer(GTK_WIDGET(m_window));
 
 	// Focus search entry
 	gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list