From 88f580ec0c7015462329846cf96560df79b140f7 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Wed, 31 Oct 2007 19:34:07 +0000
Subject: move fullscreen windows to normal layer when they lose focus

---
 ChangeLog           |  3 +++
 src/FocusControl.cc |  4 +---
 src/Window.cc       | 21 ++++++++++++---------
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 85cfb57..8cce2dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
  (Format: Year/Month/Day)
 Changes for 1.0.1:
+*07/10/31:
+   * Move fullscreen windows to normal layer when they lose focus (Mark)
+     Window.cc FocusControl.cc
 *07/10/24:
    * Fixed some gcc 2.96 compile issues ( Henrik )
      Layer.hh, MinOverlapPlacement.cc, Workspace.cc
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index 27ef999..b977d59 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -156,9 +156,7 @@ void FocusControl::cycleFocus(const Focusables &window_list,
         }
     }
 
-    if (isCycling())
-        fbwin->tempRaise();
-    else
+    if (!isCycling())
         fbwin->raise();
 
     m_cycling_window = it;
diff --git a/src/Window.cc b/src/Window.cc
index 3452ce2..5e2f7c8 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -127,7 +127,7 @@ static Bool queueScanner(Display *, XEvent *e, char *args) {
 
 /// returns the deepest transientFor, asserting against a close loop
 WinClient *getRootTransientFor(WinClient *client) {
-    while (client->transientFor()) {
+    while (client && client->transientFor()) {
         assert(client != client->transientFor());
         client = client->transientFor();
     }
@@ -1317,12 +1317,6 @@ bool FluxboxWindow::focus() {
             screen().changeWorkspaceID(workspaceNumber());
     }
 
-    FluxboxWindow *cur = FocusControl::focusedFbWindow();
-    WinClient *client = FocusControl::focusedWindow();
-    if (cur && client && cur != this && cur->isFullscreen() &&
-        getRootTransientFor(m_client) != getRootTransientFor(client))
-        return false;
-
     if (isIconic()) {
         deiconify();
         m_focused = true; // signal to mapNotifyEvent to set focus when mapped
@@ -1893,7 +1887,7 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) {
     if (!m_initialized)
         m_layernum = layernum;
 
-    if (m_layernum == layernum && !force)
+    if (m_layernum == layernum && !force || !m_client)
         return;
 
     // get root window
@@ -1942,6 +1936,8 @@ void FluxboxWindow::setIconHidden(bool value) {
 // window has actually RECEIVED focus (got a FocusIn event)
 // so now we make it a focused frame etc
 void FluxboxWindow::setFocusFlag(bool focus) {
+    if (!m_client) return;
+
     bool was_focused = isFocused();
     m_focused = focus;
 #ifdef DEBUG
@@ -1950,10 +1946,17 @@ void FluxboxWindow::setFocusFlag(bool focus) {
 
     installColormap(focus);
 
+    if (fullscreen && !focus)
+        moveToLayer(m_old_layernum);
+    if (fullscreen && focus)
+        moveToLayer(::Layer::ABOVE_DOCK);
+
     if (focus != frame().focused())
         frame().setFocus(focus);
 
-    if (screen().doAutoRaise() && !screen().focusControl().isCycling()) {
+    if (screen().focusControl().isCycling())
+        tempRaise();
+    else if (screen().doAutoRaise()) {
         if (m_focused)
             m_timer.start();
         else
-- 
cgit v0.11.2