Branch: master

17b142dd 2014-11-29 00:34:07 Timothy Pearson
Send setActive signal when taking focus in Client::takeFocus
This relates to Bug 2189
Clean up minor formatting issues
M twin/activation.cpp
M twin/client.cpp
M twin/client.h
M twin/clients/keramik/keramik.cpp
M twin/events.cpp
M twin/group.cpp
M twin/placement.cpp
diff --git a/twin/activation.cpp b/twin/activation.cpp
index 2e55b49..83ff24e 100644
--- a/twin/activation.cpp
+++ b/twin/activation.cpp
@@ -311,14 +311,14 @@
     {
     takeActivity( c, ActivityFocus | ( force ? ActivityFocusForce : 0 ), false);
     }
-    
+
 void Workspace::takeActivity( Client* c, int flags, bool handled )
     {
-     // the 'if( c == active_client ) return;' optimization mustn't be done here
+     // the 'if( c == active_client ) return;' optimization must not be done here
     if (!focusChangeEnabled() && ( c != active_client) )
         flags &= ~ActivityFocus;
 
-    if ( !c ) 
+    if ( !c )
         {
         focusToNull();
         return;
@@ -328,7 +328,7 @@
         {
         Client* modal = c->findModal();
         if( modal != NULL && modal != c )	
-            { 
+            {
             next_active_client = modal;
             if( !modal->isOnDesktop( c->desktop()))
                 {
@@ -353,7 +353,7 @@
         {
         if( c->wantsInput() && ( flags & ActivityFocus ))
             {
-        // client cannot accept focus, but at least the window should be active (window menu, et. al. )
+            // client cannot accept focus, but at least the window should be active (window menu, et. al. )
             c->setActive( true );
             focusToNull();
             }
diff --git a/twin/client.cpp b/twin/client.cpp
index f32c506..4d26bb8 100644
--- a/twin/client.cpp
+++ b/twin/client.cpp
@@ -612,7 +612,7 @@
     hidden = hide;
     updateVisibility();
     }
-    
+
 /*!
   Returns whether the window is minimizable or not
  */
@@ -2200,9 +2200,13 @@
     if ( rules()->checkAcceptFocus( input ))
         {
         XSetInputFocus( tqt_xdisplay(), window(), RevertToPointerRoot, GET_QT_X_TIME() );
+        // Signal that we took focus!
+        setActive( true, true );
         }
     if ( Ptakefocus )
+        {
         sendClientMessage(window(), atoms->wm_protocols, atoms->wm_take_focus);
+        }
     workspace()->setShouldGetFocus( this );
     }
 
@@ -2745,7 +2749,7 @@
     workspace()->raiseClient( this );
     cancelAutoRaise();
     }
-    
+
 void Client::cancelAutoRaise()
     {
     delete autoRaiseTimer;
@@ -2773,7 +2777,7 @@
         XChangeProperty(tqt_xdisplay(), window(), atoms->net_wm_window_opacity, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1L);
         }
     }
-    
+
 void Client::setShadowSize(uint shadowSize)
     {
     // ignoring all individual settings - if we control a window, we control it's shadow
@@ -2781,7 +2785,7 @@
     long data = shadowSize;
     XChangeProperty(tqt_xdisplay(), frameId(), atoms->net_wm_window_shadow, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1L);
     }
-        
+
 void Client::updateOpacity()
 // extra syncscreen flag allows to avoid double syncs when active state changes (as it will usually change for two windows)
     {
diff --git a/twin/client.h b/twin/client.h
index 674251a..d3c7e7b 100644
--- a/twin/client.h
+++ b/twin/client.h
@@ -122,7 +122,7 @@
         bool isOnCurrentDesktop() const;
         bool isOnAllDesktops() const;
         void setOnAllDesktops( bool set );
-        
+
         bool isOnScreen( int screen ) const; // true if it's at least partially there
         int screen() const; // the screen where the center is
 
@@ -274,7 +274,7 @@
         void NETMoveResize( int x_root, int y_root, NET::Direction direction );
         void NETMoveResizeWindow( int flags, int x, int y, int width, int height );
         void restackWindow( Window above, int detail, NET::RequestSource source, Time timestamp, bool send_event = false );
-        
+
         void gotPing( Time timestamp );
 
         static TQCString staticWindowRole(WId);
diff --git a/twin/clients/keramik/keramik.cpp b/twin/clients/keramik/keramik.cpp
index 55eb578..4043e6e 100644
--- a/twin/clients/keramik/keramik.cpp
+++ b/twin/clients/keramik/keramik.cpp
@@ -1156,7 +1156,6 @@
 
 	TQRegion r;
 	register int w, y = 0;
-	int nrects;
 
 	if ( TQApplication::reverseLayout() ) {
 
@@ -1168,8 +1167,6 @@
 			r += TQRegion( x + 9,  y++, w - 15, 1 );
 			r += TQRegion( x + 7,  y++, w - 12, 1 );
 		} else {
-			nrects = 8;
-
 			// Do we have a large titlebar with a retracted caption bubble?
 			// (i.e. the style is set to use large caption bubbles, we're
 			//       not maximized and not active)
@@ -1191,15 +1188,12 @@
 
 		// If the caption bubble is visible and extends above the titlebar
 		if ( largeCaption && captionRect.width() >= 25 ) {
-			nrects = 11;
 			register int x = captionRect.left();
 			w = captionRect.width();
 			r += TQRegion( x + 8, y++, w - 19, 1 );
 			r += TQRegion( x + 6, y++, w - 15, 1 );
 			r += TQRegion( x + 5, y++, w - 12, 1 );
 		} else {
-			nrects = 8;
-
 			// Do we have a large titlebar with a retracted caption bubble?
 			// (i.e. the style is set to use large caption bubbles, we're
 			//       not maximized and not active)
diff --git a/twin/events.cpp b/twin/events.cpp
index 68c4be5..e9f8fd4 100644
--- a/twin/events.cpp
+++ b/twin/events.cpp
@@ -731,8 +731,8 @@
         return;
     destroyClient();
     }
-    
-    
+
+
 bool         blockAnimation = FALSE;
 
 /*!
diff --git a/twin/group.cpp b/twin/group.cpp
index 41c987d..62d235d 100644
--- a/twin/group.cpp
+++ b/twin/group.cpp
@@ -518,7 +518,7 @@
         ||
     // hacks here
         // Mozilla has resourceName() and resourceClass() swapped
-        c1->resourceName() == "mozilla" && c2->resourceName() == "mozilla" )
+        ((c1->resourceName() == "mozilla") && (c2->resourceName() == "mozilla")) )
         {
         if( !active_hack )   // without the active hack for focus stealing prevention,
             return c1 == c2; // different mainwindows are always different apps
diff --git a/twin/placement.cpp b/twin/placement.cpp
index bea707d..8112b71 100644
--- a/twin/placement.cpp
+++ b/twin/placement.cpp
@@ -362,12 +362,17 @@
     if ((yp + ch) > H) yp = Y;
 
     if ((xp + cw) > W)
-        if (!yp) 
+    {
+        if (!yp)
         {
         place(c,area,nextPlacement);
         return;
         }
-    else xp = X;
+    }
+    else
+    {
+        xp = X;
+    }
 
   //if this isn't the first window
     if (cci[dn].pos.x() != X && cci[dn].pos.y() != Y)