discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: windows focus issue


From: Matt Rice
Subject: Re: windows focus issue
Date: Tue, 10 Oct 2006 13:06:31 -0700 (PDT)

--- Matt Rice <ratmice@yahoo.com> wrote:

> 
> 
> --- Marc Brünink <mbruen@smartsoft.de> wrote:
> 
> > Hi all,
> > 
> > please try this:
> > Open 3 windows in any application. Close the last
> > one. The first window 
> > which was opened will be focused.
> > I would expect the previous focused window to be
> > re-focused.
> > 
> > Why its bad:
> > 1. Its uncommon.
> > 2. Pretty bad if you want to show some additional
> > infomation in a new 
> > window. (Any chance that this could be solved with
> > setParentWindow: ?)
> > 3. The window is just focused. Not ordered front.
> 
> I think i implemented this somewhere, i'll look for
> the patch

ok so it isn't really finished..

you can see by hiding the app and unhiding the app
the focus order gets messed up, but its a start

and it requires specific window manager support
can test if your window manager supports it by

$ xprop -root _NET_CLIENT_LIST_STACKING

not sure if it'd be better to return bottom to top or
top to bottom... so a more intrusive patch to gui may
be in order.






__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Index: Headers/Additions/GNUstepGUI/GSDisplayServer.h
===================================================================
--- Headers/Additions/GNUstepGUI/GSDisplayServer.h      (revision 23836)
+++ Headers/Additions/GNUstepGUI/GSDisplayServer.h      (working copy)
@@ -135,6 +135,7 @@
 - (void) setwindowlevel: (int) level : (int) win;
 - (int) windowlevel: (int) win;
 - (NSArray *) windowlist;
+- (NSArray *) windoworder;
 - (int) windowdepth: (int) win;
 - (void) setmaxsize: (NSSize)size : (int) win;
 - (void) setminsize: (NSSize)size : (int) win;
Index: Source/GSDisplayServer.m
===================================================================
--- Source/GSDisplayServer.m    (revision 23836)
+++ Source/GSDisplayServer.m    (working copy)
@@ -33,6 +33,7 @@
 #include <Foundation/NSThread.h>
 #include <Foundation/NSGeometry.h>
 
+#include "AppKit/NSApplication.h"
 #include "AppKit/NSEvent.h"
 #include "AppKit/NSImage.h"
 #include "AppKit/NSWindow.h"
@@ -671,6 +672,15 @@
   return nil;
 }
 
+/** Backends can override this method to return the list of windows in focus
+    order (top to bottom).
+    By default returns a list of windows in creation order.
+ */
+- (NSArray *)windoworder
+{
+  return [NSApp windows];
+}
+
 /** Returns the depth of the window */
 - (int) windowdepth: (int) win
 {
Index: Source/NSApplication.m
===================================================================
--- Source/NSApplication.m      (revision 23836)
+++ Source/NSApplication.m      (working copy)
@@ -523,7 +523,7 @@
       if ([NSApp isHidden] == NO)
        {
          int i;
-         NSArray *windows = RETAIN([NSApp windows]);
+         NSArray *windows = RETAIN([GSCurrentServer() windoworder]);
       
          for (i = 0; i < [windows count]; i++)
            { 
@@ -3257,8 +3257,7 @@
  */
 - (NSArray *) orderedWindows
 {
-  // FIXME
-  return [self windows];
+  return [GSCurrentServer() windoworder];
 }
 
 /*
@@ -3478,7 +3477,7 @@
 - (void) _windowWillClose: (NSNotification*) notification
 {
   NSWindow             *win = [notification object];
-  NSArray              *windows_list = [self windows];
+  NSArray              *windows_list = [GSCurrentServer() windoworder];
   unsigned             count = [windows_list count];
   unsigned             i;
   NSMutableArray       *list = [NSMutableArray arrayWithCapacity: count];
Index: Source/x11/XGServerWindow.m
===================================================================
--- Source/x11/XGServerWindow.m (revision 23836)
+++ Source/x11/XGServerWindow.m (working copy)
@@ -3038,6 +3038,44 @@
   return nil;
 }
 
+- (NSArray *) windoworder
+{
+  Atom client_stack_atom;
+  Window rootWindow;
+  Window *windowOrder;
+  gswindow_device_t *tmp;
+  NSMutableArray *ret;
+  int i, c;
+
+  client_stack_atom = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False);
+  rootWindow = DefaultRootWindow(dpy);
+  
+  windowOrder = (Window *)PropGetCheckProperty(dpy, rootWindow,
+                                              client_stack_atom,
+                                              XA_WINDOW, 32, -1, &c);
+  if (windowOrder == NULL || !c)
+    {
+      return [super windoworder];
+    }
+
+  ret = [NSMutableArray array];
+  
+  /* order from front to back. */
+  for (i = c; i > 0; i--)
+    {
+      tmp = [[self class]_windowForXWindow:windowOrder[i - 1]];
+      /* CLIENT_LIST_STACKING returns all windows on the server, we're only
+       * interested in the ones which are ours. */
+      if (tmp)
+        {
+         [ret addObject:[NSApp windowWithWindowNumber:tmp->number]];
+        }
+    }
+  
+  XFree(windowOrder);
+  return ret;
+}
+
 - (int) windowdepth: (int)win
 {
   gswindow_device_t *window;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]