[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 02/03: Add option to stay visible when focus is lost. (bug #12240)

noreply at xfce.org noreply at xfce.org
Sun Jul 8 11:52:59 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 f311fbec78685cb58f36443f24155e1c61bcf8d3
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Apr 5 05:50:24 2018 -0400

    Add option to stay visible when focus is lost. (bug #12240)
---
 panel-plugin/configuration-dialog.cpp | 14 ++++++++++++++
 panel-plugin/configuration-dialog.h   |  4 +++-
 panel-plugin/settings.cpp             |  5 ++++-
 panel-plugin/settings.h               |  3 ++-
 panel-plugin/window.cpp               | 15 +++++++++++++++
 5 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index 603fb09..2e0653b 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -266,6 +266,14 @@ void ConfigurationDialog::toggle_position_categories_alternate(GtkToggleButton*
 
 //-----------------------------------------------------------------------------
 
+void ConfigurationDialog::toggle_stay_on_focus_out(GtkToggleButton* button)
+{
+	wm_settings->stay_on_focus_out = gtk_toggle_button_get_active(button);
+	wm_settings->set_modified();
+}
+
+//-----------------------------------------------------------------------------
+
 void ConfigurationDialog::recent_items_max_changed(GtkSpinButton* button)
 {
 	wm_settings->recent_items_max = gtk_spin_button_get_value_as_int(button);
@@ -710,6 +718,12 @@ GtkWidget* ConfigurationDialog::init_behavior_tab()
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_position_categories_alternate), wm_settings->position_categories_alternate);
 	g_signal_connect_slot(m_position_categories_alternate, "toggled", &ConfigurationDialog::toggle_position_categories_alternate, this);
 
+	// Add option to stay when menu loses focus
+	m_stay_on_focus_out = gtk_check_button_new_with_mnemonic(_("Stay _visible when focus is lost"));
+	gtk_box_pack_start(behavior_vbox, m_stay_on_focus_out, true, true, 0);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_stay_on_focus_out), wm_settings->stay_on_focus_out);
+	g_signal_connect_slot(m_stay_on_focus_out, "toggled", &ConfigurationDialog::toggle_stay_on_focus_out, this);
+
 
 	// Create recently used section
 	GtkGrid* recent_table = GTK_GRID(gtk_grid_new());
diff --git a/panel-plugin/configuration-dialog.h b/panel-plugin/configuration-dialog.h
index c5d65fd..0ce5655 100644
--- a/panel-plugin/configuration-dialog.h
+++ b/panel-plugin/configuration-dialog.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015, 2016 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015, 2016, 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
@@ -49,6 +49,7 @@ private:
 	void toggle_position_search_alternate(GtkToggleButton* button);
 	void toggle_position_commands_alternate(GtkToggleButton* button);
 	void toggle_position_categories_alternate(GtkToggleButton* button);
+	void toggle_stay_on_focus_out(GtkToggleButton* button);
 	void category_icon_size_changed(GtkComboBox* combo);
 	void item_icon_size_changed(GtkComboBox* combo);
 
@@ -93,6 +94,7 @@ private:
 	GtkWidget* m_position_search_alternate;
 	GtkWidget* m_position_commands_alternate;
 	GtkWidget* m_position_categories_alternate;
+	GtkWidget* m_stay_on_focus_out;
 	GtkWidget* m_category_icon_size;
 	GtkWidget* m_item_icon_size;
 	GtkWidget* m_background_opacity;
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index 09e8c92..7b0775c 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014, 2015, 2016, 2017 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2014, 2015, 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
@@ -106,6 +106,7 @@ Settings::Settings() :
 	position_search_alternate(false),
 	position_commands_alternate(false),
 	position_categories_alternate(false),
+	stay_on_focus_out(false),
 
 	menu_width(400),
 	menu_height(500),
@@ -191,6 +192,7 @@ void Settings::load(char* file)
 	position_search_alternate = xfce_rc_read_bool_entry(rc, "position-search-alternate", position_search_alternate);
 	position_commands_alternate = xfce_rc_read_bool_entry(rc, "position-commands-alternate", position_commands_alternate) && position_search_alternate;
 	position_categories_alternate = xfce_rc_read_bool_entry(rc, "position-categories-alternate", position_categories_alternate);
+	stay_on_focus_out = xfce_rc_read_bool_entry(rc, "stay-on-focus-out", stay_on_focus_out);
 
 	menu_width = std::max(10, xfce_rc_read_int_entry(rc, "menu-width", menu_width));
 	menu_height = std::max(10, xfce_rc_read_int_entry(rc, "menu-height", menu_height));
@@ -289,6 +291,7 @@ void Settings::save(char* file)
 	xfce_rc_write_bool_entry(rc, "position-search-alternate", position_search_alternate);
 	xfce_rc_write_bool_entry(rc, "position-commands-alternate", position_commands_alternate);
 	xfce_rc_write_bool_entry(rc, "position-categories-alternate", position_categories_alternate);
+	xfce_rc_write_bool_entry(rc, "stay-on-focus-out", stay_on_focus_out);
 
 	xfce_rc_write_int_entry(rc, "menu-width", menu_width);
 	xfce_rc_write_int_entry(rc, "menu-height", menu_height);
diff --git a/panel-plugin/settings.h b/panel-plugin/settings.h
index 46d934d..7b9e2ce 100644
--- a/panel-plugin/settings.h
+++ b/panel-plugin/settings.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014, 2016 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2014, 2016, 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
@@ -83,6 +83,7 @@ public:
 	bool position_search_alternate;
 	bool position_commands_alternate;
 	bool position_categories_alternate;
+	bool stay_on_focus_out;
 
 	enum Commands
 	{
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index f222672..2f5e1bf 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -42,6 +42,11 @@ using namespace WhiskerMenu;
 
 static void grab_pointer(GtkWidget* widget)
 {
+	if (wm_settings->stay_on_focus_out)
+	{
+		return;
+	}
+
 	GdkDisplay* display = gdk_display_get_default();
 	GdkSeat* seat = gdk_display_get_default_seat(display);
 	GdkWindow* window = gtk_widget_get_window(widget);
@@ -50,6 +55,11 @@ static void grab_pointer(GtkWidget* widget)
 
 static void ungrab_pointer()
 {
+	if (wm_settings->stay_on_focus_out)
+	{
+		return;
+	}
+
 	GdkDisplay* display = gdk_display_get_default();
 	GdkSeat* seat = gdk_display_get_default_seat(display);
 	gdk_seat_ungrab(seat);
@@ -737,6 +747,11 @@ gboolean WhiskerMenu::Window::on_leave_notify_event(GtkWidget*, GdkEvent* event)
 
 gboolean WhiskerMenu::Window::on_button_press_event(GtkWidget*, GdkEvent* event)
 {
+	if (wm_settings->stay_on_focus_out)
+	{
+		return false;
+	}
+
 	// Hide menu if user clicks outside
 	GdkEventButton* button_event = reinterpret_cast<GdkEventButton*>(event);
 	if ((button_event->x_root <= m_geometry.x)

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


More information about the Xfce4-commits mailing list