Subject: User state / style bug

From: Salvatore Domenick Desiano <[email-masked]>
Date: Wed, 5 May 2004 03:03:41 -0400 (EDT)

I've been using FVWM for almost ten years, now, so in a sense, every piece
of work I've done in the last decade owes at least something to FVWM. So,
my sincere thanks to the team.

Lately I decided to overhaul my setup, and I've been making heavy use of
the State portions of window states and styles. I've primarily been using
a snapshot from April 28, just after the State style was added. Something
odd was happening, so I started looking poring through and debugging the
code. Wow. Impressive code base.

Now, all I know about the code base is what I've learned from printf
debugging over the last week, so please pardon me if I sound like a
numnut. Here are is what I think I've learned, and I am intentionaly
stating the obvious to make sure I'm not making any stupid mistakes, and
my conclusions:

1. Using the WindowStyle command adds a style to the all_styles that is
   specific to a given window ID.
2. The UserState is stored in the flag portion of a style.
3. There are four copies of the flags. The actual flags are stored in
   "flags". The mask of which flags have actually been set is in
   "flag_mask". To be honest, I haven't figured out how "flag_default"
   and "change_mask" are used.
4. The flag portions of styles are merged, bit-by-bit, at the end of
   merge_styles (style.c).
5. The flag sets for the State style are set toward the end of
   style_parse_one_style_option (style.c:~3650). In this chunk of code,
   states corresponds to the old states value, mask is a mask of which
   state bit is being set. This mask is then used to update state.
6. The common flags (SCF) are set to state. This appears to be
   correct.
7. The flag mask (SCM) is currently set to 1. I think this is
   incorrect. I think this should be set to
   S_USER_STATES(SCM(*ps)) | mask. Right now, only the bottom bit of the
   mask is ever changed.
8. I'm not sure how the change mask is used, but I suspect that it needs
   to be set differently.
9. I have no idea how the default mask is used.

I'm loathe to actually change the code in CVS, since I'm not even remotely
on the development team, so here is the snippet that I think needs to be
changed:

	else if (StrEquals(token, "State"))
	{
		spargs = GetIntegerArguments(rest, NULL, tmpno, 1);
		if (spargs == 1 && tmpno[0] >= 0 && tmpno[0] <= 31)
		{
			unsigned int old_state;
			unsigned int set_mask;
			unsigned int new_state;
			unsigned int flag_mask;
			unsigned int change_mask;
			unsigned int default_mask;

			old_state = S_USER_STATES(SCF(*ps));
			set_mask = (1 << tmpno[0]);
			new_state = old_state;
			if (on)
			{
				new_state |= mask;
			}
			else
			{
				new_state &= ~mask;
			}
			flag_mask = S_USER_STATES(SCM(*ps))
			flag_mask |= mask;
			change_mask = S_USER_STATES(SCC(*ps));
			change_mask |= ~(new_state ^ old_state)
			default_mask = S_USER_STATES(SCD(*ps));
			default_mask = ????;

			S_SET_USER_STATES(SCF(*ps), new_state);
			S_SET_USER_STATES(SCM(*ps), flag_mask);
			S_SET_USER_STATES(SCC(*ps), change_mask);
			S_SET_USER_STATES(SCD(*ps), default_mask);
		}
		else
		{
			fvwm_msg(
				ERR,"style_parse_one_style_option",
				"bad State arg: %s", rest);
		}
	}

Thanks again for all of your hard work. Hope this is useful.

-- Sal
smile.

--------------
  Salvatore Domenick Desiano
    Research Scientist
      NASA Ames Research Center (QSS Group, Inc.)

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: [email-masked]
Date: Thu, 6 May 2004 02:36:33 +0200

>    and "change_mask" are used.

The change_mask indicates which flags have been changed recently
but not yet applied to the corresponding windows.  The
flag_default is used to allow for non-zero default values if the
style has never been set (or its last instance has been deleted).
It is used only for a couple of old styles to allow backwards
compatibility.  It's usually not necessary to fiddle with the
defaults.

>    S_USER_STATES(SCM(*ps)) | mask. Right now, only the bottom bit of the

Yes.

> 8. I'm not sure how the change mask is used, but I suspect that it needs

The mask has to be or'ed into the change_mask too.  As far as I
know, the flag_mask and the change_mask are always treated the
same when a style is used.

> 9. I have no idea how the default mask is used.

It's irrelevant here.

> 			change_mask |= ~(new_state ^ old_state)

Make that

> 			change_mask |= mask;

Not that it matters.  For the "State" style, the change_mask is
never used because it applies only to new windows.

Just delete this.

> Thanks again for all of your hard work. Hope this is useful.

I'll commit a fix.

Ciao

Dominik ^_^  ^_^

 --
Dominik Vogt, [email-masked]
Reply-To: [email-masked]

---

From: Salvatore Domenick Desiano <[email-masked]>
Date: Wed, 5 May 2004 21:18:57 -0400 (EDT)

o The change_mask indicates which flags have been changed recently
o but not yet applied to the corresponding windows.  The
o flag_default is used to allow for non-zero default values if the
o style has never been set (or its last instance has been deleted).
o It is used only for a couple of old styles to allow backwards
o compatibility.  It's usually not necessary to fiddle with the
o defaults.

Ah. I see.

o > 			change_mask |= mask;
o
o Not that it matters.  For the "State" style, the change_mask is
o never used because it applies only to new windows.

I assume you mean that "change_mask" is only for new windows. Right? I
mean, calling "WindowStyle State 3" during application should work...

Thanks again.

-- Sal
smile.

--------------