bool netlink_unregister(struct netlink_info *netlink, unsigned int id) { GHashTable *notify_list; struct notify *notify; if (!netlink || id == 0) return false; if (!netlink->notify_groups || !netlink->notify_lookup) return false; notify_list = g_hash_table_lookup(netlink->notify_lookup, GUINT_TO_POINTER(id)); if (!notify_list) return false; g_hash_table_remove(netlink->notify_lookup, GUINT_TO_POINTER(id)); notify = g_hash_table_lookup(notify_list, GUINT_TO_POINTER(id)); if (!notify) return false; g_hash_table_remove(notify_list, GUINT_TO_POINTER(id)); if (g_hash_table_size(notify_list) == 0) drop_membership(netlink, notify->group); destroy_notify(notify); return true; }
bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index) { GList *list, *next; if (!mgmt) return false; for (list = g_list_first(mgmt->notify_list); list; list = next) { struct mgmt_notify *notify = list->data; next = g_list_next(list); if (notify->index != index) continue; mgmt->notify_list = g_list_remove_link(mgmt->notify_list, list); if (!mgmt->in_notify) { g_list_free_1(list); destroy_notify(notify, NULL); continue; } notify->destroyed = true; mgmt->notify_destroyed = g_list_concat(mgmt->notify_destroyed, list); } return true; }
bool mgmt_unregister(struct mgmt *mgmt, unsigned int id) { struct mgmt_notify *notify; GList *list; if (!mgmt || !id) return false; list = g_list_find_custom(mgmt->notify_list, GUINT_TO_POINTER(id), compare_notify_id); if (!list) return false; notify = list->data; mgmt->notify_list = g_list_remove_link(mgmt->notify_list, list); if (!mgmt->in_notify) { g_list_free_1(list); destroy_notify(notify, NULL); return true; } notify->destroyed = true; mgmt->notify_destroyed = g_list_concat(mgmt->notify_destroyed, list); return true; }
static void unref_data (GstCollectData * data) { GstCollectDataDestroyNotify destroy_notify; g_assert (data != NULL); g_assert (data->abidata.ABI.refcount > 0); if (!g_atomic_int_dec_and_test (&(data->abidata.ABI.refcount))) return; /* FIXME: Ugly hack as we can't add more fields to GstCollectData */ destroy_notify = (GstCollectDataDestroyNotify) g_object_get_data (G_OBJECT (data->pad), "gst-collect-data-destroy-notify"); if (destroy_notify) destroy_notify (data); g_object_unref (data->pad); if (data->buffer) { gst_buffer_unref (data->buffer); } g_free (data); }
static gboolean cleanup_notify(gpointer key, gpointer value, gpointer user_data) { struct notify *notify = value; destroy_notify(notify); return TRUE; }
virtual ~DecodeTask() { if ( image ) { delete image; } if ( destroy_notify ) { destroy_notify( user ); } }
void handle_event(xcb_generic_event_t *evt) { uint8_t resp_type = XCB_EVENT_RESPONSE_TYPE(evt); switch (resp_type) { case XCB_MAP_REQUEST: map_request(evt); break; case XCB_DESTROY_NOTIFY: destroy_notify(evt); break; case XCB_UNMAP_NOTIFY: unmap_notify(evt); break; case XCB_CLIENT_MESSAGE: client_message(evt); break; case XCB_CONFIGURE_REQUEST: configure_request(evt); break; case XCB_PROPERTY_NOTIFY: property_notify(evt); break; case XCB_ENTER_NOTIFY: enter_notify(evt); break; case XCB_MOTION_NOTIFY: motion_notify(evt); break; case XCB_FOCUS_IN: focus_in(evt); break; case 0: process_error(evt); break; default: if (randr && resp_type == randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { update_monitors(); } break; } }
bool mgmt_unregister(struct mgmt *mgmt, unsigned int id) { struct mgmt_notify *notify; if (!mgmt || !id) return false; notify = queue_remove_if(mgmt->notify_list, match_notify_id, UINT_TO_PTR(id)); if (!notify) return false; if (!mgmt->in_notify) { destroy_notify(notify); return true; } notify->removed = true; mgmt->need_notify_cleanup = true; return true; }
/* main() for usual operation */ int tray_main(int argc, char **argv) { XEvent ev; /* Interpret those settings that need an open display */ interpret_settings(); #ifdef DEBUG ewmh_list_supported_atoms(tray_data.dpy); #endif /* Create and show tray window */ tray_create_window(argc, argv); tray_acquire_selection(); tray_show_window(); #ifndef NO_NATIVE_KDE kde_tray_init(tray_data.dpy); #endif xembed_init(); #ifndef NO_NATIVE_KDE kde_icons_update(); #endif /* Main event loop */ while ("my guitar gently wheeps") { /* This is ugly and extra dependency. But who cares? * Rationale: we want to block unless absolutely needed. * This way we ensure that stalonetray does not show up * in powertop (i.e. does not eat unnecessary power and * CPU cycles) * Drawback: handling of signals is very limited. XNextEvent() * does not if signal occurs. This means that graceful * exit on e.g. Ctrl-C cannot be implemented without hacks. */ while (XPending(tray_data.dpy) || tray_data.scrollbars_data.scrollbar_down == -1) { XNextEvent(tray_data.dpy, &ev); xembed_handle_event(ev); scrollbars_handle_event(ev); switch (ev.type) { case VisibilityNotify: LOG_TRACE(("VisibilityNotify (0x%x, state=%d)\n", ev.xvisibility.window, ev.xvisibility.state)); visibility_notify(ev.xvisibility); break; case Expose: LOG_TRACE(("Expose (0x%x)\n", ev.xexpose.window)); expose(ev.xexpose); break; case PropertyNotify: LOG_TRACE(("PropertyNotify(0x%x)\n", ev.xproperty.window)); property_notify(ev.xproperty); break; case DestroyNotify: LOG_TRACE(("DestroyNotify(0x%x)\n", ev.xdestroywindow.window)); destroy_notify(ev.xdestroywindow); break; case ClientMessage: LOG_TRACE(("ClientMessage(from 0x%x?)\n", ev.xclient.window)); client_message(ev.xclient); break; case ConfigureNotify: LOG_TRACE(("ConfigureNotify(0x%x)\n", ev.xconfigure.window)); configure_notify(ev.xconfigure); break; case MapNotify: LOG_TRACE(("MapNotify(0x%x)\n", ev.xmap.window)); map_notify(ev.xmap); break; case ReparentNotify: LOG_TRACE(("ReparentNotify(0x%x to 0x%x)\n", ev.xreparent.window, ev.xreparent.parent)); reparent_notify(ev.xreparent); break; case SelectionClear: LOG_TRACE(("SelectionClear (0x%x has lost selection)\n", ev.xselectionclear.window)); selection_clear(ev.xselectionclear); break; case SelectionNotify: LOG_TRACE(("SelectionNotify\n")); break; case SelectionRequest: LOG_TRACE(("SelectionRequest (from 0x%x to 0x%x)\n", ev.xselectionrequest.requestor, ev.xselectionrequest.owner)); break; case UnmapNotify: LOG_TRACE(("UnmapNotify(0x%x)\n", ev.xunmap.window)); unmap_notify(ev.xunmap); break; default: #if defined(DEBUG) && defined(TRACE_EVENTS) LOG_TRACE(("Unhandled event: %s, serial: %d, window: 0x%x\n", x11_event_names[ev.type], ev.xany.serial, ev.xany.window)); #endif break; } if (tray_data.terminated) goto bailout; /* Perform all periodic tasks but for scrollbars */ perform_periodic_tasks(PT_MASK_ALL & (~PT_MASK_SB)); } perform_periodic_tasks(PT_MASK_ALL); my_usleep(500000L); } bailout: LOG_TRACE(("Clean exit\n")); return 0; }
void SYSTRAY_event_filter(XEvent *e) { XEvent ev; if (!tray_data.dpy) return; ev = *e; xembed_handle_event(ev); //scrollbars_handle_event(ev); switch (ev.type) { case VisibilityNotify: LOG_TRACE(("VisibilityNotify (0x%x, state=%d)\n", ev.xvisibility.window, ev.xvisibility.state)); visibility_notify(ev.xvisibility); break; case Expose: LOG_TRACE(("Expose (0x%x)\n", ev.xexpose.window)); expose(ev.xexpose); break; case PropertyNotify: LOG_TRACE(("PropertyNotify(0x%x)\n", ev.xproperty.window)); property_notify(ev.xproperty); break; case DestroyNotify: LOG_TRACE(("DestroyNotify(0x%x)\n", ev.xdestroywindow.window)); destroy_notify(ev.xdestroywindow); break; case ClientMessage: LOG_TRACE(("ClientMessage(from 0x%x?)\n", ev.xclient.window)); client_message(ev.xclient); break; case ConfigureNotify: LOG_TRACE(("ConfigureNotify(0x%x)\n", ev.xconfigure.window)); configure_notify(ev.xconfigure); break; case MapNotify: LOG_TRACE(("MapNotify(0x%x)\n", ev.xmap.window)); map_notify(ev.xmap); break; case ReparentNotify: LOG_TRACE(("ReparentNotify(0x%x to 0x%x)\n", ev.xreparent.window, ev.xreparent.parent)); reparent_notify(ev.xreparent); break; case SelectionClear: LOG_TRACE(("SelectionClear (0x%x has lost selection)\n", ev.xselectionclear.window)); selection_clear(ev.xselectionclear); break; case SelectionNotify: LOG_TRACE(("SelectionNotify\n")); break; case SelectionRequest: LOG_TRACE(("SelectionRequest (from 0x%x to 0x%x)\n", ev.xselectionrequest.requestor, ev.xselectionrequest.owner)); break; case UnmapNotify: LOG_TRACE(("UnmapNotify(0x%x)\n", ev.xunmap.window)); unmap_notify(ev.xunmap); break; default: #if defined(DEBUG) && defined(TRACE_EVENTS) LOG_TRACE(("Unhandled event: %s, serial: %d, window: 0x%x\n", x11_event_names[ev.type], ev.xany.serial, ev.xany.window)); #endif break; } // TODO: perform_periodic_tasks(PT_MASK_ALL); #if 0 if (tray_data.terminated) goto bailout; /* Perform all periodic tasks but for scrollbars */ perform_periodic_tasks(PT_MASK_ALL & (~PT_MASK_SB)); }