/* * We abuse the OAT_* hooks (which are intended for access control frameworks * such as sepgsql) for getting notified on relation create, alter, and drop * actions. This is more reliable than digging around in the utility command * parse trees, as these hooks are called from the internal functions which * actually update the system catalogs, regardless of how those functions were * invoked. */ static void objectaccess_hook(ObjectAccessType access, Oid classId, Oid objectId, int subId, void *arg) { switch (access) { case OAT_POST_CREATE: on_create(classId, objectId, subId, (ObjectAccessPostCreate *)arg); break; /* * The OAT_POST_ALTER hook is called from the following functions: * * [func] [class] [obj] [subobj] * renameatt_internal RelationRelationId pg_class.oid attnum * RenameRelationInternal RelationRelationId pg_class.oid 0 */ case OAT_POST_ALTER: on_alter(classId, objectId, subId, (ObjectAccessPostAlter *)arg); break; case OAT_DROP: on_drop(classId, objectId, subId, (ObjectAccessDrop *)arg); break; case OAT_NAMESPACE_SEARCH: case OAT_FUNCTION_EXECUTE: /* Ignore these events. */ break; } }
void UIWidget::mouse_up_func() { if (disabled) return; // call this function on the children first for (auto &child : ElementID::recast_collection<UIWidget>(get_children())) child->mouse_up_func(); // then continue with the function on self if (mouse_over && mouse_down_on_over) { on_click(); } mouse_down_on_over = false; if (dragging) { dragging = false; on_drop(); } on_mouse_up(); }
/** Event handler to fire (higher level, abstracted) Item signals from Gtk events. */ bool Item::on_event(GdkEvent* event) { boost::shared_ptr<Canvas> canvas = _canvas.lock(); if (!canvas || !event) return false; static double x, y; static double drag_start_x, drag_start_y; static bool double_click = false; static bool dragging = false; double click_x, click_y; click_x = event->button.x; click_y = event->button.y; property_parent().get_value()->w2i(click_x, click_y); switch (event->type) { case GDK_2BUTTON_PRESS: if (dragging) { ungrab(event->button.time); dragging = false; } on_double_click(&event->button); double_click = true; break; case GDK_BUTTON_PRESS: if (!canvas->locked() && event->button.button == 1) { x = click_x; y = click_y; // Set these so we can tell on a button release if a drag actually // happened (if not, it's just a click) drag_start_x = x; drag_start_y = y; grab(GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK, Gdk::Cursor(Gdk::FLEUR), event->button.time); dragging = true; } break; case GDK_MOTION_NOTIFY: if ((dragging && (event->motion.state & GDK_BUTTON1_MASK))) { double new_x = click_x; double new_y = click_y; if (event->motion.is_hint) { int t_x; int t_y; GdkModifierType state; gdk_window_get_pointer(event->motion.window, &t_x, &t_y, &state); new_x = t_x; new_y = t_y; } on_drag(new_x - x, new_y - y); x = new_x; y = new_y; } break; case GDK_BUTTON_RELEASE: if (dragging) { ungrab(event->button.time); dragging = false; if (click_x != drag_start_x || click_y != drag_start_y) { on_drop(); } else if (!double_click) { on_click(&event->button); } } else if (!double_click) { on_click(&event->button); } double_click = false; break; case GDK_ENTER_NOTIFY: canvas->signal_item_entered.emit(this); raise_to_top(); break; case GDK_LEAVE_NOTIFY: canvas->signal_item_left.emit(this); break; default: break; } // Never stop event propagation so derived classes have full access // to GTK events. return false; }