FVWM: Per-Window Styles

From: Craig Milo Rogers <Rogers_at_ISI.EDU>
Date: Sun, 16 Mar 2003 17:02:54 -0800

        Today, out of the blue, I decided that I wanted to apply
styles to specific windows (and not to window names, classes, or
resources, any of which may the same for multiple windows) on my FVWM
desktop. I noticed that a request to do this was already pending in
the FVWM bug site(id #568), but seeing that it's been over 2 years
since the enhancement request was queued in the bug tracking system, I
decided to look into it for fun.

        I made the following changes to "fvwm/style.c" in fvwm-2.5.6:

*** style.c.orig 2003-03-16 15:48:15.000000000 -0800
--- style.c 2003-03-16 15:51:17.000000000 -0800
***************
*** 4033,4038 ****
--- 4033,4042 ----
        /* clear callers return area */
        memset(styles, 0, sizeof(window_style));
  
+ /* Get the window ID: */
+ char winId[20];
+ sprintf(winId, "0x%x", (unsigned int)FW_W(fw));
+
        /* look thru all styles in order defined. */
        for (nptr = all_styles; nptr != NULL; nptr = SGET_NEXT_STYLE(*nptr))
        {
***************
*** 4051,4056 ****
--- 4055,4063 ----
                {
                        merge_styles(styles, nptr, False);
                }
+ else if (strcmp(SGET_NAME(*nptr), winId) == 0) {
+ merge_styles(styles, nptr, False);
+ }
        }
        if (!DO_IGNORE_GNOME_HINTS(fw))
        {
***************
*** 4800,4808 ****
        for (t = Scr.FvwmRoot.next; t != NULL && t != &Scr.FvwmRoot;
             t = t->next)
        {
                if (matchWildcards(name, t->class.res_class) == TRUE ||
                    matchWildcards(name, t->class.res_name) == TRUE ||
! matchWildcards(name, t->name.name) == TRUE)
                {
                        SET_STYLE_DELETED(t, 1);
                        Scr.flags.do_need_window_update = 1;
--- 4807,4820 ----
        for (t = Scr.FvwmRoot.next; t != NULL && t != &Scr.FvwmRoot;
             t = t->next)
        {
+ /* Get the window ID: */
+ char winId[20];
+ sprintf(winId, "0x%x", (unsigned int)FW_W(t));
+
                if (matchWildcards(name, t->class.res_class) == TRUE ||
                    matchWildcards(name, t->class.res_name) == TRUE ||
! matchWildcards(name, t->name.name) == TRUE ||
! strcmp(name, winId) == 0)
                {
                        SET_STYLE_DELETED(t, 1);
                        Scr.flags.do_need_window_update = 1;

        This implements per-window styles, except for the the
possibility of the reuse of window IDs. I apologize for the hokey
20-character fixed buffers; consider this a proof-of-concept
implementation, not rugged code.

        Here's a sample menu that applies per-window styles:

AddToMenu "WindowOps" "WindowOps" Title
+ "Focus Policy" Popup FocusPolicyOps

AddToMenu "FocusPolicyOps" "Focus Policy" Title
+ "Click to Focus" Current Style $[w.id] ClickToFocus
+ "Focus Follows Mouse" Current Style $[w.id] FocusFollowsMouse
+ "Never Focus" Current Style $[w.id] NeverFocus
+ "Sloppy Focus" Current Style $[w.id] SloppyFocus



                                        Craig Milo Rogers
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Sun Mar 16 2003 - 19:04:13 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:54 BST