[Xfce4-commits] <xfwm4:xfce-4.6> Do not set the "demand attention" flag when the window is alredy focused, refactor the code bit.
Olivier Fourdan
noreply at xfce.org
Tue Nov 17 12:54:01 CET 2009
Updating branch refs/heads/xfce-4.6
to 941a74f58fdcfdad7eeb47260deea02b84ef149e (commit)
from c2da2d43ba5b1f164cb2cc427e7715769c012cb0 (commit)
commit 941a74f58fdcfdad7eeb47260deea02b84ef149e
Author: Olivier Fourdan <fourdan at xfce.org>
Date: Thu Oct 1 09:33:18 2009 +0200
Do not set the "demand attention" flag when the window is alredy focused, refactor the code bit.
src/events.c | 63 ++++++++++++----------------------------------------------
src/netwm.c | 43 +++++++++++++++++++++++++++++++++++++++
src/netwm.h | 3 ++
3 files changed, 59 insertions(+), 50 deletions(-)
diff --git a/src/events.c b/src/events.c
index 8af6d54..d36b628 100644
--- a/src/events.c
+++ b/src/events.c
@@ -2077,34 +2077,8 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
}
else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) && (ev->format == 32))
{
- gboolean source_is_application;
- guint32 ev_time;
-
- ev_time = myDisplayGetTime (display_info, (guint32) ev->data.l[1]);
- source_is_application = (ev->data.l[0] == 1);
-
TRACE ("client \"%s\" (0x%lx) has received a NET_ACTIVE_WINDOW event", c->name, c->window);
- if (source_is_application)
- {
- guint32 current = myDisplayGetLastUserTime (display_info);
-
- TRACE ("Time of event received is %u, current XServer time is %u", (guint32) ev_time, (guint32) current);
- if ((screen_info->params->prevent_focus_stealing) && TIMESTAMP_IS_BEFORE(ev_time, current))
- {
- TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
- FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
- clientSetNetState (c);
- }
- else
- {
- clientActivate (c, ev_time, source_is_application);
- }
- }
- else
- {
- /* The request is either from a pager or an older client, use the most accurate timestamp */
- clientActivate (c, getXServerTime (display_info), source_is_application);
- }
+ clientHandleNetActiveWindow (c, (guint32) ev->data.l[1], (gboolean) (ev->data.l[0] == 1));
}
else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
{
@@ -2132,8 +2106,8 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
(ev->message_type == display_info->atoms[NET_CURRENT_DESKTOP])) && (ev->format == 32))
{
TRACE ("root has received a win_workspace or a NET_CURRENT_DESKTOP event %li", ev->data.l[0]);
- if ((ev->data.l[0] >= 0) && (ev->data.l[0] < screen_info->workspace_count) &&
- (ev->data.l[0] != screen_info->current_ws))
+ if ((ev->data.l[0] >= 0) && (ev->data.l[0] < (long) screen_info->workspace_count) &&
+ (ev->data.l[0] != (long) screen_info->current_ws))
{
workspaceSwitch (screen_info, ev->data.l[0], NULL, TRUE,
myDisplayGetTime (display_info, (guint32) ev->data.l[1]));
@@ -2143,7 +2117,7 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
(ev->message_type == display_info->atoms[NET_NUMBER_OF_DESKTOPS])) && (ev->format == 32))
{
TRACE ("root has received a win_workspace_count event");
- if (ev->data.l[0] != screen_info->workspace_count)
+ if (ev->data.l[0] != (long) screen_info->workspace_count)
{
workspaceSetCount (screen_info, ev->data.l[0]);
getDesktopLayout(display_info, screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
@@ -2823,12 +2797,13 @@ size_changed_cb(GdkScreen *gscreen, gpointer data)
{
ScreenInfo *screen_info;
DisplayInfo *display_info;
- int new_width, new_height;
+ gboolean size_changed;
TRACE ("entering size_changed_cb");
screen_info = (ScreenInfo *) data;
g_return_if_fail (screen_info);
+ display_info = screen_info->display_info;
/*
* We have added/removed a monitor or even changed the layout,
@@ -2841,28 +2816,16 @@ size_changed_cb(GdkScreen *gscreen, gpointer data)
screen_info->cache_monitor.width = 0;
screen_info->cache_monitor.height = 0;
- /*
- * If the overall size of the screen hasn't changed,
- * there is no need to continue any further...
- */
- new_width = WidthOfScreen (screen_info->xscreen);
- new_height = HeightOfScreen (screen_info->xscreen);
-
- if ((screen_info->width == new_width) &&
- (screen_info->height == new_height))
- {
- return;
- }
-
- display_info = screen_info->display_info;
- screen_info->width = new_width;
- screen_info->height = new_height;
-
+ size_changed = myScreenComputeSize (screen_info);
setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
- new_width, new_height, screen_info->margins);
+ screen_info->width, screen_info->height, screen_info->margins);
placeSidewalks (screen_info, screen_info->params->wrap_workspaces);
clientScreenResize (screen_info);
- compositorUpdateScreenSize (screen_info);
+
+ if (size_changed)
+ {
+ compositorUpdateScreenSize (screen_info);
+ }
}
static void
diff --git a/src/netwm.c b/src/netwm.c
index 1f127ae..b6187b0 100644
--- a/src/netwm.c
+++ b/src/netwm.c
@@ -1365,6 +1365,49 @@ clientSetNetActiveWindow (ScreenInfo *screen_info, Client *c, guint32 timestamp)
PropModeReplace, (unsigned char *) data, 2);
}
+void
+clientHandleNetActiveWindow (Client *c, guint32 timestamp, gboolean source_is_application)
+{
+ DisplayInfo *display_info;
+ ScreenInfo *screen_info;
+ guint32 ev_time, current_time;
+ Client *focused;
+
+ g_return_if_fail (c != NULL);
+ TRACE ("entering clientHandleNetActiveWindow");
+
+ screen_info = c->screen_info;
+ display_info = screen_info->display_info;
+ ev_time = myDisplayGetTime (display_info, timestamp);
+
+ if (source_is_application)
+ {
+ current_time = myDisplayGetLastUserTime (display_info);
+
+ TRACE ("Time of event received is %u, current XServer time is %u", (guint32) ev_time, (guint32) current_time);
+ if ((screen_info->params->prevent_focus_stealing) && TIMESTAMP_IS_BEFORE((guint32) ev_time, (guint32) current_time))
+ {
+ focused = clientGetFocus ();
+ /* We do not want to set the demand attention flag if the window is focused though */
+ if (c != focused)
+ {
+ TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
+ FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
+ clientSetNetState (c);
+ }
+ }
+ else
+ {
+ clientActivate (c, ev_time, source_is_application);
+ }
+ }
+ else
+ {
+ /* The request is either from a pager or an older client, use the most accurate timestamp */
+ clientActivate (c, getXServerTime (display_info), source_is_application);
+ }
+}
+
static gboolean
ping_timeout_cb (gpointer data)
{
diff --git a/src/netwm.h b/src/netwm.h
index 351ad77..7b54be4 100644
--- a/src/netwm.h
+++ b/src/netwm.h
@@ -55,6 +55,9 @@ void clientUpdateLayerState (Client *);
void clientSetNetActiveWindow (ScreenInfo *,
Client *,
guint32);
+void clientHandleNetActiveWindow (Client *,
+ guint32,
+ gboolean);
void clientRemoveNetWMPing (Client *);
gboolean clientSendNetWMPing (Client *,
guint32);
More information about the Xfce4-commits
mailing list