joewing / jwm

Joe's Window Manager
http://joewing.net/projects/jwm
MIT License
529 stars 85 forks source link

title bar button effects #241

Open simargl opened 9 years ago

simargl commented 9 years ago

Is there a plan to add hover and pressed effect for buttons, then with little changes themes from xfce could be used in jwm

technosaurus commented 9 years ago

At one point we could specify xbm images to use for the title bar (removed?) It looks like each title "button" has a significant amount of code to be "drawn" whereas it looks like using a specified image may take less code

... I know it wouldn't work if icons were disabled which brings me to:

Now it also looks like the xpm-create-image-from-data function and its associated helpers are only used in 1 place and it looks like you cannot have icons without --enable-xpm (though I haven't tried)

Perhaps generating a static const char[] array for these is an option (it appears to just be RGBA format) ... title bar images, the "X" icon, etc...

P.S. would it be possible to fallback to the "X" image or something if a specified image is not found/supported? Useful for instance as a "placeholder" if a theme is created with svg images, but jwm is compiled without svg support... at least in trays where a missing icon can result in a tray button of 0 width/height if label="" is not set

joewing commented 9 years ago

It's still possible to specify xbm images (or any image format that JWM supports) for title bar icons (see http://joewing.net/projects/jwm/config.shtml#other). There is a good amount of code to draw the non-image icons, but I prefer those since they don't require an external file (or data blob that JWM may be unable to interpret), they scale correctly, and they use the correct colors (which xbm images would as well, of course).

You should also be able to have images without enable-xpm, just not xpm images. If not, that's a bug.

In any case, I think there are 2 additional icons that JWM would need to support for each button ideally. The first for mouse hover and the second for mouse click. The internal icons could just change color (or stay the same). For external icons, I was thinking there could be an additional property when specifying icons. For example:

<ButtonClose>the-default.png</ButtonClose>
<ButtonClose on="hover">icon-to-display-on-hover.xpm</ButtonClose>  <!-- optional -->
<ButtonClose on="click">icon-to-display-on-click.jpg</ButtonClose> <!-- optional -->
technosaurus commented 9 years ago

Somewhere along the way xbm support was broken (it worked in 2.2.2, but since 3.0 it just frees the data and does nothing with it) something like this should work:


ImageNode *LoadXBMImage(const char *fileName)
{
   ImageNode *result = CreateImage(0,0,1);
   int dummy1, dummy2, rc;
   rc = XReadBitmapFileData(fileName,&result->width,&result->height,
                            &(result->data),&dummy1,&dummy2);
   return (rc == BitmapSuccess)?result:NULL;
}

also CreateImage() should have


//image->bitmap = 0;
image->bitmap = bitmap;
joewing commented 9 years ago

@technosaurus, I'm not sure what code you're looking at. There is no 3.0 and xbms seem to work in master. I think I might have had a horribly broken, experimental 3.0 branch at one point, but it's long gone. LoadXBMImage is here: https://github.com/joewing/jwm/blob/master/src/image.c#L527

technosaurus commented 9 years ago

I meant 2.3.0... but yeah, master is broken too. It broke @ https://github.com/joewing/jwm/commit/4c62a4796910d93702736ae1829d7a5547acdb80 image->data never gets filled image->bitmap is set to 0 instead of 1 The result is an image of random data, but the above changes fix it.

joewing commented 9 years ago

Thanks for the fix! I was loading an XPM instead of an XBM, so I thought it was working when it wasn't. It seems to actually work now.

technosaurus commented 9 years ago

I got to thinking about this and it seems that the bitmap color on title bar buttons (close, maximize...) is set to black, regardless of the foreground color... Am I missing a setting? It used to be the same as font color.

BlackCodec commented 2 years ago

@joewing I try to use your example for on hover and on click button event but it seems to not work. The last instruction is the only icon that appears. I use window style flat. Is this feature removed from last version?

joewing commented 2 years ago

I don't believe this was ever implemented.

BlackCodec commented 2 years ago

@joewing oh sorry, I saw the thread closed and I supposed it was implemented. Do you have any plan for this enhancment?

joewing commented 2 years ago

I'm not sure why the issue was closed, but it should probably be open if there's interest. I wasn't planning on implementing this (I forgot it existed). Unfortunately, I can't say I'll get to it any time soon.