jwm-desktop-change.diff (2538B)
1 diff --git a/src/client.c b/src/client.c 2 index 4856fd4..82ef774 100644 3 --- a/src/client.c 4 +++ b/src/client.c 5 @@ -37,6 +37,10 @@ static void RestoreTransients(ClientNode *np, char raise); 6 static void KillClientHandler(ClientNode *np); 7 static void UnmapClient(ClientNode *np); 8 9 +void UnsetActiveClient() { 10 + activeClient = NULL; 11 +} 12 + 13 /** Load windows that are already mapped. */ 14 void StartupClients(void) 15 { 16 diff --git a/src/client.h b/src/client.h 17 index 6be5353..30bc590 100644 18 --- a/src/client.h 19 +++ b/src/client.h 20 @@ -166,6 +166,10 @@ typedef struct ClientNode { 21 /** The number of clients (maintained in client.c). */ 22 extern unsigned int clientCount; 23 24 +/** Unset the activeClient variable 25 + */ 26 +void UnsetActiveClient(void); 27 + 28 /** Find a client by window or parent window. 29 * @param w The window. 30 * @return The client (NULL if not found). 31 diff --git a/src/desktop.c b/src/desktop.c 32 index 1a136ca..4e5a502 100644 33 --- a/src/desktop.c 34 +++ b/src/desktop.c 35 @@ -165,20 +165,12 @@ void ChangeDesktop(unsigned int desktop) 36 return; 37 } 38 39 - /* Hide clients from the old desktop. 40 - * Note that we show clients in a separate loop to prevent an issue 41 - * with clients losing focus. 42 - */ 43 + /* Unset active client */ 44 for(x = 0; x < LAYER_COUNT; x++) { 45 for(np = nodes[x]; np; np = np->next) { 46 - if(np->state.status & STAT_STICKY) { 47 - continue; 48 - } 49 - if(np->state.desktop == currentDesktop) { 50 - HideClient(np); 51 - if((np->state.status & STAT_MINIMIZED) && (np->state.status & STAT_ACTIVE)) { 52 - np->state.status &= ~STAT_ACTIVE; 53 - } 54 + if (np->state.desktop == currentDesktop && np == GetActiveClient()) { 55 + UnsetActiveClient(); 56 + break; 57 } 58 } 59 } 60 @@ -195,6 +187,24 @@ void ChangeDesktop(unsigned int desktop) 61 } 62 } 63 64 + /* Hide clients from the old desktop. 65 + * Note that we show clients in a separate loop to prevent an issue 66 + * with clients losing focus. 67 + */ 68 + for(x = 0; x < LAYER_COUNT; x++) { 69 + for(np = nodes[x]; np; np = np->next) { 70 + if(np->state.status & STAT_STICKY) { 71 + continue; 72 + } 73 + if(np->state.desktop == currentDesktop) { 74 + HideClient(np); 75 + if((np->state.status & STAT_MINIMIZED) && (np->state.status & STAT_ACTIVE)) { 76 + np->state.status &= ~STAT_ACTIVE; 77 + } 78 + } 79 + } 80 + } 81 + 82 previousDesktop = currentDesktop; 83 currentDesktop = desktop; 84