From 17c4c23f227ae03440baff205018192fbef0a1d7 Mon Sep 17 00:00:00 2001 From: id Date: Sat, 29 May 1999 01:57:30 +0000 Subject: [PATCH] Add internal notification observer for deselection. --- WINGs/wtextfield.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 66afc42c..88a02555 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -236,6 +236,13 @@ lostHandler(WMWidget *w, Atom selection) paintTextField(tPtr); } +static void +_notification(void *observerData, WMNotification *notification) +{ + WMTextField *to = (WMTextField*)observerData; + WMTextField *tw = (WMTextField*)WMGetNotificationClientData(notification); + if (to != tw) lostHandler(to, 0); +} WMTextField* WMCreateTextField(WMWidget *parent) @@ -285,6 +292,7 @@ WMCreateTextField(WMWidget *parent) WMCreateSelectionHandler(tPtr, XA_PRIMARY, CurrentTime, requestHandler, lostHandler, NULL); + WMAddNotificationObserver(_notification, tPtr, "_lostOwnership", tPtr); tPtr->flags.cursorOn = 1; @@ -1242,6 +1250,13 @@ handleTextFieldActionEvents(XEvent *event, void *data) if (move) { XSetSelectionOwner(tPtr->view->screen->display, XA_PRIMARY, tPtr->view->window, CurrentTime); + { + WMNotification *notif = WMCreateNotification("_lostOwnership", + NULL,tPtr); + puts("notify it"); + WMPostNotification(notif); + WMReleaseNotification(notif); + } } break; @@ -1339,6 +1354,7 @@ destroyTextField(TextField *tPtr) WMReleaseFont(tPtr->font); WMDeleteSelectionHandler(tPtr, XA_PRIMARY); + WMRemoveNotificationObserver(tPtr); if (tPtr->text) free(tPtr->text); -- 2.11.4.GIT