lxpanel: fix several issues via upstream patches for trisquel-mini

This commit is contained in:
Ark74 2025-07-14 01:44:23 -06:00
parent 410f35b19e
commit 5b65330e61
6 changed files with 429 additions and 0 deletions

View file

@ -0,0 +1,72 @@
From 44df20a33645b4a645b547725c75904cee46dfba Mon Sep 17 00:00:00 2001
From: Nicolas Salguero <nicolas.salguero@laposte.net>
Date: Thu, 21 Jul 2022 12:54:07 +0200
Subject: [PATCH 1/2] Fix a scrolling issue with the GTK3 volume plugin
Scrolling with the mouse wheel in the volume plugin window only reduces
the volume, because the GDK_SCROLL_SMOOTH direction is not taken into
account.
This fixes github issue #27, reported by martenwa,
part of github issue #45, reported by nsalguero, and
part of https://bugs.debian.org/1052050.
(commit and message amended by committer)
---
plugins/volumealsa/volumealsa.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/plugins/volumealsa/volumealsa.c b/plugins/volumealsa/volumealsa.c
index 5c410511..74b49f90 100644
--- a/plugins/volumealsa/volumealsa.c
+++ b/plugins/volumealsa/volumealsa.c
@@ -796,6 +796,17 @@ static void volumealsa_popup_scale_scrolled(GtkScale * scale, GdkEventScroll * e
/* Dispatch on scroll direction to update the value. */
if ((evt->direction == GDK_SCROLL_UP) || (evt->direction == GDK_SCROLL_LEFT))
val += 2;
+#if GTK_CHECK_VERSION(3, 4, 0)
+ else if (evt->direction == GDK_SCROLL_SMOOTH)
+ {
+ gdouble delta_x, delta_y;
+ gdk_event_get_scroll_deltas((GdkEvent *) evt, &delta_x, &delta_y);
+ if ((delta_y < 0) || (delta_x < 0))
+ val += 2;
+ else
+ val -= 2;
+ }
+#endif
else
val -= 2;
From a9c1c58558ec066b6e086230abcf70c7793583c8 Mon Sep 17 00:00:00 2001
From: Nicolas Salguero <nicolas.salguero@laposte.net>
Date: Thu, 21 Jul 2022 12:54:07 +0200
Subject: [PATCH 2/2] Fix a scrolling issue with the GTK3 volume plugin
Scrolling with the mouse wheel on the volume plugin icon does nothing
because GDK_SCROLL events are missing. To receive these events, widgets
must set either GDK_SCROLL_MASK or GDK_SMOOTH_SCROLL_MASK.
This fixes part of github issue #45, reported by nsalguero,
and part of https://bugs.debian.org/1052050.
(commit and message amended by committer)
---
plugins/volumealsa/volumealsa.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugins/volumealsa/volumealsa.c b/plugins/volumealsa/volumealsa.c
index 74b49f90..13693773 100644
--- a/plugins/volumealsa/volumealsa.c
+++ b/plugins/volumealsa/volumealsa.c
@@ -991,6 +991,9 @@ static GtkWidget *volumealsa_constructor(LXPanel *panel, config_setting_t *setti
vol->tray_icon = lxpanel_image_new_for_icon(panel, "audio-volume-muted-panel",
-1, ICONS_MUTE);
gtk_container_add(GTK_CONTAINER(p), vol->tray_icon);
+#if GTK_CHECK_VERSION(3, 4, 0)
+ gtk_widget_add_events(p, GDK_SCROLL_MASK);
+#endif
/* Initialize window to appear when icon clicked. */
volumealsa_build_popup_window(p);

View file

@ -0,0 +1,28 @@
From 0995ca8ee2b7cbd768921b0a4e2f88a98af09c92 Mon Sep 17 00:00:00 2001
From: Mikau <mikau@aaathats3as.com>
Date: Mon, 17 Apr 2023 16:37:10 +0200
Subject: [PATCH] Handle "Not Charging" state in battery indicator
When the battery has reached the target charge level, some devices
use the status "Not Charging". LXpanel should not interpret this to mean
"Discharging", but rather the same as "Full".
This is also likely to fix github issue #50, reported by embedeo.
(commit message amended by committer)
---
plugins/batt/batt_sys.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/batt/batt_sys.c b/plugins/batt/batt_sys.c
index 5a40273e..eb807a3c 100644
--- a/plugins/batt/batt_sys.c
+++ b/plugins/batt/batt_sys.c
@@ -396,6 +396,7 @@ gboolean battery_is_charging( battery *b )
return ( strcasecmp( b->state, "Unknown" ) == 0
|| strcasecmp( b->state, "Full" ) == 0
|| strcasecmp( b->state, "Charging" ) == 0
+ || strcasecmp( b->state, "Not Charging" ) == 0
|| b->current_now == 0 ); /* bug sf.net, #720 */
}

View file

@ -0,0 +1,28 @@
From 8b2d1ead714529f3abe00fff282607a4f9eb47b7 Mon Sep 17 00:00:00 2001
From: kurokawachan <kurokawapopochan@gmail.com>
Date: Fri, 23 Aug 2024 04:11:55 -0700
Subject: [PATCH] Do not trigger wincmd_button_clicked() by GDK_2BUTTON_PRESS
events
If the toggle is clicked too quickly, it is considered a double-click
and three button-press events are generated instead of the usual two,
resulting in unwanted behavior.
This fixes https://github.com/lxde/lxpanel/issues/77.
---
plugins/wincmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/wincmd.c b/plugins/wincmd.c
index 9b4ae48e..ae8db997 100644
--- a/plugins/wincmd.c
+++ b/plugins/wincmd.c
@@ -124,7 +124,7 @@ static gboolean wincmd_button_clicked(GtkWidget * widget, GdkEventButton * event
WinCmdPlugin * wc = lxpanel_plugin_get_data(widget);
/* Left-click to iconify. */
- if (event->button == 1)
+ if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
{
GdkScreen* screen = gtk_widget_get_screen(widget);
Screen *xscreen = GDK_SCREEN_XSCREEN(screen);

View file

@ -0,0 +1,27 @@
From 8b1135b857eb684296013c92487532a903039102 Mon Sep 17 00:00:00 2001
From: kurokawachan <kurokawapopochan@gmail.com>
Date: Sat, 21 Sep 2024 20:16:48 -0700
Subject: [PATCH] Pop down a menu before detaching it
If we detach a GtkMenu while it is still being displayed,
it will freeze the entire panel.
This fixes github issue #83, reported by make-your-soft-better.
(commit message slightly amended by committer)
---
plugins/task-button.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/task-button.c b/plugins/task-button.c
index 3744cc79..f90da5c8 100644
--- a/plugins/task-button.c
+++ b/plugins/task-button.c
@@ -1544,6 +1544,7 @@ void task_button_update_windows_list(TaskButton *button, Window *list, gint n)
for (l = menu_list; l; l = l->next)
{
GtkMenu *menu = GTK_MENU(l->data);
+ gtk_menu_popdown(menu);
gtk_menu_detach(menu);
}
g_list_free(menu_list);

View file

@ -0,0 +1,237 @@
From dfa4708213c65b734b0d724de8290d4da3ba5af4 Mon Sep 17 00:00:00 2001
From: rofl0r <rofl0r@users.noreply.github.com>
Date: Wed, 12 Mar 2025 00:35:15 +0000
Subject: [PATCH 1/4] Restore disabled cpufreq plugin functionality
According to the comment used, this was apparently disabled because
someone thought that changing CPU governors requires root permissions,
but that can be easily changed using a rc script running on system
start.
Probably the most sensible setup to modify the governors from a
restricted user account is to add it to a dedicated group with
write access to the corresponding sysfs files.
For instance:
for i in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor \
/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_setspeed ; do
chown root:cpufreq "$i"
chmod 664 "$i"
done
---
plugins/cpufreq/cpufreq.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/plugins/cpufreq/cpufreq.c b/plugins/cpufreq/cpufreq.c
index 05f41e0d..24e819ea 100644
--- a/plugins/cpufreq/cpufreq.c
+++ b/plugins/cpufreq/cpufreq.c
@@ -99,7 +99,7 @@ get_cur_freq(cpufreq *cf){
}
}
-/*static void
+static void
get_governors(cpufreq *cf){
FILE *fp;
GList *l;
@@ -189,7 +189,7 @@ frequency_menu(cpufreq *cf){
fclose(fp);
return GTK_WIDGET(menu);
-}*/
+}
static void
get_cpus(cpufreq *cf)
@@ -228,7 +228,7 @@ get_cpus(cpufreq *cf)
g_dir_close(cpuDirectory);
}
-/*static void
+static void
cpufreq_set_governor(GtkWidget *widget, Param* p){
FILE *fp;
char buf[ 100 ], sstmp [ 256 ];
@@ -291,7 +291,7 @@ cpufreq_menu(cpufreq *cf){
}
return GTK_WIDGET (menu);
-}*/
+}
@@ -303,9 +303,9 @@ clicked(GtkWidget *widget, GdkEventButton *evt, LXPanel *panel)
/* Standard right-click handling. */
if( evt->button == 1 )
{
-// Setting governor can't work without root privilege
-// gtk_menu_popup( cpufreq_menu((cpufreq*)plugin->priv), NULL, NULL, NULL, NULL,
-// evt->button, evt->time );
+ cpufreq *cf = lxpanel_plugin_get_data(widget);
+ gtk_menu_popup( GTK_MENU(cpufreq_menu(cf)), NULL, NULL, NULL, NULL,
+ evt->button, evt->time );
return TRUE;
}
From 6c35362e69030f6e1bd360f1d8d8171135943c85 Mon Sep 17 00:00:00 2001
From: rofl0r <rofl0r@users.noreply.github.com>
Date: Wed, 12 Mar 2025 09:57:01 +0000
Subject: [PATCH 2/4] Factor out identical code in cpufreq_set_gov/frequency
---
plugins/cpufreq/cpufreq.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/plugins/cpufreq/cpufreq.c b/plugins/cpufreq/cpufreq.c
index 24e819ea..48ff25d0 100644
--- a/plugins/cpufreq/cpufreq.c
+++ b/plugins/cpufreq/cpufreq.c
@@ -138,19 +138,34 @@ get_governors(cpufreq *cf){
}
static void
-cpufreq_set_freq(GtkWidget *widget, Param* p){
+set_file(const char* cpu, const char* val, const char* file) {
FILE *fp;
- char buf[ 100 ], sstmp [ 256 ];
+ char path [ 256 ];
- if(strcmp(p->cf->cur_governor, "userspace")) return;
+ snprintf(path, sizeof(path), "%s/%s", cpu, file);
- sprintf(sstmp,"%s/%s",p->cf->cpus->data, SCALING_SETFREQ);
- if ((fp = fopen( sstmp, "w")) != NULL) {
- fprintf(fp,"%s",p->data);
+ if ((fp = fopen( path, "w")) != NULL) {
+ fprintf(fp,"%s",val);
fclose(fp);
}
}
+static void
+set_freq(const char* cpu, const char* val) {
+ set_file(cpu, val, SCALING_SETFREQ);
+}
+
+static void
+set_gov(const char* cpu, const char* val) {
+ set_file(cpu, val, SCALING_GOV);
+}
+
+static void
+cpufreq_set_freq(GtkWidget *widget, Param* p){
+ if(strcmp(p->cf->cur_governor, "userspace")) return;
+ set_freq(p->cf->cpus->data, p->data);
+}
+
static GtkWidget *
frequency_menu(cpufreq *cf){
FILE *fp;
@@ -230,14 +245,7 @@ get_cpus(cpufreq *cf)
static void
cpufreq_set_governor(GtkWidget *widget, Param* p){
- FILE *fp;
- char buf[ 100 ], sstmp [ 256 ];
-
- sprintf(sstmp, "%s/%s", p->cf->cpus->data, SCALING_GOV);
- if ((fp = fopen( sstmp, "w")) != NULL) {
- fprintf(fp,"%s",p->data);
- fclose(fp);
- }
+ set_gov(p->cf->cpus->data, p->data);
}
static GtkWidget *
From c0831241f801f321ddfd48f7acc1e61574640a38 Mon Sep 17 00:00:00 2001
From: rofl0r <rofl0r@users.noreply.github.com>
Date: Wed, 12 Mar 2025 10:00:20 +0000
Subject: [PATCH 3/4] Apply chosen governor/frequency to all CPUs
Previously, governor and frequency were only changed for the
first CPU/core in the system, but all others were left untouched.
A user changing those generally wants the setting applied
to all cores (for example to powersave governor if on battery).
---
plugins/cpufreq/cpufreq.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/plugins/cpufreq/cpufreq.c b/plugins/cpufreq/cpufreq.c
index 48ff25d0..9c194ca0 100644
--- a/plugins/cpufreq/cpufreq.c
+++ b/plugins/cpufreq/cpufreq.c
@@ -162,8 +162,12 @@ set_gov(const char* cpu, const char* val) {
static void
cpufreq_set_freq(GtkWidget *widget, Param* p){
+ GList *curr;
+
if(strcmp(p->cf->cur_governor, "userspace")) return;
- set_freq(p->cf->cpus->data, p->data);
+
+ for(curr = p->cf->cpus; curr; curr = curr->next)
+ set_freq(curr->data, p->data);
}
static GtkWidget *
@@ -245,7 +249,10 @@ get_cpus(cpufreq *cf)
static void
cpufreq_set_governor(GtkWidget *widget, Param* p){
- set_gov(p->cf->cpus->data, p->data);
+ GList *curr;
+
+ for(curr = p->cf->cpus; curr; curr = curr->next)
+ set_gov(curr->data, p->data);
}
static GtkWidget *
From e8db3d47a308e43c44e0b036fa66df448a246e51 Mon Sep 17 00:00:00 2001
From: rofl0r <rofl0r@users.noreply.github.com>
Date: Fri, 14 Mar 2025 07:23:20 +0000
Subject: [PATCH 4/4] Cosmetic change: move cpufreq_set_governor up
---
plugins/cpufreq/cpufreq.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/plugins/cpufreq/cpufreq.c b/plugins/cpufreq/cpufreq.c
index 9c194ca0..9e1bb0f1 100644
--- a/plugins/cpufreq/cpufreq.c
+++ b/plugins/cpufreq/cpufreq.c
@@ -170,6 +170,14 @@ cpufreq_set_freq(GtkWidget *widget, Param* p){
set_freq(curr->data, p->data);
}
+static void
+cpufreq_set_governor(GtkWidget *widget, Param* p) {
+ GList *curr;
+
+ for(curr = p->cf->cpus; curr; curr = curr->next)
+ set_gov(curr->data, p->data);
+}
+
static GtkWidget *
frequency_menu(cpufreq *cf){
FILE *fp;
@@ -247,14 +255,6 @@ get_cpus(cpufreq *cf)
g_dir_close(cpuDirectory);
}
-static void
-cpufreq_set_governor(GtkWidget *widget, Param* p){
- GList *curr;
-
- for(curr = p->cf->cpus; curr; curr = curr->next)
- set_gov(curr->data, p->data);
-}
-
static GtkWidget *
cpufreq_menu(cpufreq *cf){
GList *l;