FVWM: FvwmIconMan patch for sort by app_id

From: Greg Klanderman <greg_at_alphatech.com>
Date: Thu, 11 Dec 1997 20:35:08 -0500

Hi,

If you don't sort the IconMan buttons, the order ends up changing as
you switch back and forth between different desks, and this is highly
irritating. This is presumably because the module gets the window
messages from fvwm in different orders. This patch adds a new option,
sortbyappid of type boolean which changes the sort to sort by the
application id, roughly equivalent to order of window creation as twm
does, rather than by the button name.

Eg, you might use

*FvwmIconMan*sortbyappid true

to set this behavior. It is false by default.

Patch follows.

Greg


--- /local/mstar/software/fvwm/.backups/!local!mstar!software!fvwm!fvwm-2.0.46!modules!FvwmIconMan!FvwmIconMan.h.~1~ Wed Jul 16 21:31:22 1997
+++ FvwmIconMan.h Thu Dec 11 20:11:22 1997
_at_@ -286,6 +286,7 @@
   Uchar followFocus;
   Uchar usewinlist;
   Uchar sort;
+ Uchar sort_by_appid;
 
   /* X11 state */
   Window theWindow, theFrame;
--- /local/mstar/software/fvwm/.backups/!local!mstar!software!fvwm!fvwm-2.0.46!modules!FvwmIconMan!globals.c.~1~ Wed Jul 16 21:31:21 1997
+++ globals.c Thu Dec 11 20:12:43 1997
_at_@ -69,6 +69,7 @@
   globals.managers[id].followFocus = 0;
   globals.managers[id].usewinlist = 1;
   globals.managers[id].sort = 1;
+ globals.managers[id].sort_by_appid = 0;
   globals.managers[id].focus_button = NULL;
   globals.managers[id].select_button = NULL;
   globals.managers[id].bindings[MOUSE] = ParseMouseEntry (DEFAULT_MOUSE);
--- /local/mstar/software/fvwm/.backups/!local!mstar!software!fvwm!fvwm-2.0.46!modules!FvwmIconMan!readconfig.c.~1~ Wed Jul 16 21:31:21 1997
+++ readconfig.c Thu Dec 11 20:14:40 1997
_at_@ -1584,6 +1584,27 @@
         ConsoleDebug (CONFIG, "Setting sort to: %d\n", i);
         SET_MANAGER (manager, sort, i);
       }
+ else if (!strcasecmp (option1, "sortbyappid")) {
+ p = read_next_cmd (READ_ARG);
+ if (!p) {
+ ConsoleMessage ("Bad line: %s\n", current_line);
+ ConsoleMessage ("Need argument to sortbyappid\n");
+ continue;
+ }
+ if (!strcasecmp (p, "true")) {
+ i = 1;
+ }
+ else if (!strcasecmp (p, "false")) {
+ i = 0;
+ }
+ else {
+ ConsoleMessage ("Bad line: %s\n", current_line);
+ ConsoleMessage ("What is this: %s?\n", p);
+ continue;
+ }
+ ConsoleDebug (CONFIG, "Setting sortbyappid to: %d\n", i);
+ SET_MANAGER (manager, sort_by_appid, i);
+ }
       else if (!strcasecmp (option1, "title")) {
         char *token;
         p = read_next_cmd (READ_REST_OF_LINE);
--- /local/mstar/software/fvwm/.backups/!local!mstar!software!fvwm!fvwm-2.0.46!modules!FvwmIconMan!xmanager.c.~1~ Wed Jul 16 21:31:22 1997
+++ xmanager.c Thu Dec 11 20:17:51 1997
_at_@ -1403,6 +1403,17 @@
   XFlush (theDisplay);
 }
 
+
+static int compare_windows(int by_appid, WinData *a, WinData *b)
+{
+ if (by_appid) {
+ return a->app_id - b->app_id;
+ }
+ else {
+ return strcasecmp (a->display_string, b->display_string);
+ }
+}
+
 /* find_windows_spot: returns index of button to stick the window in.
  * checks win->button to see if it's already in manager.
  * if it isn't, then gives spot at which it should be,
_at_@ -1413,9 +1424,9 @@
 {
   WinManager *man = win->manager;
   int num_windows = man->buttons.num_windows;
+ int by_appid = man->sort_by_appid;
 
   if (man->sort) {
- char *ds = win->display_string;
     int i, cur, start, finish, cmp_dir, correction;
     Button **bp;
 
_at_@ -1425,15 +1436,14 @@
       cur = win->button->index;
 
       if (cur - 1 > 0 &&
- strcasecmp (ds, bp[cur - 1]->drawn_state.win->display_string) < 0) {
+ compare_windows (by_appid, win, bp[cur - 1]->drawn_state.win) < 0) {
         start = cur - 1;
         finish = -1;
         cmp_dir = -1;
         correction = 1;
       }
       else if (cur < num_windows - 1 &&
- strcasecmp (ds,
- bp[cur + 1]->drawn_state.win->display_string) > 0) {
+ compare_windows (by_appid, win, bp[cur + 1]->drawn_state.win) > 0) {
         start = cur + 1;
         finish = num_windows;
         cmp_dir = 1;
_at_@ -1450,7 +1460,7 @@
       correction = 0;
     }
     for (i = start; i != finish && bp[i]->drawn_state.win && cmp_dir *
- strcasecmp (ds, bp[i]->drawn_state.win->display_string) > 0;
+ compare_windows (by_appid, win, bp[i]->drawn_state.win) > 0;
          i = i + cmp_dir)
       ;
     i += correction;
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Thu Dec 11 1997 - 19:38:58 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:38:01 BST