[tray] sync NaTray code from gnome-panel
Our copies and gnome-panel's had been ported for GSEAL independently. Sync them back up again. https://bugzilla.gnome.org/show_bug.cgi?id=627306
This commit is contained in:
parent
a9c0dcbd6b
commit
7ff7ec0e7a
@ -132,17 +132,15 @@ na_tray_child_size_allocate (GtkWidget *widget,
|
|||||||
GtkAllocation *allocation)
|
GtkAllocation *allocation)
|
||||||
{
|
{
|
||||||
NaTrayChild *child = NA_TRAY_CHILD (widget);
|
NaTrayChild *child = NA_TRAY_CHILD (widget);
|
||||||
|
|
||||||
GdkWindow *window;
|
|
||||||
GtkAllocation widget_allocation;
|
GtkAllocation widget_allocation;
|
||||||
gboolean moved, resized;
|
gboolean moved, resized;
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &widget_allocation);
|
gtk_widget_get_allocation (widget, &widget_allocation);
|
||||||
moved = allocation->x != widget_allocation.x ||
|
|
||||||
allocation->y != widget_allocation.y;
|
moved = (allocation->x != widget_allocation.x ||
|
||||||
resized = allocation->width != widget_allocation.width ||
|
allocation->y != widget_allocation.y);
|
||||||
allocation->height != widget_allocation.height;
|
resized = (allocation->width != widget_allocation.width ||
|
||||||
window = gtk_widget_get_window (widget);
|
allocation->height != widget_allocation.height);
|
||||||
|
|
||||||
/* When we are allocating the widget while mapped we need special handling
|
/* When we are allocating the widget while mapped we need special handling
|
||||||
* for both real and fake transparency.
|
* for both real and fake transparency.
|
||||||
@ -157,7 +155,7 @@ na_tray_child_size_allocate (GtkWidget *widget,
|
|||||||
if ((moved || resized) && gtk_widget_get_mapped (widget))
|
if ((moved || resized) && gtk_widget_get_mapped (widget))
|
||||||
{
|
{
|
||||||
if (na_tray_child_has_alpha (child))
|
if (na_tray_child_has_alpha (child))
|
||||||
gdk_window_invalidate_rect (gdk_window_get_parent (window),
|
gdk_window_invalidate_rect (gdk_window_get_parent (gtk_widget_get_window (widget)),
|
||||||
&widget_allocation, FALSE);
|
&widget_allocation, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +165,7 @@ na_tray_child_size_allocate (GtkWidget *widget,
|
|||||||
if ((moved || resized) && gtk_widget_get_mapped (widget))
|
if ((moved || resized) && gtk_widget_get_mapped (widget))
|
||||||
{
|
{
|
||||||
if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget)))
|
if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget)))
|
||||||
gdk_window_invalidate_rect (gdk_window_get_parent (window),
|
gdk_window_invalidate_rect (gdk_window_get_parent (gtk_widget_get_window (widget)),
|
||||||
&widget_allocation, FALSE);
|
&widget_allocation, FALSE);
|
||||||
else if (moved && child->parent_relative_bg)
|
else if (moved && child->parent_relative_bg)
|
||||||
na_tray_child_force_redraw (child);
|
na_tray_child_force_redraw (child);
|
||||||
@ -286,6 +284,7 @@ na_tray_child_new (GdkScreen *screen,
|
|||||||
gdk_visual_get_green_pixel_details (visual, NULL, NULL, &green_prec);
|
gdk_visual_get_green_pixel_details (visual, NULL, NULL, &green_prec);
|
||||||
gdk_visual_get_blue_pixel_details (visual, NULL, NULL, &blue_prec);
|
gdk_visual_get_blue_pixel_details (visual, NULL, NULL, &blue_prec);
|
||||||
depth = gdk_visual_get_depth (visual);
|
depth = gdk_visual_get_depth (visual);
|
||||||
|
|
||||||
visual_has_alpha = red_prec + blue_prec + green_prec < depth;
|
visual_has_alpha = red_prec + blue_prec + green_prec < depth;
|
||||||
child->has_alpha = (visual_has_alpha &&
|
child->has_alpha = (visual_has_alpha &&
|
||||||
gdk_display_supports_composite (gdk_screen_get_display (screen)));
|
gdk_display_supports_composite (gdk_screen_get_display (screen)));
|
||||||
@ -386,13 +385,15 @@ void
|
|||||||
na_tray_child_set_composited (NaTrayChild *child,
|
na_tray_child_set_composited (NaTrayChild *child,
|
||||||
gboolean composited)
|
gboolean composited)
|
||||||
{
|
{
|
||||||
GdkWindow *window;
|
|
||||||
g_return_if_fail (NA_IS_TRAY_CHILD (child));
|
g_return_if_fail (NA_IS_TRAY_CHILD (child));
|
||||||
|
|
||||||
|
if (child->composited == composited)
|
||||||
|
return;
|
||||||
|
|
||||||
child->composited = composited;
|
child->composited = composited;
|
||||||
window = gtk_widget_get_window (GTK_WIDGET (child));
|
if (gtk_widget_get_realized (GTK_WIDGET (child)))
|
||||||
if (window)
|
gdk_window_set_composited (gtk_widget_get_window (GTK_WIDGET (child)),
|
||||||
gdk_window_set_composited (window, composited);
|
composited);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we are faking transparency with a window-relative background, force a
|
/* If we are faking transparency with a window-relative background, force a
|
||||||
@ -404,7 +405,7 @@ na_tray_child_force_redraw (NaTrayChild *child)
|
|||||||
{
|
{
|
||||||
GtkWidget *widget = GTK_WIDGET (child);
|
GtkWidget *widget = GTK_WIDGET (child);
|
||||||
|
|
||||||
if (gtk_widget_get_mapped (GTK_WIDGET (child)) && child->parent_relative_bg)
|
if (gtk_widget_get_mapped (widget) && child->parent_relative_bg)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
/* Sending an ExposeEvent might cause redraw problems if the
|
/* Sending an ExposeEvent might cause redraw problems if the
|
||||||
@ -412,13 +413,15 @@ na_tray_child_force_redraw (NaTrayChild *child)
|
|||||||
* the redraw. It should be ok for GtkStatusIcon or EggTrayIcon.
|
* the redraw. It should be ok for GtkStatusIcon or EggTrayIcon.
|
||||||
*/
|
*/
|
||||||
Display *xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget));
|
Display *xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget));
|
||||||
GtkAllocation allocation;
|
|
||||||
XEvent xev;
|
XEvent xev;
|
||||||
|
GdkWindow *plug_window;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
plug_window = gtk_socket_get_plug_window (GTK_SOCKET (child));
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
xev.xexpose.type = Expose;
|
xev.xexpose.type = Expose;
|
||||||
xev.xexpose.window = GDK_WINDOW_XWINDOW (gtk_socket_get_plug_window (GTK_SOCKET (child)));
|
xev.xexpose.window = GDK_WINDOW_XWINDOW (plug_window);
|
||||||
xev.xexpose.x = 0;
|
xev.xexpose.x = 0;
|
||||||
xev.xexpose.y = 0;
|
xev.xexpose.y = 0;
|
||||||
xev.xexpose.width = allocation.width;
|
xev.xexpose.width = allocation.width;
|
||||||
@ -444,3 +447,88 @@ na_tray_child_force_redraw (NaTrayChild *child)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* from libwnck/xutils.c, comes as LGPLv2+ */
|
||||||
|
static char *
|
||||||
|
latin1_to_utf8 (const char *latin1)
|
||||||
|
{
|
||||||
|
GString *str;
|
||||||
|
const char *p;
|
||||||
|
|
||||||
|
str = g_string_new (NULL);
|
||||||
|
|
||||||
|
p = latin1;
|
||||||
|
while (*p)
|
||||||
|
{
|
||||||
|
g_string_append_unichar (str, (gunichar) *p);
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* derived from libwnck/xutils.c, comes as LGPLv2+ */
|
||||||
|
static void
|
||||||
|
_get_wmclass (Display *xdisplay,
|
||||||
|
Window xwindow,
|
||||||
|
char **res_class,
|
||||||
|
char **res_name)
|
||||||
|
{
|
||||||
|
XClassHint ch;
|
||||||
|
|
||||||
|
ch.res_name = NULL;
|
||||||
|
ch.res_class = NULL;
|
||||||
|
|
||||||
|
gdk_error_trap_push ();
|
||||||
|
XGetClassHint (xdisplay, xwindow, &ch);
|
||||||
|
gdk_error_trap_pop ();
|
||||||
|
|
||||||
|
if (res_class)
|
||||||
|
*res_class = NULL;
|
||||||
|
|
||||||
|
if (res_name)
|
||||||
|
*res_name = NULL;
|
||||||
|
|
||||||
|
if (ch.res_name)
|
||||||
|
{
|
||||||
|
if (res_name)
|
||||||
|
*res_name = latin1_to_utf8 (ch.res_name);
|
||||||
|
|
||||||
|
XFree (ch.res_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch.res_class)
|
||||||
|
{
|
||||||
|
if (res_class)
|
||||||
|
*res_class = latin1_to_utf8 (ch.res_class);
|
||||||
|
|
||||||
|
XFree (ch.res_class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* na_tray_child_get_wm_class;
|
||||||
|
* @child: a #NaTrayChild
|
||||||
|
* @res_name: return location for a string containing the application name of
|
||||||
|
* @child, or %NULL
|
||||||
|
* @res_class: return location for a string containing the application class of
|
||||||
|
* @child, or %NULL
|
||||||
|
*
|
||||||
|
* Fetches the resource associated with @child.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
na_tray_child_get_wm_class (NaTrayChild *child,
|
||||||
|
char **res_name,
|
||||||
|
char **res_class)
|
||||||
|
{
|
||||||
|
GdkDisplay *display;
|
||||||
|
|
||||||
|
g_return_if_fail (NA_IS_TRAY_CHILD (child));
|
||||||
|
|
||||||
|
display = gtk_widget_get_display (GTK_WIDGET (child));
|
||||||
|
|
||||||
|
_get_wmclass (GDK_DISPLAY_XDISPLAY (display),
|
||||||
|
child->icon_window,
|
||||||
|
res_class,
|
||||||
|
res_name);
|
||||||
|
}
|
||||||
|
@ -62,6 +62,9 @@ gboolean na_tray_child_has_alpha (NaTrayChild *child);
|
|||||||
void na_tray_child_set_composited (NaTrayChild *child,
|
void na_tray_child_set_composited (NaTrayChild *child,
|
||||||
gboolean composited);
|
gboolean composited);
|
||||||
void na_tray_child_force_redraw (NaTrayChild *child);
|
void na_tray_child_force_redraw (NaTrayChild *child);
|
||||||
|
void na_tray_child_get_wm_class (NaTrayChild *child,
|
||||||
|
char **res_name,
|
||||||
|
char **res_class);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -538,17 +538,18 @@ na_tray_manager_unmanage (NaTrayManager *manager)
|
|||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
GdkWindow *window;
|
|
||||||
guint32 timestamp;
|
guint32 timestamp;
|
||||||
GtkWidget *invisible;
|
GtkWidget *invisible;
|
||||||
|
GdkWindow *window;
|
||||||
|
|
||||||
if (manager->invisible == NULL)
|
if (manager->invisible == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
invisible = manager->invisible;
|
invisible = manager->invisible;
|
||||||
window = gtk_widget_get_window (invisible);
|
window = gtk_widget_get_window (invisible);
|
||||||
|
|
||||||
g_assert (GTK_IS_INVISIBLE (invisible));
|
g_assert (GTK_IS_INVISIBLE (invisible));
|
||||||
g_assert (gtk_widget_get_realized (GTK_WIDGET (invisible)));
|
g_assert (gtk_widget_get_realized (invisible));
|
||||||
g_assert (GDK_IS_WINDOW (window));
|
g_assert (GDK_IS_WINDOW (window));
|
||||||
|
|
||||||
display = gtk_widget_get_display (invisible);
|
display = gtk_widget_get_display (invisible);
|
||||||
@ -580,16 +581,14 @@ static void
|
|||||||
na_tray_manager_set_orientation_property (NaTrayManager *manager)
|
na_tray_manager_set_orientation_property (NaTrayManager *manager)
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
GdkDisplay *display;
|
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
GdkDisplay *display;
|
||||||
Atom orientation_atom;
|
Atom orientation_atom;
|
||||||
gulong data[1];
|
gulong data[1];
|
||||||
|
|
||||||
if (!manager->invisible)
|
if (!manager->invisible)
|
||||||
return;
|
return;
|
||||||
|
window = gtk_widget_get_window (manager->invisible);
|
||||||
window = gtk_widget_get_window (GTK_WIDGET (manager->invisible));
|
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -614,17 +613,15 @@ static void
|
|||||||
na_tray_manager_set_visual_property (NaTrayManager *manager)
|
na_tray_manager_set_visual_property (NaTrayManager *manager)
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
GdkDisplay *display;
|
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
GdkDisplay *display;
|
||||||
Visual *xvisual;
|
Visual *xvisual;
|
||||||
Atom visual_atom;
|
Atom visual_atom;
|
||||||
gulong data[1];
|
gulong data[1];
|
||||||
|
|
||||||
if (!manager->invisible)
|
if (!manager->invisible)
|
||||||
return;
|
return;
|
||||||
|
window = gtk_widget_get_window (manager->invisible);
|
||||||
window = gtk_widget_get_window (GTK_WIDGET (manager->invisible));
|
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -675,9 +672,9 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
|
|||||||
GdkScreen *screen)
|
GdkScreen *screen)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
GdkWindow *window;
|
|
||||||
Screen *xscreen;
|
Screen *xscreen;
|
||||||
GtkWidget *invisible;
|
GtkWidget *invisible;
|
||||||
|
GdkWindow *window;
|
||||||
char *selection_atom_name;
|
char *selection_atom_name;
|
||||||
guint32 timestamp;
|
guint32 timestamp;
|
||||||
|
|
||||||
@ -700,8 +697,6 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
|
|||||||
invisible = gtk_invisible_new_for_screen (screen);
|
invisible = gtk_invisible_new_for_screen (screen);
|
||||||
gtk_widget_realize (invisible);
|
gtk_widget_realize (invisible);
|
||||||
|
|
||||||
window = gtk_widget_get_window (GTK_WIDGET (invisible));
|
|
||||||
|
|
||||||
gtk_widget_add_events (invisible,
|
gtk_widget_add_events (invisible,
|
||||||
GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);
|
GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);
|
||||||
|
|
||||||
@ -716,6 +711,8 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
|
|||||||
na_tray_manager_set_orientation_property (manager);
|
na_tray_manager_set_orientation_property (manager);
|
||||||
na_tray_manager_set_visual_property (manager);
|
na_tray_manager_set_visual_property (manager);
|
||||||
|
|
||||||
|
window = gtk_widget_get_window (invisible);
|
||||||
|
|
||||||
timestamp = gdk_x11_get_server_time (window);
|
timestamp = gdk_x11_get_server_time (window);
|
||||||
|
|
||||||
/* Check if we could set the selection owner successfully */
|
/* Check if we could set the selection owner successfully */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user