Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Tab icons #39

Closed
wants to merge 7 commits into from
Closed

WIP: Tab icons #39

wants to merge 7 commits into from

Conversation

olejorgenb
Copy link
Contributor

@olejorgenb olejorgenb commented Feb 5, 2017

Work in progress adding icons to tabs. (ie. render _NET_WM_ICON)

Status: Works, but the code need some cleaning, and I haven't decided on all design choices yet.

Toggled through a style attribute show_icon. It's enabled for the clean looks in the branch. If you use a different look (or keep the look files in ~/.notion) add show_icon = true to defstyle("tab", ... or defstyle("tab-frame", ...

icon_align_left=false|true controls the alignment (whether the icon follows the text of is always left aligned)

I put this PR out there a bit early to get some indication on whether the feature is wanted at all and maybe some feedback/input. If there's little interest I might just maintain the branch in a less polished state.

cairo is a dependency.

  1. Is there strong feelings about needing a build flag? (a runtime option to will obviously be included)
  2. Is it worth adding icon_path to winprops?
  3. The icon size is hadcoded to 16x16 px atm. Is anyone interested in larger/smaller sizes?

(ref: #38)

2017-02-22-182019_992x676_scrot

Added:
- Add a new region dynfun 'region_icon'
- Code for extracting and resizing icons from _NET_WM_ICON
- Somewhat adhoc drawing of icons in tabs. eg. by abusing GrTextElem
- Dependency on cairo (didn't feel like learning the ancient X11 GC stuff)

Remaining:
- Less adhoc "transport" of icons into to the drawing engine
- Proper aligning (atm. hardcoded to 16x16 and 2px x and y offset)
- Account for icon size when shortening and don't draw icons on top of the title
- On/off option, preferably using the style system
- Possible build-time option?
- Extract icons from the WM_HINTS if _NET_WM_ICON isn't present
- Misc cleanup and documentation
- New extra style 'show_icon' controls whether to show tab icons
- Position the icon and title properly
- Make sure the tabbar is high enough to accomodate the icon [1]

[1] icon size is hardcoded to 16x16 atm.
Extra boolean style attribute "icon_align_left"

Note: Subject to change
@raboof
Copy link
Owner

raboof commented Feb 5, 2017

Cool!

I think adding cairo as a build-time required dependency could be a hurdle, it'd be really nice if that could be avoided...

Notion users don't tend to like changes to their configurations, but leaving this disabled by default will make it hard to discover. Not sure how to handle that gracefully...

@olejorgenb
Copy link
Contributor Author

It's simple enough (not pretty) to wrap all icon stuff in #ifdefs. I'm sure it's possible to make do with only Xlib draw functions also, but I'm not particular motivated to go down that road. If someone is willing to work out the details it's cool though.

We could extend ~/.notion/.welcome_msg_displayed to include version information and use that to display a "what's new" dialog but not sure it's worth the complexity.

Also report that we support _NEW_WM_ICON in _NET_SUPPORTED
winprop key "icon":
- Path to a png file
- Overrides _NET_WM_ICON [1]
- Will be rescaled to 16x16 if needed

Atm. no caching of icons is done. The png file is read (and possibly scaled)
each time a new matching window is mapped.

[1] know quirk: if the app changes _NET_WM_ICON the winprop
icon will be overriden
@raboof raboof changed the base branch from master to notion3 June 17, 2019 22:22
@wilhelmy
Copy link
Collaborator

wilhelmy commented Oct 7, 2019

Hypothetically speaking, how hard would it be to ditch cairo (since it isn't used elsewhere in notion right now)? Then nothing would prevent this being merged.

@olejorgenb
Copy link
Contributor Author

olejorgenb commented Oct 7, 2019

A long time since I wrote this, but I don't think it's harder than to find something else that can render ARGB data to a x-drawable. If you want support for the icon_path winprop you'll need something that can decode png - hopefully to ARGB laid out like the _NET_WM_ICON xprop (to simplify buffer managment)

Probably possible to use https://tronche.com/gui/x/xlib/utilities/XCreateImage.html though I'm not sure how well it handles alpha. I suspect the main challenge will be to properly blend the icon onto the surface.

(I don't actually remember if I tried to use the xlib functions or not)

@knixeur
Copy link
Collaborator

knixeur commented Oct 10, 2019

Thanks for the info. The code is very clear we could ifdef the code if Cairo is present like we do with Xft

@olejorgenb
Copy link
Contributor Author

PS: although the PR says WIP, me and hedning used the patch daily (for a year+) as part of our "fork", so the code should be reasonably well tested.

@knixeur
Copy link
Collaborator

knixeur commented Oct 10, 2019

Great! Thanks @olejorgenb I'll rebase against master (instead of notion3) and create new PR

@knixeur knixeur mentioned this pull request Oct 12, 2019
4 tasks
@knixeur
Copy link
Collaborator

knixeur commented Oct 29, 2019

I'll close this to follow it on #211 , thanks again @olejorgenb !

@knixeur knixeur closed this Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants