medmunds@verity.com (Mike Edmunds) (01/24/91)
Is there a way (using Xlib or Xt) for my application to be notified whenever the owner of the PRIMARY selection changes? Or better yet, when the selection itself changes? I'd like to be able to update my application's menus based on the available selection targets. To do this, I need to know when the available targets have changed, which is likely to be when the selection changes. After looking through the ICCCM and a couple of Xlib and Xt references, it appears to me that the only way I can receive notification of selection status is to actually own the selection myself (in which case I'll be told when I lose it). That's not what I want to do. Thanks in advance for any ideas. - Mike Edmunds medmunds@verity.com Verity, Inc.
epstein@trwacs.UUCP (Jeremy Epstein) (01/29/91)
In article <1991Jan23.221631.27410@verity.com>, medmunds@verity.com (Mike Edmunds) writes: > Is there a way (using Xlib or Xt) for my application to be notified > whenever the owner of the PRIMARY selection changes? Or better yet, > when the selection itself changes? > > I'd like to be able to update my application's menus based on the > available selection targets. To do this, I need to know when the > available targets have changed, which is likely to be when the > selection changes. > > After looking through the ICCCM and a couple of Xlib and Xt > references, it appears to me that the only way I can receive > notification of selection status is to actually own the selection > myself (in which case I'll be told when I lose it). That's not what > I want to do. Selection ownership is the way to do this. However, it's not entirely fool-proof. Say your client owns the PRIMARY selection, and waits for SelectionNotify events. If client A does a SetSelectionOwner, you receive an event, so you know it's time to do something (i.e., update the application menus in your case). However, if client B now does a SetSelectionOwner, then client A will be notified, and not you. Thus, you don't know that another update is (potentially) needed. The CLIPBOARD described in the ICCCM suffers from this problem. One possibility I've been looking at is extending the protocol to add SetPersistentSelectionOwner, who would receive *all* SelectionNotify events on the property, regardless of who owned it. This approach solves a number of different problems, but I'm reluctant to extend the protocol. --Jeremy -- Jeremy Epstein UUCP: uunet!trwacs!epstein Trusted X Research Group Internet: epstein@trwacs.fp.trw.com TRW Systems Division Voice: +1 703/876-8776 Fairfax Virginia