+2006-12-27 Tor Lillqvist <tml@novell.com>
+
+ * gtk/gtk.symbols: Add gtk_status_icon_get_screen and
+ gtk_status_icon_set_screen.
+
+ * gtk/gtkstatusicon.c: Implement gtk_status_icon_position_menu()
+ on Windows. Keep track of where the last button click on the
+ taskbar icon took place, and return that. Obviously not correct if
+ no button has ever been clicked on the icon, or if the geometry of
+ the taskbar has changed since. But for most use cases where a menu
+ is going to be displayed as a direct result of a button click on
+ the status icon, works fine. (#377349)
+
+ Implement getting the orientation property on Windows.
+
+ (gtk_status_icon_embedded_changed)
+ (gtk_status_icon_orientation_changed): Ifdefify these functions
+ that are used only on X11.
+
2006-12-27 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c (execute_callbacks): Fix
#ifdef GDK_WINDOWING_WIN32
GtkWidget *dummy_widget;
NOTIFYICONDATAW nid;
+ gint last_click_x, last_click_y;
+ GtkOrientation orientation;
#endif
#ifdef GDK_WINDOWING_QUARTZ
#ifdef GDK_WINDOWING_WIN32
static void
-build_button_event (GdkEventButton *e,
- GdkEventType type,
- guint button)
+build_button_event (GtkStatusIconPrivate *priv,
+ GdkEventButton *e,
+ GdkEventType type,
+ guint button)
{
POINT pos;
GdkRectangle monitor0;
e->send_event = TRUE;
e->time = GetTickCount ();
GetCursorPos (&pos);
- e->x = pos.x + monitor0.x;
- e->y = pos.y + monitor0.y;
+ priv->last_click_x = e->x = pos.x + monitor0.x;
+ priv->last_click_y = e->y = pos.y + monitor0.y;
e->axes = NULL;
e->state = 0;
e->button = button;
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
- build_button_event (&e, GDK_BUTTON_PRESS,
+ build_button_event (status_icon->priv, &e, GDK_BUTTON_PRESS,
(lparam == WM_LBUTTONDOWN) ? 1 : 3);
gtk_status_icon_button_press (status_icon, &e);
break;
#ifdef GDK_WINDOWING_WIN32
- /* Code to get position and orientation of Windows taskbar. Not needed
- * currently, kept for reference.
- */
-#if 0
+ /* Get position and orientation of Windows taskbar. */
{
APPBARDATA abd;
abd.cbSize = sizeof (abd);
SHAppBarMessage (ABM_GETTASKBARPOS, &abd);
if (abd.rc.bottom - abd.rc.top > abd.rc.right - abd.rc.left)
- orientation = GTK_ORIENTATION_VERTICAL;
+ priv->orientation = GTK_ORIENTATION_VERTICAL;
else
- orientation = GTK_ORIENTATION_HORIZONTAL;
+ priv->orientation = GTK_ORIENTATION_HORIZONTAL;
}
-#endif
+
+ priv->last_click_x = priv->last_click_y = 0;
/* Are the system tray icons always 16 pixels square? */
priv->size = 16;
g_value_set_boolean (value, gtk_status_icon_is_embedded (status_icon));
break;
case PROP_ORIENTATION:
+#ifdef GDK_WINDOWING_X11
g_value_set_enum (value, _gtk_tray_icon_get_orientation (status_icon->priv->tray_icon));
+#endif
+#ifdef GDK_WINDOWING_WIN32
+ g_value_set_enum (value, status_icon->priv->orientation);
+#endif
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
#endif
+#ifdef GDK_WINDOWING_X11
+
static void
gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon)
{
g_object_notify (G_OBJECT (status_icon), "orientation");
}
+#endif
+
static gboolean
gtk_status_icon_button_press (GtkStatusIcon *status_icon,
GdkEventButton *event)
*push_in = FALSE;
#endif /* GDK_WINDOWING_X11 */
+
+#ifdef GDK_WINDOWING_WIN32
+ GtkStatusIcon *status_icon;
+ GtkStatusIconPrivate *priv;
+
+ g_return_if_fail (GTK_IS_MENU (menu));
+ g_return_if_fail (GTK_IS_STATUS_ICON (user_data));
+
+ status_icon = GTK_STATUS_ICON (user_data);
+ priv = status_icon->priv;
+
+ *x = priv->last_click_x;
+ *y = priv->last_click_y;
+ *push_in = TRUE;
+#endif
}
/**