[maemo-commits] [maemo-commits] r11199 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Apr 23 17:04:34 EEST 2007
- Previous message: [maemo-commits] r11198 - projects/haf/trunk/dosfstools/debian/patches
- Next message: [maemo-commits] r11200 - in projects/haf/trunk/hail: . hail/hail-hildon-desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2007-04-23 17:04:31 +0300 (Mon, 23 Apr 2007) New Revision: 11199 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h Log: * libhildondesktop/hildon-desktop-popup-window.[ch]: - Added new methods to access panes. - Fixed behavior. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-04-23 13:02:02 UTC (rev 11198) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-04-23 14:04:31 UTC (rev 11199) @@ -1,3 +1,9 @@ +2007-04-23 Moises Martinez <moises.martinez at nokia.com> + + * libhildondesktop/hildon-desktop-popup-window.[ch]: + - Added new methods to access panes. + - Fixed behavior. + 2007-04-20 Johan Bilien <johan.bilien at nokia.com> * configure.ac: 0.0.8 Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c 2007-04-23 13:02:02 UTC (rev 11198) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c 2007-04-23 14:04:31 UTC (rev 11199) @@ -67,7 +67,7 @@ static void hildon_desktop_popup_window_show_all (GtkWidget *widget); static void hildon_desktop_popup_window_hide_all (GtkWidget *widget); -static gboolean hildon_desktop_popup_window_enter_notify (GtkWidget *widget, GdkEventCrossing *event); +static gboolean hildon_desktop_popup_window_motion_notify (GtkWidget *widget, GdkEventMotion *event); static gboolean hildon_desktop_popup_window_leave_notify (GtkWidget *widget, GdkEventCrossing *event); static gboolean hildon_desktop_popup_window_visibility_notify (GtkWidget *widget, @@ -78,6 +78,12 @@ GdkEventCrossing *event, HildonDesktopPopupWindow *popup); +static gboolean hildon_desktop_popup_window_composited_button_release (GtkWidget *widget, + GdkEventButton *event, + HildonDesktopPopupWindow *popup); + +static gboolean popup_grab_on_window (GdkWindow *window, guint32 activate_time, gboolean grab_keyboard); + static gboolean hildon_desktop_popup_window_button_release_event (GtkWidget *widget, GdkEventButton *event); @@ -92,6 +98,7 @@ gpointer position_func_data; gboolean have_xgrab; + GtkWidget *pane_with_grab; GtkWidget *attached_widget; }; @@ -104,8 +111,9 @@ popup->priv->extra_panes = NULL; popup->priv->n_extra_panes = 0; - popup->priv->have_xgrab = FALSE; + popup->priv->have_xgrab = FALSE; + popup->priv->pane_with_grab = popup->priv->attached_widget = NULL; } @@ -119,7 +127,7 @@ object_class->set_property = hildon_desktop_popup_window_set_property; object_class->get_property = hildon_desktop_popup_window_get_property; - widget_class->enter_notify_event = hildon_desktop_popup_window_enter_notify; + widget_class->motion_notify_event = hildon_desktop_popup_window_motion_notify; widget_class->leave_notify_event = hildon_desktop_popup_window_leave_notify; widget_class->button_release_event = hildon_desktop_popup_window_button_release_event; @@ -203,6 +211,11 @@ GDK_WINDOW_TYPE_HINT_MENU); g_signal_connect (popup->priv->extra_panes[i], + "button-release-event", + G_CALLBACK (hildon_desktop_popup_window_composited_button_release), + (gpointer)popup); + + g_signal_connect (popup->priv->extra_panes[i], "leave-notify-event", G_CALLBACK (hildon_desktop_popup_window_composited_leave_notify), (gpointer)popup); @@ -289,19 +302,49 @@ gtk_widget_hide_all (popup->priv->extra_panes[i]); } -static gboolean -hildon_desktop_popup_window_enter_notify (GtkWidget *widget, - GdkEventCrossing *event) +static gboolean +hildon_desktop_popup_window_motion_notify (GtkWidget *widget, + GdkEventMotion *event) { HildonDesktopPopupWindow *popup = HILDON_DESKTOP_POPUP_WINDOW (widget); + gboolean in_panes_area = FALSE; + gint w,h,x,y,i; - g_debug ("%s enter_notify %p",__FILE__,popup); - /* We have to grab the pointer in here, we should get this when we come from - * a composited window - */ + w = widget->allocation.width; + h = widget->allocation.height; + + gtk_widget_get_pointer (widget, &x, &y); + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + in_panes_area = TRUE; + + if (!in_panes_area) + { + for (i=0; i < popup->priv->n_extra_panes; i++) + { + w = popup->priv->extra_panes[i]->allocation.width; + h = popup->priv->extra_panes[i]->allocation.height; + + gtk_widget_get_pointer (popup->priv->extra_panes[i], &x, &y); + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + { + gtk_grab_remove (widget); + + popup_grab_on_window + (popup->priv->extra_panes[i]->window, GDK_CURRENT_TIME, TRUE); + + gtk_grab_add (popup->priv->extra_panes[i]); + + popup->priv->pane_with_grab = popup->priv->extra_panes[i]; + popup->priv->have_xgrab = FALSE; + + break; + } + } + } - return - GTK_WIDGET_CLASS (hildon_desktop_popup_window_parent_class)->enter_notify_event (widget, event); + return TRUE; } static gboolean @@ -309,23 +352,98 @@ GdkEventCrossing *event) { HildonDesktopPopupWindow *popup = HILDON_DESKTOP_POPUP_WINDOW (widget); + gint w,h,x,y,i; + gboolean in_panes_area = FALSE; /* We have to ungrab the pointer in here, we should get this when we go to * a composited window */ - g_debug ("%s leave_notify %p",__FILE__,popup); + + for (i=0; i < popup->priv->n_extra_panes; i++) + { + w = popup->priv->extra_panes[i]->allocation.width; + h = popup->priv->extra_panes[i]->allocation.height; + + gtk_widget_get_pointer (popup->priv->extra_panes[i], &x, &y); + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + { + in_panes_area = TRUE; + break; + } + } + + if (in_panes_area) + { + gtk_grab_remove (GTK_WIDGET (popup)); + + popup_grab_on_window + (popup->priv->extra_panes[i]->window, GDK_CURRENT_TIME, TRUE); + + gtk_grab_add (popup->priv->extra_panes[i]); + + popup->priv->pane_with_grab = popup->priv->extra_panes[i]; + popup->priv->have_xgrab = FALSE; + } return GTK_WIDGET_CLASS (hildon_desktop_popup_window_parent_class)->leave_notify_event (widget, event); } -static gboolean +static gboolean hildon_desktop_popup_window_composited_leave_notify (GtkWidget *widget, - GdkEventCrossing *event, - HildonDesktopPopupWindow *popup) + GdkEventCrossing *event, + HildonDesktopPopupWindow *popup) { + gint w,h,x,y,i; + gboolean in_panes_area = FALSE; + + for (i=0; i < popup->priv->n_extra_panes; i++) + { + w = popup->priv->extra_panes[i]->allocation.width; + h = popup->priv->extra_panes[i]->allocation.height; + + gtk_widget_get_pointer (popup->priv->extra_panes[i], &x, &y); + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + { + in_panes_area = TRUE; + break; + } + } + + if (in_panes_area) + { + gtk_grab_remove (widget); + popup_grab_on_window + (popup->priv->extra_panes[i]->window, GDK_CURRENT_TIME, TRUE); + gtk_grab_add (popup->priv->extra_panes[i]); + + popup->priv->pane_with_grab = popup->priv->extra_panes[i]; + popup->priv->have_xgrab = FALSE; + } + else + { + gtk_widget_get_pointer (GTK_WIDGET (popup), &x, &y); + + w = GTK_WIDGET (popup)->allocation.width; + h = GTK_WIDGET (popup)->allocation.height; + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + { + gtk_grab_remove (widget); + + popup_grab_on_window (GTK_WIDGET (popup)->window, GDK_CURRENT_TIME, TRUE); + + gtk_grab_add (GTK_WIDGET (popup)); + + popup->priv->pane_with_grab = NULL; + popup->priv->have_xgrab = TRUE; + } + } + return TRUE; } @@ -336,7 +454,6 @@ { HildonDesktopPopupWindow *popup = HILDON_DESKTOP_POPUP_WINDOW (widget); - g_debug ("%s visibility_notify %p",__FILE__,popup); /* We have to close every window when called this but also we have to * track if our composited windows are not the responsibles for the * visibility-notify @@ -399,6 +516,60 @@ } static gboolean +hildon_desktop_popup_window_composited_button_release (GtkWidget *widget, + GdkEventButton *event, + HildonDesktopPopupWindow *popup) +{ + gboolean in_panes_area = FALSE, + in_window_area = FALSE; + gint x,y,w,h,i; + + if (!event) + return FALSE; + + gtk_widget_get_pointer (widget, &x, &y); + + w = widget->allocation.width; + h = widget->allocation.height; + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + in_panes_area = TRUE; + else + { + w = GTK_WIDGET (popup)->allocation.width; + h = GTK_WIDGET (popup)->allocation.height; + + gtk_widget_get_pointer (widget, &x, &y); + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + in_window_area = TRUE; + + for (i=0; i < popup->priv->n_extra_panes; i++) + { + if (widget != popup->priv->extra_panes[i]) + { + w = popup->priv->extra_panes[i]->allocation.width; + h = popup->priv->extra_panes[i]->allocation.height; + + gtk_widget_get_pointer (popup->priv->extra_panes[i], &x, &y); + + if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) + { + in_panes_area = TRUE; + break; + } + } + } + } + + /* Event outside of popup or in button area, close in clean way */ + if (!in_panes_area || in_window_area) + hildon_desktop_popup_window_popdown (popup); + + return TRUE; +} + +static gboolean hildon_desktop_popup_window_button_release_event (GtkWidget *widget, GdkEventButton *event) { @@ -415,7 +586,6 @@ w = widget->allocation.width; h = widget->allocation.height; - /* Pointer on window popup area */ if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) in_window_area = TRUE; else @@ -427,7 +597,6 @@ gtk_widget_get_pointer (popup->priv->extra_panes[i], &x, &y); - /* Pointer on button area */ if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) in_panes_area = TRUE; @@ -630,6 +799,67 @@ return popup->priv->extra_panes [pane]; } +GtkWidget * +hildon_desktop_popup_window_get_grabbed_pane (HildonDesktopPopupWindow *popup) +{ + g_assert (HILDON_DESKTOP_IS_POPUP_WINDOW (popup)); + + if (popup->priv->pane_with_grab) + return popup->priv->pane_with_grab; + else + return GTK_WIDGET (popup->priv->pane_with_grab); +} + +void +hildon_desktop_popup_window_jump_to_pane (HildonDesktopPopupWindow *popup, gint pane) +{ + g_assert (HILDON_DESKTOP_IS_POPUP_WINDOW (popup)); + + if (pane >= popup->priv->n_extra_panes) + pane = popup->priv->n_extra_panes -1; + + if (GTK_WIDGET_VISIBLE (GTK_WIDGET (popup))) + { + if (pane <= -1) + { + if (popup->priv->have_xgrab) + return; + else + { + gtk_grab_remove (popup->priv->pane_with_grab); + + popup_grab_on_window (GTK_WIDGET (popup)->window, GDK_CURRENT_TIME, TRUE); + + gtk_grab_add (GTK_WIDGET (popup)); + + popup->priv->pane_with_grab = NULL; + popup->priv->have_xgrab = TRUE; + } + } + else + { + GtkWidget *widget_with_grab; + + if (popup->priv->have_xgrab) + widget_with_grab = GTK_WIDGET (popup); + else + widget_with_grab = popup->priv->pane_with_grab; + + if (widget_with_grab == popup->priv->extra_panes[pane]) + return; + + gtk_grab_remove (widget_with_grab); + + popup_grab_on_window (popup->priv->extra_panes[pane]->window, GDK_CURRENT_TIME, TRUE); + + gtk_grab_add (popup->priv->extra_panes[pane]); + + popup->priv->pane_with_grab = popup->priv->extra_panes[pane]; + popup->priv->have_xgrab = FALSE; + } + } +} + void hildon_desktop_popup_window_popup (HildonDesktopPopupWindow *popup, HDPopupWindowPositionFunc func, @@ -677,8 +907,13 @@ void hildon_desktop_popup_window_popdown (HildonDesktopPopupWindow *popup) { + gint i; + gtk_widget_hide (GTK_WIDGET (popup)); gtk_grab_remove (GTK_WIDGET (popup)); + + for (i=0; i < popup->priv->n_extra_panes; i++) + gtk_grab_remove (popup->priv->extra_panes[i]); } Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h 2007-04-23 13:02:02 UTC (rev 11198) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h 2007-04-23 14:04:31 UTC (rev 11199) @@ -77,7 +77,13 @@ GtkWidget * hildon_desktop_popup_window_get_pane (HildonDesktopPopupWindow *popup, gint pane); +GtkWidget * +hildon_desktop_popup_window_get_grabbed_pane (HildonDesktopPopupWindow *popup); + void +hildon_desktop_popup_window_jump_to_pane (HildonDesktopPopupWindow *popup, gint pane); + +void hildon_desktop_popup_window_popup (HildonDesktopPopupWindow *popup, HDPopupWindowPositionFunc func, gpointer func_data,
- Previous message: [maemo-commits] r11198 - projects/haf/trunk/dosfstools/debian/patches
- Next message: [maemo-commits] r11200 - in projects/haf/trunk/hail: . hail/hail-hildon-desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]