Skip to content

Commit

Permalink
window: add _NET_WM_STATE_FOCUSED hint to _NET_WM_STATE
Browse files Browse the repository at this point in the history
  • Loading branch information
monsta authored and raveit65 committed Feb 26, 2018
1 parent 70d82d3 commit 42410fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/atomnames.h
Expand Up @@ -158,6 +158,7 @@ item(_NET_WM_ACTION_ABOVE)
item(_NET_WM_ACTION_BELOW)
item(_NET_WM_STATE_STICKY)
item(_NET_WM_FULLSCREEN_MONITORS)
item(_NET_WM_STATE_FOCUSED)

#if 0
/* We apparently never use: */
Expand Down
23 changes: 18 additions & 5 deletions src/core/window.c
Expand Up @@ -1259,7 +1259,7 @@ static void
set_net_wm_state (MetaWindow *window)
{
int i;
unsigned long data[12];
unsigned long data[13];

i = 0;
if (window->shaded)
Expand Down Expand Up @@ -1322,6 +1322,11 @@ set_net_wm_state (MetaWindow *window)
data[i] = window->display->atom__NET_WM_STATE_STICKY;
++i;
}
if (window->has_focus)
{
data[i] = window->display->atom__NET_WM_STATE_FOCUSED;
++i;
}

meta_verbose ("Setting _NET_WM_STATE with %d atoms\n", i);

Expand Down Expand Up @@ -5490,6 +5495,15 @@ meta_window_client_message (MetaWindow *window,
return FALSE;
}

static void
meta_window_appears_focused_changed (MetaWindow *window)
{
set_net_wm_state (window);

if (window->frame)
meta_frame_queue_draw (window->frame);
}

gboolean
meta_window_notify_focus (MetaWindow *window,
XEvent *event)
Expand Down Expand Up @@ -5599,8 +5613,7 @@ meta_window_notify_focus (MetaWindow *window,
window);
}

if (window->frame)
meta_frame_queue_draw (window->frame);
meta_window_appears_focused_changed (window);

meta_error_trap_push (window->display);
XInstallColormap (window->display->xdisplay,
Expand Down Expand Up @@ -5652,8 +5665,8 @@ meta_window_notify_focus (MetaWindow *window,

window->display->focus_window = NULL;
window->has_focus = FALSE;
if (window->frame)
meta_frame_queue_draw (window->frame);

meta_window_appears_focused_changed (window);

meta_compositor_set_active_window (window->display->compositor,
window->screen, NULL);
Expand Down

14 comments on commit 42410fe

@raveit65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monsta
Can you please test Menta themes from this branch https://github.com/mate-desktop/mate-themes/commits/menta-backdrop ?
I like to know if using the backdrop state is OK in general or maybe it is to overload and i have to reduce some settings.

@raveit65
Copy link
Member

@raveit65 raveit65 commented on 42410fe Aug 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monsta
Hi, is it possible to add a gsettings key for this new feature?
I am pretty sure we have users who don't like this.
And i want to start with changing themes for backdrop state.
.....this affects not only headerbars from report ;)
So giving an user a chance to disable it would be really great.

Thank you

@monsta
Copy link
Contributor Author

@monsta monsta commented on 42410fe Aug 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it looks like this new feature created more problems than it solved... so maybe we should just revert it for 1.22.

@raveit65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which "more problems"?

@lukefromdc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "more problems" do we mean theme issues or bugs?

@raveit65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we have a few reports by people who missed that feature.
I didn't noticed any report against this feature.
But every very little change which we did to help users can cause a report against it by another user.
And using backdrop state isn't a little change.
An example not related to this feature.
mate-desktop/mate-themes#232
For this reason i asked for a gsettings key to disable backdrop state.
For me the missing key and that i can't add it for myself and i have to ask other busy developers is the only issue ;)
Sorry, that i asked you.

Btw. the backdrop state is the only solution to sign a csd-window that it is in background.

@monsta
Copy link
Contributor Author

@monsta monsta commented on 42410fe Aug 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember how many reports were about this feature... today I only found this one: mate-desktop/mate-panel#749.

Ok, I'll check how to add a new setting to Marco (seems like src/core/prefs.c needs some changes).

@raveit65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another report about missing backdrop state from firefox maintainer.
#427
@monsta
Can you please check if it is possible to add a gsettings key for that feature?
It's OK If you aren't able to do this, but please don't let me wait for this.
Adding backdrop state to themes is a huge job and i can't do that from one day to another.
Thank you

@lukefromdc
Copy link
Member

@lukefromdc lukefromdc commented on 42410fe Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I did in UbuntuStudio_Legacy was to only set a :backdrop theming different from the default theming for CSD window decorations and absolutely nothing else. That works, and makes CSD apps behave similiarly to traditional SSD apps so far as focus/backdrop appearance is concerned.

gedit_backdrop-and-focus

While two empty gedit windows don't have a lot to theme, this does show the basics: same view colors, same backgrounds, etc, only the window decorations need to use :backdrop and set a different appearance.

@raveit65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but i like to style more widgets than the headerbar for Menta themes, similar what adwaita does.

@monsta
Copy link
Contributor Author

@monsta monsta commented on 42410fe Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't have the time to work on this. Maybe I'll try this weekend. But if someone else can do it faster, I don't mind 🙂

@lukefromdc
Copy link
Member

@lukefromdc lukefromdc commented on 42410fe Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's Nautilus with BlackMATE, one window focused and one in backdrop. CSD code taken from UbuntuStudio_Legacy, mostly csd decorations and shadows are different(checked the code for instances of :backdrop). In most places the basic selector and same selector with :backdrop are simply listed together to keep them the same. Also note that :backdrop had to be used in BlackMATE and UbuntuStudio_Legacy to hide the carot in a non-selected view at one point, not sure if that is still the case though.

nautilus_blackmate

@raveit65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you , feel free to add what ever setting you want to BlackMate theme as maintainer of it ;).
I did already a more extended setting to Menta themes since several months, see menta-backdrop branch.

@lukefromdc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work was important in BlackMATE and UbuntuStudio_Legacy(source of the code used) as I use it with
https://gitlab.com/lukefromdc/compiz/tree/dev-focus_WIP which is my branch of compiz-reloaded that supports _NET_WM_STATE_FOCUSED . It contains work by myself, @soreau, and @muktupavels to enable CSD focus and backdrop states. I use that branch as my daily window manager and it works well.

Please sign in to comment.