Package: icewm
Version: 2.1.2-1
Severity: normal
Tags: patch

Dear Maintainer,

A patch in upstream icewm 2.1.0 broke the behaviour of switching windows in the
order they appear on the taskbar.  This can be done by scrolling the mouse
wheel over the taskbar or with configuring special shortcuts.
At first this works but as soon as buttons are moved (e.g. by dragging) the
order becomes chaotic.

The Debian testing/unstable version of icewm 2.1.2 includes this problem.
That's a regression since current stable.
I reported the problem upstream: https://github.com/bbidulock/icewm/issues/602
It has now been fixed upstream by commit c16c44e936856bcebf11c8fd36028119c021e0
The patch applies nicely to 2.1.2

Could you please include this patch in the Debian package?

Thank you!


-- System Information:
Debian Release: 10.9
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-16-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=C (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
commit c16c44e936856bcebf11c8fd36028119c021e0cc
Author: Bert Gijsbers <gijsb...@science.uva.nl>
Date:   Thu Jul 15 21:36:20 2021 +0200

    Rewrite task successor and task predecessor to properly take into account 
the
    separation of TaskBarApp and TaskButton as well as task grouping.
    Resolves #602, resolves #604.

    [rediffed against 2.1.2 by Jiri Bohac]

diff --git a/src/atasks.cc b/src/atasks.cc
index fe5405e9..b47fe05a 100644
--- a/src/atasks.cc
+++ b/src/atasks.cc
@@ -125,6 +125,38 @@ void TaskButton::remove(TaskBarApp* tapp) {
     }
 }
 
+TaskBarApp* TaskButton::getNextShown(TaskBarApp* tapp) const {
+    if (grouping()) {
+        int k = tapp ? find(fGroup, tapp) : -1;
+        if (k >= 0 || tapp == nullptr) {
+            while (++k < fGroup.getCount()) {
+                if (fGroup[k]->getShown()) {
+                    return fGroup[k];
+                }
+            }
+        }
+    } else if (tapp == nullptr) {
+        return fActive;
+    }
+    return nullptr;
+}
+
+TaskBarApp* TaskButton::getPrevShown(TaskBarApp* tapp) const {
+    if (grouping()) {
+        int k = tapp ? find(fGroup, tapp) : fGroup.getCount();
+        if (k > 0) {
+            while (--k >= 0) {
+                if (fGroup[k]->getShown()) {
+                    return fGroup[k];
+                }
+            }
+        }
+    } else if (tapp == nullptr) {
+        return fActive;
+    }
+    return nullptr;
+}
+
 void TaskButton::setShown(TaskBarApp* tapp, bool ashow) {
     if (tapp == fActive) {
         if (ashow != visible())
@@ -562,28 +594,46 @@ void TaskPane::insert(TaskBarApp* tapp) {
 }
 
 TaskBarApp* TaskPane::predecessor(TaskBarApp* tapp) {
-    const int count = fApps.getCount();
-    const int found = find(fApps, tapp);
-    if (found >= 0) {
-        for (int i = count - 1; 1 <= i; --i) {
-            int k = (found + i) % count;
-            if (fApps[k]->getShown()) {
-                return fApps[k];
-            }
+    TaskButton* button = tapp->button();
+    TaskBarApp* prev = button->getPrevShown(tapp);
+    if (prev && button->getShown()) {
+        return prev;
+    } else {
+        int k = find(fTasks, button);
+        if (k >= 0) {
+            int i = k;
+            do {
+                i = (i - 1 + fTasks.getCount()) % fTasks.getCount();
+                if (fTasks[i]->getShown()) {
+                    prev = fTasks[i]->getPrevShown(nullptr);
+                    if (prev && prev != tapp) {
+                        return prev;
+                    }
+                }
+            } while (i != k);
         }
     }
     return nullptr;
 }
 
 TaskBarApp* TaskPane::successor(TaskBarApp* tapp) {
-    const int count = fApps.getCount();
-    const int found = find(fApps, tapp);
-    if (found >= 0) {
-        for (int i = 1; i < count; ++i) {
-            int k = (found + i) % count;
-            if (fApps[k]->getShown()) {
-                return fApps[k];
-            }
+    TaskButton* button = tapp->button();
+    TaskBarApp* next = button->getNextShown(tapp);
+    if (next && button->getShown()) {
+        return next;
+    } else {
+        int k = find(fTasks, button);
+        if (k >= 0) {
+            int i = k;
+            do {
+                i = (i + 1) % fTasks.getCount();
+                if (fTasks[i]->getShown()) {
+                    next = fTasks[i]->getNextShown(nullptr);
+                    if (next && next != tapp) {
+                        return next;
+                    }
+                }
+            } while (i != k);
         }
     }
     return nullptr;
diff --git a/src/atasks.h b/src/atasks.h
index 14553e7b..769d2f1d 100644
--- a/src/atasks.h
+++ b/src/atasks.h
@@ -61,6 +61,8 @@ public:
     int getOrder() const;
     int getCount() const;
 
+    TaskBarApp* getNextShown(TaskBarApp* tapp) const;
+    TaskBarApp* getPrevShown(TaskBarApp* tapp) const;
     TaskBarApp* getActive() const { return fActive; }
     ClientData* getFrame() const { return fActive->getFrame(); }
     TaskPane* taskPane() const { return fTaskPane; }

Reply via email to