• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Click Through Bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Click Through Bug?


  • Subject: Click Through Bug?
  • From: Perry Clarke <email@hidden>
  • Date: Wed, 5 Feb 2003 15:34:55 -0800

I seem to have stumbled on what looks like an OS X window manager bug. As always I am hesitant to blame the os when my code is almost certainly to blame but having just come up with a trivial reproducible case I'm thinking that this time I may actually be right.

The problem is that clicking on an application whose main window is specified to have a NSBorderlessWindowMask and be transparent sometimes "clicks through" and causes the application to give up focus to whatever app owns the window behind it even though an opaque portion of the window was clicked. The "click through" is triggered by drawing activity in the window (i.e. an app that does a bunch of drawing in response to a mouse click is susceptible to this problem).

My theory is that for each mouse click the window manager checks the windows under it until it finds the first non-transparent one and gives the click to the application that owns that window. If a borderless window is in the middle of repainting itself when the window manager checks its transparency, the window manager may incorrectly decide the window (or, at least, the area under the mouse) is transparent and should not get the click.

I've reproduced this by adding a NSImageView to the RoundTransparentWindow sample and specifying the following code for the mouseDown delegate:

- (void) mouseDown:(NSEvent *) theEvent
{
NSLog(@"ImageView: mouseDown");
[self setImageScaling:NSScaleProportionally];
[self setImage:[NSImage imageNamed:@"Moon"]];
[[self window] display];
usleep(200000);
}

The code is a little strange in that its intent is to simulate "work being done" in the mouse down handler. The sleep for 2/10s of a second just serves to make the problem more easily reproducible by making the handler take longer to finish so one can get ahead of the app by clicking rapidly. All that is needed to have the problem occur occasionally is a repaint triggered by the mouse down, the code above just makes it happen in about 10 seconds of clicking rapidly. The only change needed to eliminate the problem is to make the window opaque (or use NSTitledWindowMask).

I've invested a huge amount of time in trying to work around this but haven't come up with anything yet. It's in the nature of my app that clicking the mouse causes things to be redisplayed and I've tried all kinds of tricks like moving the drawing out of the mouse down handler to a separate event but nothing makes any difference.

Searching the archives revealed one recent post on this topic but no responses ("Preventing click-through in transparent window" from Ujwal S. Sathyam on 21 Jan 2003).

Any suggestions would be most appreciated.

Perry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Click Through Bug?
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: namesOfPromisedFilesDroppedAtDestination
  • Next by Date: Bug in TextSizingExample
  • Previous by thread: Re: namesOfPromisedFilesDroppedAtDestination
  • Next by thread: Re: Click Through Bug?
  • Index(es):
    • Date
    • Thread