Mercurial > audlegacy
changeset 3060:a0f79856693b
branch merge
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Fri, 13 Jul 2007 12:53:30 +0200 |
parents | f58cbfe8df1b (current diff) 766a0fd12f7d (diff) |
children | eaf597833f74 093759970e44 |
files | src/audacious/ui_skinned_button.c |
diffstat | 3 files changed, 109 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/ui_skinned_button.c Fri Jul 13 12:52:36 2007 +0200 +++ b/src/audacious/ui_skinned_button.c Fri Jul 13 12:53:30 2007 +0200 @@ -61,6 +61,9 @@ static void ui_skinned_button_init(UiSkinnedButton *button); static void ui_skinned_button_destroy(GtkObject *object); static void ui_skinned_button_realize(GtkWidget *widget); +static void ui_skinned_button_unrealize(GtkWidget *widget); +static void ui_skinned_button_map(GtkWidget *widget); +static void ui_skinned_button_unmap(GtkWidget *widget); static void ui_skinned_button_size_request(GtkWidget *widget, GtkRequisition *requisition); static gint ui_skinned_button_expose(GtkWidget *widget,GdkEventExpose *event); @@ -116,6 +119,9 @@ object_class->destroy = ui_skinned_button_destroy; widget_class->realize = ui_skinned_button_realize; + widget_class->unrealize = ui_skinned_button_unrealize; + widget_class->map = ui_skinned_button_map; + widget_class->unmap = ui_skinned_button_unmap; widget_class->expose_event = ui_skinned_button_expose; widget_class->size_request = ui_skinned_button_size_request; widget_class->size_allocate = ui_skinned_button_size_allocate; @@ -171,6 +177,7 @@ button->type = TYPE_NOT_SET; priv->move_x = 0; priv->move_y = 0; + button->event_window = NULL; } static void ui_skinned_button_destroy (GtkObject *object) { @@ -200,28 +207,64 @@ attributes.height = widget->allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events(widget); - attributes.visual = gtk_widget_get_visual(widget); - attributes.colormap = gtk_widget_get_colormap(widget); attributes.event_mask |= GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK; if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET) { + widget->window = gtk_widget_get_parent_window (widget); + g_object_ref (widget->window); attributes.wclass = GDK_INPUT_ONLY; attributes_mask = GDK_WA_X | GDK_WA_Y; + button->event_window = gdk_window_new (widget->window, &attributes, attributes_mask); GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW); + gdk_window_set_user_data(button->event_window, widget); } else { + attributes.visual = gtk_widget_get_visual(widget); + attributes.colormap = gtk_widget_get_colormap(widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask |= GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); + GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_WINDOW); + gdk_window_set_user_data(widget->window, widget); } - widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); - widget->style = gtk_style_attach(widget->style, widget->window); +} - gdk_window_set_user_data(widget->window, widget); +static void ui_skinned_button_unrealize (GtkWidget *widget) { + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + + if ( button->event_window != NULL ) + { + gdk_window_set_user_data( button->event_window , NULL ); + gdk_window_destroy( button->event_window ); + button->event_window = NULL; + } + + if (GTK_WIDGET_CLASS (parent_class)->unrealize) + (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); +} - if (attributes.wclass == GDK_INPUT_ONLY) - gdk_window_show (widget->window); +static void ui_skinned_button_map (GtkWidget *widget) +{ + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + + if (button->event_window != NULL) + gdk_window_show (button->event_window); + + if (GTK_WIDGET_CLASS (parent_class)->map) + (* GTK_WIDGET_CLASS (parent_class)->map) (widget); +} + +static void ui_skinned_button_unmap (GtkWidget *widget) +{ + UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); + + if (button->event_window != NULL) + gdk_window_hide (button->event_window); + + if (GTK_WIDGET_CLASS (parent_class)->unmap) + (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); } static void ui_skinned_button_size_request(GtkWidget *widget, GtkRequisition *requisition) { @@ -239,7 +282,12 @@ widget->allocation.y *= (1+priv->double_size); if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize(widget->window, allocation->x*(1+priv->double_size), allocation->y*(1+priv->double_size), allocation->width, allocation->height); + { + if ( button->event_window != NULL ) + gdk_window_move_resize(button->event_window, allocation->x*(1+priv->double_size), allocation->y*(1+priv->double_size), allocation->width, allocation->height); + else + gdk_window_move_resize(widget->window, allocation->x*(1+priv->double_size), allocation->y*(1+priv->double_size), allocation->width, allocation->height); + } button->x = widget->allocation.x/(priv->double_size ? 2 : 1); button->y = widget->allocation.y/(priv->double_size ? 2 : 1); @@ -261,6 +309,10 @@ if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET) return FALSE; + /* paranoia */ + if (button->event_window != NULL) + return FALSE; + GdkPixmap *obj; GdkGC *gc; obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth);
--- a/src/audacious/ui_vis.c Fri Jul 13 12:52:36 2007 +0200 +++ b/src/audacious/ui_vis.c Fri Jul 13 12:53:30 2007 +0200 @@ -53,6 +53,8 @@ static void ui_vis_destroy (GtkObject *object); static void ui_vis_realize (GtkWidget *widget); static void ui_vis_unrealize (GtkWidget *widget); +static void ui_vis_map (GtkWidget *widget); +static void ui_vis_unmap (GtkWidget *widget); static void ui_vis_size_request (GtkWidget *widget, GtkRequisition *requisition); static void ui_vis_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gboolean ui_vis_expose (GtkWidget *widget, GdkEventExpose *event); @@ -93,6 +95,8 @@ widget_class->realize = ui_vis_realize; widget_class->unrealize = ui_vis_unrealize; + widget_class->map = ui_vis_map; + widget_class->unmap = ui_vis_unmap; widget_class->expose_event = ui_vis_expose; widget_class->size_request = ui_vis_size_request; widget_class->size_allocate = ui_vis_size_allocate; @@ -122,6 +126,7 @@ vis->double_size = FALSE; vis->visible_window = TRUE; + vis->event_window = NULL; gtk_fixed_put(GTK_FIXED(vis->fixed), GTK_WIDGET(vis), vis->x, vis->y); @@ -167,31 +172,62 @@ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW); + gdk_window_set_user_data(widget->window, widget); } else { + widget->window = gtk_widget_get_parent_window (widget); + g_object_ref (widget->window); + attributes.wclass = GDK_INPUT_ONLY; attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + vis->event_window = gdk_window_new (widget->window, &attributes, attributes_mask); GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW); + gdk_window_set_user_data(vis->event_window, widget); } widget->style = gtk_style_attach(widget->style, widget->window); - - gdk_window_set_user_data(widget->window, widget); - - if (attributes.wclass == GDK_INPUT_ONLY) - gdk_window_show (widget->window); } static void ui_vis_unrealize(GtkWidget *widget) { UiVis *vis; vis = UI_VIS(widget); + if ( vis->event_window != NULL ) + { + gdk_window_set_user_data( vis->event_window , NULL ); + gdk_window_destroy( vis->event_window ); + vis->event_window = NULL; + } + if (GTK_WIDGET_CLASS (parent_class)->unrealize) (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); } +static void ui_vis_map(GtkWidget *widget) +{ + UiVis *vis; + vis = UI_VIS(widget); + + if (vis->event_window != NULL) + gdk_window_show (vis->event_window); + + if (GTK_WIDGET_CLASS (parent_class)->map) + (* GTK_WIDGET_CLASS (parent_class)->map) (widget); +} + +static void ui_vis_unmap (GtkWidget *widget) +{ + UiVis *vis; + vis = UI_VIS(widget); + + if (vis->event_window != NULL) + gdk_window_hide (vis->event_window); + + if (GTK_WIDGET_CLASS (parent_class)->unmap) + (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); +} + static void ui_vis_size_request(GtkWidget *widget, GtkRequisition *requisition) { UiVis *vis = UI_VIS(widget); @@ -206,7 +242,12 @@ widget->allocation.x *= (1+vis->double_size); widget->allocation.y *= (1+vis->double_size); if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + { + if (vis->event_window != NULL) + gdk_window_move_resize(vis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + else + gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + } vis->x = widget->allocation.x/(vis->double_size ? 2 : 1); vis->y = widget->allocation.y/(vis->double_size ? 2 : 1);