static gboolean st_button_button_release (ClutterActor *actor, ClutterButtonEvent *event) { StButton *button = ST_BUTTON (actor); StButtonPrivate *priv = st_button_get_instance_private (button); StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button); ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event); if (priv->button_mask & mask) { gboolean is_click; is_click = priv->grabbed && clutter_actor_contains (actor, event->source); st_button_release (button, device, mask, is_click ? event->button : 0, NULL); priv->grabbed &= ~mask; if (priv->grabbed == 0) clutter_ungrab_pointer (); return TRUE; } return FALSE; }
/** * st_button_fake_release: * @button: an #StButton * * If this widget is holding a pointer grab, this function will * will ungrab it, and reset the pressed state. The effect is * similar to if the user had released the mouse button, but without * emitting the clicked signal. * * This function is useful if for example you want to do something * after the user is holding the mouse button for a given period of * time, breaking the grab. */ void st_button_fake_release (StButton *button) { StButtonPrivate *priv; g_return_if_fail (ST_IS_BUTTON (button)); priv = st_button_get_instance_private (button); if (priv->device && priv->press_sequence) { clutter_input_device_sequence_ungrab (priv->device, priv->press_sequence); } if (priv->pressed || priv->press_sequence) st_button_release (button, priv->device, priv->pressed, 0, NULL); if (priv->grabbed) { priv->grabbed = 0; clutter_ungrab_pointer (); } priv->device = NULL; }
static gboolean mx_toggle_handle_button_release_event (ClutterActor *actor, ClutterButtonEvent *event, MxToggle *toggle) { ClutterActorBox box; if (mx_widget_get_disabled (MX_WIDGET (toggle))) return FALSE; if (toggle->priv->last_move == 0) mx_toggle_set_active (toggle, !toggle->priv->active); else mx_toggle_set_active (toggle, (toggle->priv->last_move > 0.0)); toggle->priv->drag_offset = -1; toggle->priv->last_move = 0; clutter_ungrab_pointer (); /* ensure the hover state is removed if the pointer left the handle * during the grab */ clutter_actor_get_allocation_box (actor, &box); if (!clutter_actor_box_contains (&box, event->x, event->y)) mx_stylable_style_pseudo_class_remove (MX_STYLABLE (actor), "hover"); return TRUE; }
static void shell_menu_popdown_nosignal (ShellMenu *menu) { menu->priv->popped_up = FALSE; if (menu->priv->have_grab) clutter_ungrab_pointer (); clutter_actor_hide (CLUTTER_ACTOR (menu)); }
void shell_menu_popdown (ShellMenu *box) { if (box->priv->have_grab) clutter_ungrab_pointer (); clutter_actor_hide (CLUTTER_ACTOR (box)); g_signal_emit (G_OBJECT (box), shell_menu_signals[POPDOWN], 0); }
static gboolean red_release_cb (ClutterActor *actor, ClutterEvent *event, gpointer data) { clutter_ungrab_pointer (); return FALSE; }
static MxFocusable * mnb_launcher_button_accept_focus (MxFocusable *focusable, MxFocusHint hint) { clutter_ungrab_pointer (); clutter_actor_grab_key_focus (CLUTTER_ACTOR (focusable)); mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), "hover"); return focusable; }
static void stop_scrolling (StScrollBar *bar) { if (!bar->priv->grabbed) return; clutter_ungrab_pointer (); bar->priv->grabbed = FALSE; g_signal_emit (bar, signals[SCROLL_STOP], 0); }
IO_METHOD(IoClutter, ungrabPointer) { IoObject *device_n = IoMessage_locals_valueArgAt_(m, locals, 0); if(ISNUMBER(device_n)) clutter_ungrab_pointer_for_device(CNUMBER(device_n)); else clutter_ungrab_pointer(); return self; }
/** * shell_button_box_fake_release: * @box: * * If this button box is holding a pointer grab, this function will * will ungrab it, and reset the pressed state. The effect is * similar to if the user had released the mouse button, but without * emitting the activate signal. * * This function is useful if for example you want to do something after the user * is holding the mouse button for a given period of time, breaking the * grab. */ void shell_button_box_fake_release (ShellButtonBox *box) { if (!box->priv->held) return; box->priv->held = FALSE; clutter_ungrab_pointer (); set_pressed (box, FALSE); }
/** * st_button_fake_release: * @button: an #StButton * * If this widget is holding a pointer grab, this function will * will ungrab it, and reset the pressed state. The effect is * similar to if the user had released the mouse button, but without * emitting the clicked signal. * * This function is useful if for example you want to do something * after the user is holding the mouse button for a given period of * time, breaking the grab. */ void st_button_fake_release (StButton *button) { if (button->priv->pressed) st_button_release (button, button->priv->pressed, 0); if (button->priv->grabbed) { button->priv->grabbed = 0; clutter_ungrab_pointer (); } }
static void stop_scrolling (StScrollBar *bar) { if (!bar->priv->grabbed) return; st_widget_remove_style_pseudo_class (ST_WIDGET (bar->priv->handle), "active"); clutter_ungrab_pointer (); bar->priv->grabbed = FALSE; g_signal_emit (bar, signals[SCROLL_STOP], 0); }
static gboolean toggle_grab_pointer_cb (ClutterActor *actor, ClutterEvent *event, gpointer data) { /* we only deal with the event if the source is ourself */ if (event->button.source == actor) { if (clutter_get_pointer_grab () != NULL) clutter_ungrab_pointer (); else clutter_grab_pointer (actor); } return FALSE; }
static void gmc_button_pull (GmcButton *self) { GmcButtonPrivate *priv; priv = GMC_BUTTON_GET_PRIVATE (self); if (priv->is_pressed == FALSE) { return; } clutter_ungrab_pointer (); priv->is_pressed = FALSE; g_signal_emit (self, button_signals[CLICKED], 0, self); }
/* Accept focus handles setting hover pseudo style class and leave events * handle unsetting the hover pseudo style class */ static gboolean _leave_event_cb (ClutterActor *actor, ClutterCrossingEvent *event, gpointer data) { MnbLauncherButton *self = MNB_LAUNCHER_BUTTON (actor); mx_stylable_set_style_pseudo_class (MX_STYLABLE (self), NULL); if (self->priv->is_pressed) { clutter_ungrab_pointer (); clutter_ungrab_keyboard (); self->priv->is_pressed = FALSE; } return FALSE; }
static gboolean glide_image_button_release (ClutterActor *actor, ClutterButtonEvent *bev) { GlideImage *image = GLIDE_IMAGE (actor); if (image->priv->dragging) { if (!image->priv->motion_since_press) glide_undo_manager_cancel_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (actor))); else glide_undo_manager_end_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (actor)), GLIDE_ACTOR (actor)); clutter_ungrab_pointer (); image->priv->dragging = FALSE; return TRUE; } return FALSE; }
static gboolean st_button_button_release (ClutterActor *actor, ClutterButtonEvent *event) { StButton *button = ST_BUTTON (actor); StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button); if (button->priv->button_mask & mask) { gboolean is_click; is_click = button->priv->grabbed && st_widget_get_hover (ST_WIDGET (button)); st_button_release (button, mask, is_click ? event->button : 0); button->priv->grabbed &= ~mask; if (button->priv->grabbed == 0) clutter_ungrab_pointer (); return TRUE; } return FALSE; }
static gboolean mnb_launcher_button_button_release_event (ClutterActor *actor, ClutterButtonEvent *event) { if (event->button == 1) { MnbLauncherButton *self = MNB_LAUNCHER_BUTTON (actor); if (!self->priv->is_pressed) return FALSE; clutter_ungrab_pointer (); self->priv->is_pressed = FALSE; g_signal_emit (self, _signals[ACTIVATED], 0); mx_stylable_set_style_pseudo_class (MX_STYLABLE (self), NULL); mx_widget_hide_tooltip (MX_WIDGET (self)); return TRUE; } return FALSE; }
static gboolean shell_button_box_button_release_event (ClutterActor *actor, ClutterButtonEvent *event) { ShellButtonBox *box = SHELL_BUTTON_BOX (actor); if (event->button != 1 || event->click_count != 1) return FALSE; if (!box->priv->held) return TRUE; box->priv->held = FALSE; clutter_ungrab_pointer (); if (!shell_button_box_contains (box, event->source)) return FALSE; set_pressed (box, FALSE); g_signal_emit (G_OBJECT (box), shell_button_box_signals[ACTIVATE], 0, event); return TRUE; }
int main (int argc, char *argv[]) { GLenum err = 0; #ifdef WIN32 HGLRC clutter_gl_context = 0; HDC clutter_dc = 0; #else Display *clutter_display = NULL; Window clutter_win = 0; GLXContext clutter_gl_context = NULL; #endif GstPipeline *pipeline = NULL; GstBus *bus = NULL; GstElement *glupload = NULL; GstState state = 0; ClutterActor *stage = NULL; ClutterActor *clutter_texture = NULL; GAsyncQueue *queue_input_buf = NULL; GAsyncQueue *queue_output_buf = NULL; GstElement *fakesink = NULL; /* init gstreamer then clutter */ gst_init (&argc, &argv); clutter_threads_init (); clutter_init (&argc, &argv); clutter_threads_enter (); g_print ("clutter version: %s\n", CLUTTER_VERSION_S); /* init glew */ err = glewInit (); if (err != GLEW_OK) g_debug ("failed to init GLEW: %s", glewGetErrorString (err)); /* avoid to dispatch unecesary events */ clutter_ungrab_keyboard (); clutter_ungrab_pointer (); /* retrieve and turn off clutter opengl context */ stage = clutter_stage_get_default (); /* retrieve and turn off clutter opengl context */ #ifdef WIN32 clutter_gl_context = wglGetCurrentContext (); clutter_dc = wglGetCurrentDC (); wglMakeCurrent (0, 0); #else clutter_display = clutter_x11_get_default_display (); clutter_win = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); clutter_gl_context = glXGetCurrentContext (); glXMakeCurrent (clutter_display, None, 0); #endif /* setup gstreamer pipeline */ pipeline = GST_PIPELINE (gst_parse_launch ("videotestsrc ! video/x-raw-yuv, width=320, height=240, framerate=(fraction)30/1 ! " "glupload ! gleffects effect=5 ! glfiltercube ! fakesink sync=1", NULL)); /* setup bus */ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), NULL); g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), NULL); g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), NULL); gst_object_unref (bus); /* clutter_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */ glupload = gst_bin_get_by_name (GST_BIN (pipeline), "glupload0"); g_object_set (G_OBJECT (glupload), "external-opengl-context", clutter_gl_context, NULL); g_object_unref (glupload); /* NULL to PAUSED state pipeline to make sure the gst opengl context is created and * shared with the clutter one */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); state = GST_STATE_PAUSED; if (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) { g_debug ("failed to pause pipeline\n"); return -1; } /* turn on back clutter opengl context */ #ifdef WIN32 wglMakeCurrent (clutter_dc, clutter_gl_context); #else glXMakeCurrent (clutter_display, clutter_win, clutter_gl_context); #endif /* clutter stage */ clutter_actor_set_size (stage, 640, 480); clutter_actor_set_position (stage, 0, 0); clutter_stage_set_title (CLUTTER_STAGE (stage), "clutter and gst-plugins-gl"); clutter_texture = setup_stage (CLUTTER_STAGE (stage)); /* append a gst-gl texture to this queue when you do not need it no more */ queue_input_buf = g_async_queue_new (); queue_output_buf = g_async_queue_new (); g_object_set_data (G_OBJECT (clutter_texture), "queue_input_buf", queue_input_buf); g_object_set_data (G_OBJECT (clutter_texture), "queue_output_buf", queue_output_buf); /* set a callback to retrieve the gst gl textures */ fakesink = gst_bin_get_by_name (GST_BIN (pipeline), "fakesink0"); g_object_set (G_OBJECT (fakesink), "signal-handoffs", TRUE, NULL); g_signal_connect (fakesink, "handoff", G_CALLBACK (on_gst_buffer), clutter_texture); g_object_unref (fakesink); /* play gst */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); /* main loop */ clutter_main (); /* before to deinitialize the gst-gl-opengl context, * no shared context (here the clutter one) must be current */ #ifdef WIN32 wglMakeCurrent (0, 0); #else glXMakeCurrent (clutter_display, None, 0); #endif clutter_threads_leave (); /* stop and clean up the pipeline */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); g_object_unref (pipeline); /* make sure there is no pending gst gl buffer in the communication queues * between clutter and gst-gl */ while (g_async_queue_length (queue_input_buf) > 0) { GstBuffer *buf = g_async_queue_pop (queue_input_buf); gst_buffer_unref (buf); } while (g_async_queue_length (queue_output_buf) > 0) { GstBuffer *buf = g_async_queue_pop (queue_output_buf); gst_buffer_unref (buf); } return 0; }