calendar: Use gdk_window_new_input()

This commit is contained in:
Benjamin Otte 2016-10-17 20:14:09 +02:00
parent 31b5ba5bad
commit 4b92c0bb88

View File

@ -1526,8 +1526,6 @@ calendar_realize_arrows (GtkCalendar *calendar)
{ {
GtkWidget *widget = GTK_WIDGET (calendar); GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = calendar->priv; GtkCalendarPrivate *priv = calendar->priv;
GdkWindowAttr attributes;
gint attributes_mask;
gint i; gint i;
GtkAllocation allocation; GtkAllocation allocation;
@ -1536,25 +1534,19 @@ calendar_realize_arrows (GtkCalendar *calendar)
{ {
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
attributes.wclass = GDK_INPUT_ONLY;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = (gtk_widget_get_events (widget)
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
GdkRectangle rect; GdkRectangle rect;
calendar_arrow_rectangle (calendar, i, &rect); calendar_arrow_rectangle (calendar, i, &rect);
attributes.x = allocation.x + rect.x; rect.x += allocation.x;
attributes.y = allocation.y + rect.y; rect.y += allocation.y;
attributes.width = rect.width;
attributes.height = rect.height;
priv->arrow_win[i] = gdk_window_new (gtk_widget_get_window (widget),
&attributes,
attributes_mask);
priv->arrow_win[i] = gdk_window_new_input (gtk_widget_get_window (widget),
gtk_widget_get_events (widget)
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
&rect);
gtk_widget_register_window (widget, priv->arrow_win[i]); gtk_widget_register_window (widget, priv->arrow_win[i]);
} }
priv->arrow_prelight = 0x0; priv->arrow_prelight = 0x0;
@ -1624,10 +1616,8 @@ static void
gtk_calendar_realize (GtkWidget *widget) gtk_calendar_realize (GtkWidget *widget)
{ {
GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv;
GdkWindowAttr attributes;
gint attributes_mask;
gint inner_border = calendar_get_inner_border (GTK_CALENDAR (widget)); gint inner_border = calendar_get_inner_border (GTK_CALENDAR (widget));
GtkAllocation allocation; GtkAllocation allocation, rect;
GtkBorder padding; GtkBorder padding;
get_component_paddings (GTK_CALENDAR (widget), &padding, NULL, NULL, NULL); get_component_paddings (GTK_CALENDAR (widget), &padding, NULL, NULL, NULL);
@ -1635,34 +1625,26 @@ gtk_calendar_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_calendar_parent_class)->realize (widget); GTK_WIDGET_CLASS (gtk_calendar_parent_class)->realize (widget);
attributes.wclass = GDK_INPUT_ONLY;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = (gtk_widget_get_events (widget)
| GDK_SCROLL_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_LEAVE_NOTIFY_MASK);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
attributes.x = priv->week_width + padding.left + inner_border; rect.x = priv->week_width + padding.left + inner_border;
else else
attributes.x = padding.left + inner_border; rect.x = padding.left + inner_border;
rect.y = priv->header_h + priv->day_name_h + padding.top + inner_border;
attributes.y = priv->header_h + priv->day_name_h + padding.top + inner_border;
attributes.width = allocation.width - attributes.x - (padding.right + inner_border);
rect.width = allocation.width - rect.x - (padding.right + inner_border);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
attributes.width -= priv->week_width; rect.width -= priv->week_width;
rect.height = priv->main_h;
attributes.height = priv->main_h; priv->main_win = gdk_window_new_input (gtk_widget_get_window (widget),
attributes_mask = GDK_WA_X | GDK_WA_Y; gtk_widget_get_events (widget)
| GDK_SCROLL_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_LEAVE_NOTIFY_MASK,
&rect);
attributes.x += allocation.x;
attributes.y += allocation.y;
priv->main_win = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
gtk_widget_register_window (widget, priv->main_win); gtk_widget_register_window (widget, priv->main_win);
calendar_realize_arrows (GTK_CALENDAR (widget)); calendar_realize_arrows (GTK_CALENDAR (widget));