bugGNUstep - Bugs: bug #25472, NSDocumentController doesn't bring...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25472: NSDocumentController doesn't bring an already-open document to the front

Submitted by:  Doug Simons <theeggcamefirst>
Submitted on:  Mon 02 Feb 2009 11:50:46 PM UTC  
 
Category: Gui/AppKitSeverity: 3 - Normal
Item Group: BugStatus: Invalid
Privacy: PublicAssigned to: Fred Kiefer <FredKiefer>
Open/Closed: Declined

Wed 04 Feb 2009 05:42:18 PM UTC, comment #5:

So we have reached an agreement that the window is ordered front, it even gets the key focus for a short time, but in your case it looses that sometimes again.

As far as gui is concerned things are fine then. We call makeKeyAndOrderFront on NSWindow, which is what needs to be done. The rest of your problem stems from the window manager your are using. Newer window managers think that they know better, which window should have the focus. When an application switches the focus between windows this code in the window manager prevents the switch from actually happening.

Last year in a Google Summer of Code project a student tried to resolve this problem for us. And the situation has improved a lot through his code. Looks like he didn't succeed for all window managers.

What you may do now is either file another bug report for back, where you list your window manager and the actual behaviour you are getting. Or if you want to see any real progress here, start to debug the problem in back yourself. The starting point is setinputfocus: in the file back/Source/x11/XGServerWindow.m.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Tue 03 Feb 2009 11:15:49 PM UTC, comment #4:

checking with PRICE, if I reopen an image, which I on purpose put in the background, the document controller will correctly try to bring the window up to front, but it will not be key (that is , retains the gray border).

This on plain linux/x86/windowmaker/libart SVN Head

Riccardo Mottola <rmottola>
Project Member
Tue 03 Feb 2009 09:33:16 PM UTC, comment #3:

Okay, looking at this again I see that I gave a bad report about what I was seeing (stepping through slowly from gdb gives somewhat different window behavior than running without breakpoints). So now when I run normally the window IS coming to the front, but NOT always becoming key (or possibly becoming key briefly before the previous key window is made key again).

I'm not sure what's causing the odd key window behavior, but it behaves fine (becomes the key window every time) when the document is opened by selecting its name in a window and clicking a button in that window. The failure to become key window only occurs when the document is opened by selecting it from an open panel that was brought up from a menu.

The code to open the document is essentially identical in both cases, so I suspect an odd interaction somehow either from the menu click or from the modal open panel that was just displayed.

This isn't a very critical issue at this point, but in case anyone wants to think about this puzzle, here is my code (slightly condensed):

Code that WORKS 100% of the time, called by clicking a button (or double-clicking an item in an NSTableView) in a window containing an NSTableView with a list of document names:

- (IBAction) openFiles:(id)sender {
NSEnumerator *rowEnumerator = [fileTableView selectedRowEnumerator];
NSNumber *currentRow = nil;
NSArray *filenames = [self filenames]; // array of document filenames

while (currentRow = [rowEnumerator nextObject]) {
NSString *fileName = [filenames objectAtIndex:[currentRow intValue]];

[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:fileName display:YES];
}
}

Here's the code that OCCASIONALLY WORKS, but more often brings the document window to the front but FAILS to make it the key window. This is called as the action of a menu item:

- (IBAction) openScript: sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];

[openPanel setAllowsMultipleSelection:YES];
if ([openPanel runModalForDirectory:[self currentDirectory] file:nil types:[NSArray arrayWithObject:@"filetype"]] == NSOKButton) {
NSArray *filenames = [openPanel filenames];
NSEnumerator *objectEnumerator = [filenames objectEnumerator];
NSString *filename = nil;

while (filename = [objectEnumerator nextObject]) {
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:filename display:YES];
}
}
}

Like I said, I don't see anything significantly different about the two pieces of code other than the way they are invoked. The failure to become the key window occurs whether or not the document was already open (earlier I thought that was a factor, but apparently not).

Doug Simons <theeggcamefirst>
Tue 03 Feb 2009 07:39:28 AM UTC, comment #2:

this could also be a window manager problem, so information on which window manager you're running might be helpful in diagnosing that.

matt rice <ratmice>
Project Member
Tue 03 Feb 2009 07:33:55 AM UTC, comment #1:

With which application are you getting this problem?

The code in [NSDocumentController openDocumentWithContentsOfFile:display:] calls [NSDocument showWindows] and this asks the window controllers to order front. From what I can see in my test application Ink this GNUstep mechanism works fine. If it fails for you some application class must be at fault.

Could you please provide us with the code of your application or try to reproduce this behaviour with a freely available one.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Mon 02 Feb 2009 11:50:46 PM UTC, original submission:

[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:filename display:YES];

If the filename document is already open, the code above makes its window the key window, but doesn't bring it to the front of other windows.

Doug Simons <theeggcamefirst>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rmottola (Posted a comment)
  • -unavailable- added by ratmice (Posted a comment)
  • -unavailable- added by FredKiefer (Posted a comment)
  • -unavailable- added by theeggcamefirst (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 04 Feb 2009 05:42:18 PM UTCFredKieferStatusNeed Info=>Invalid
      Open/ClosedOpen=>Declined
    Tue 03 Feb 2009 07:33:55 AM UTCFredKieferStatusNone=>Need Info
      Assigned toNone=>FredKiefer

    Back to the top


    Powered by Savane 3.1-cleanup1