Commit 670180c4 authored by Roman Lebedev's avatar Roman Lebedev

GTK3: expose_event is now draw, second param is different

parent 53b3ae4f
......@@ -40,7 +40,7 @@ G_DEFINE_TYPE(DtBauhausWidget, dt_bh, GTK_TYPE_DRAWING_AREA)
#pragma GCC diagnostic pop
// fwd declare
static gboolean dt_bauhaus_popup_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
static gboolean dt_bauhaus_popup_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data);
static gboolean dt_bauhaus_popup_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
static void dt_bauhaus_widget_accept(dt_bauhaus_widget_t *w);
static void dt_bauhaus_widget_reject(dt_bauhaus_widget_t *w);
......@@ -500,7 +500,7 @@ static void dt_bh_class_init(DtBauhausWidgetClass *class)
// TODO: could init callbacks once per class for more efficiency:
// GtkWidgetClass *widget_class;
// widget_class = GTK_WIDGET_CLASS (class);
// widget_class->expose_event = dt_bauhaus_expose;
// widget_class->draw = dt_bauhaus_draw;
}
static int guess_font_size()
......@@ -633,8 +633,8 @@ void dt_bauhaus_init()
| GDK_KEY_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK);
g_signal_connect(G_OBJECT(darktable.bauhaus->popup_window), "show", G_CALLBACK(window_show), (gpointer)NULL);
g_signal_connect(G_OBJECT(darktable.bauhaus->popup_area), "expose-event",
G_CALLBACK(dt_bauhaus_popup_expose), (gpointer)NULL);
g_signal_connect(G_OBJECT(darktable.bauhaus->popup_area), "draw", G_CALLBACK(dt_bauhaus_popup_draw),
(gpointer)NULL);
g_signal_connect(G_OBJECT(darktable.bauhaus->popup_area), "motion-notify-event",
G_CALLBACK(dt_bauhaus_popup_motion_notify), (gpointer)NULL);
g_signal_connect(G_OBJECT(darktable.bauhaus->popup_area), "leave-notify-event",
......@@ -669,7 +669,7 @@ static gboolean dt_bauhaus_combobox_button_press(GtkWidget *widget, GdkEventButt
static gboolean dt_bauhaus_combobox_scroll(GtkWidget *widget, GdkEventScroll *event, gpointer user_data);
// static gboolean
// dt_bauhaus_button_release(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
static gboolean dt_bauhaus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
static gboolean dt_bauhaus_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data);
// end static init/cleanup
......@@ -692,7 +692,7 @@ static void dt_bauhaus_widget_init(dt_bauhaus_widget_t *w, dt_iop_module_t *self
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK);
g_signal_connect(G_OBJECT(w), "expose-event", G_CALLBACK(dt_bauhaus_expose), NULL);
g_signal_connect(G_OBJECT(w), "draw", G_CALLBACK(dt_bauhaus_draw), NULL);
// for combobox, where mouse-release triggers a selection, we need to catch this
// event where the mouse-press occurred, which will be this widget. we just pass
......@@ -1295,7 +1295,7 @@ static void dt_bauhaus_widget_accept(dt_bauhaus_widget_t *w)
}
}
static gboolean dt_bauhaus_popup_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
static gboolean dt_bauhaus_popup_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
......@@ -1486,16 +1486,14 @@ static gboolean dt_bauhaus_popup_expose(GtkWidget *widget, GdkEventExpose *event
}
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_set_source_surface(crf, cst, 0, 0);
cairo_paint(crf);
cairo_surface_destroy(cst);
return TRUE;
}
static gboolean dt_bauhaus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
static gboolean dt_bauhaus_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
......@@ -1556,10 +1554,8 @@ static gboolean dt_bauhaus_expose(GtkWidget *widget, GdkEventExpose *event, gpoi
cairo_restore(cr);
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_set_source_surface(crf, cst, 0, 0);
cairo_paint(crf);
cairo_surface_destroy(cst);
return TRUE;
......
......@@ -563,7 +563,7 @@ void *dt_control_expose(void *voidptr)
return NULL;
}
gboolean dt_control_expose_endmarker(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean dt_control_draw_endmarker(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
......@@ -573,10 +573,8 @@ gboolean dt_control_expose_endmarker(GtkWidget *widget, GdkEventExpose *event, g
cairo_t *cr = cairo_create(cst);
dt_draw_endmarker(cr, width, height, GPOINTER_TO_INT(user_data));
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_set_source_surface(crf, cst, 0, 0);
cairo_paint(crf);
cairo_surface_destroy(cst);
return TRUE;
}
......
......@@ -57,7 +57,7 @@ typedef GdkCursorType dt_cursor_t;
// called from gui
void *dt_control_expose(void *voidptr);
gboolean dt_control_expose_endmarker(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
gboolean dt_control_draw_endmarker(GtkWidget *widget, cairo_t *crf, gpointer user_data);
void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state);
void dt_control_button_released(double x, double y, int which, uint32_t state);
void dt_control_mouse_moved(double x, double y, double pressure, int which);
......
......@@ -790,7 +790,7 @@ static void _blendop_masks_polarity_callback(GtkToggleButton *togglebutton, dt_i
dt_dev_add_history_item(darktable.develop, self, TRUE);
}
static gboolean _blendop_blendif_expose(GtkWidget *widget, GdkEventExpose *event, dt_iop_module_t *module)
static gboolean _blendop_blendif_draw(GtkWidget *widget, cairo_t *cr, dt_iop_module_t *module)
{
if(darktable.gui->reset) return FALSE;
......@@ -1147,9 +1147,9 @@ void dt_iop_gui_init_blendif(GtkVBox *blendw, dt_iop_module_t *module)
g_object_set(output, "tooltip-text", ttoutput, (char *)NULL);
g_object_set(input, "tooltip-text", ttinput, (char *)NULL);
g_signal_connect(G_OBJECT(bd->lower_slider), "expose-event", G_CALLBACK(_blendop_blendif_expose), module);
g_signal_connect(G_OBJECT(bd->lower_slider), "draw", G_CALLBACK(_blendop_blendif_draw), module);
g_signal_connect(G_OBJECT(bd->upper_slider), "expose-event", G_CALLBACK(_blendop_blendif_expose), module);
g_signal_connect(G_OBJECT(bd->upper_slider), "draw", G_CALLBACK(_blendop_blendif_draw), module);
g_signal_connect(G_OBJECT(bd->channel_tabs), "switch_page", G_CALLBACK(_blendop_blendif_tab_switch), bd);
......
......@@ -25,14 +25,15 @@ static void _button_init(GtkDarktableButton *button);
static void _button_size_request(GtkWidget *widget, GtkRequisition *requisition);
static void _button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width);
static void _button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height);
static gboolean _button_expose(GtkWidget *widget, GdkEventExpose *event);
static gboolean _button_draw(GtkWidget *widget, cairo_t *cr);
static void _button_class_init(GtkDarktableButtonClass *klass)
{
GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
widget_class->get_preferred_width = _button_get_preferred_width;
widget_class->get_preferred_height = _button_get_preferred_height;
widget_class->expose_event = _button_expose;
widget_class->draw = _button_draw;
}
static void _button_init(GtkDarktableButton *button)
......@@ -66,11 +67,11 @@ static void _button_get_preferred_height(GtkWidget *widget, gint *minimal_height
*minimal_height = *natural_height = requisition.height;
}
static gboolean _button_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _button_draw(GtkWidget *widget, cairo_t *cr)
{
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_BUTTON(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkStyle *style = gtk_widget_get_style(widget);
int state = gtk_widget_get_state(widget);
......@@ -101,9 +102,6 @@ static gboolean _button_expose(GtkWidget *widget, GdkEventExpose *event)
}
/* begin cairo drawing */
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int x = allocation.x;
......@@ -125,8 +123,8 @@ static gboolean _button_expose(GtkWidget *widget, GdkEventExpose *event)
else if(!(flags & CPF_BG_TRANSPARENT))
{
/* draw default boxed button */
gtk_paint_box(gtk_widget_get_style(widget), gdk_cairo_create(gtk_widget_get_window(widget)),
gtk_widget_get_state(widget), GTK_SHADOW_OUT, widget, "button", x, y, width, height);
gtk_paint_box(gtk_widget_get_style(widget), cr, gtk_widget_get_state(widget), GTK_SHADOW_OUT, widget,
"button", x, y, width, height);
}
if(flags & CPF_IGNORE_FG_STATE) state = GTK_STATE_NORMAL;
......@@ -156,8 +154,6 @@ static gboolean _button_expose(GtkWidget *widget, GdkEventExpose *event)
g_object_unref(layout);
}
cairo_destroy(cr);
return FALSE;
}
......
......@@ -42,8 +42,8 @@ static void _gradient_slider_get_preferred_width(GtkWidget *widget, gint *minima
static void _gradient_slider_get_preferred_height(GtkWidget *widget, gint *minimal_height,
gint *natural_height);
static void _gradient_slider_realize(GtkWidget *widget);
static gboolean _gradient_slider_expose(GtkWidget *widget, GdkEventExpose *event);
static void _gradient_slider_destroy(GtkObject *object);
static gboolean _gradient_slider_draw(GtkWidget *widget, cairo_t *cr);
static void _gradient_slider_destroy(GtkWidget *widget);
// Events
static gboolean _gradient_slider_enter_notify_event(GtkWidget *widget, GdkEventCrossing *event);
......@@ -328,7 +328,7 @@ static void _gradient_slider_class_init(GtkDarktableGradientSliderClass *klass)
widget_class->realize = _gradient_slider_realize;
widget_class->get_preferred_width = _gradient_slider_get_preferred_width;
widget_class->get_preferred_height = _gradient_slider_get_preferred_height;
widget_class->expose_event = _gradient_slider_expose;
widget_class->draw = _gradient_slider_draw;
object_class->destroy = _gradient_slider_destroy;
widget_class->enter_notify_event = _gradient_slider_enter_notify_event;
......@@ -454,7 +454,7 @@ static void _gradient_slider_destroy(GtkObject *object)
}
}
static gboolean _gradient_slider_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _gradient_slider_draw(GtkWidget *widget, cairo_t *cr)
{
GtkDarktableGradientSlider *gslider = DTGTK_GRADIENT_SLIDER(widget);
......@@ -462,7 +462,7 @@ static gboolean _gradient_slider_expose(GtkWidget *widget, GdkEventExpose *event
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_GRADIENT_SLIDER(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkStyle *style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), NULL, "GtkButton", GTK_TYPE_BUTTON);
if(!style) style = gtk_rc_get_style(widget);
int state = gtk_widget_get_state(widget);
......@@ -476,9 +476,6 @@ static gboolean _gradient_slider_expose(GtkWidget *widget, GdkEventExpose *event
int margins = gslider->margins;
// Begin cairo drawing
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
// First build the cairo gradient and then fill the gradient
float gheight = height / 2.0;
float gwidth = width - 2 * margins;
......@@ -588,7 +585,6 @@ static gboolean _gradient_slider_expose(GtkWidget *widget, GdkEventExpose *event
}
}
cairo_destroy(cr);
return FALSE;
}
......
......@@ -24,7 +24,7 @@ static void _icon_init(GtkDarktableIcon *icon);
static void _icon_size_request(GtkWidget *widget, GtkRequisition *requisition);
static void _icon_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width);
static void _icon_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height);
static gboolean _icon_expose(GtkWidget *widget, GdkEventExpose *event);
static gboolean _icon_draw(GtkWidget *widget, cairo_t *cr);
static void _icon_class_init(GtkDarktableIconClass *klass)
......@@ -32,7 +32,7 @@ static void _icon_class_init(GtkDarktableIconClass *klass)
GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
widget_class->get_preferred_width = _icon_get_preferred_width;
widget_class->get_preferred_height = _icon_get_preferred_height;
widget_class->expose_event = _icon_expose;
widget_class->draw = _icon_draw;
}
static void _icon_init(GtkDarktableIcon *icon)
......@@ -66,11 +66,11 @@ static void _icon_get_preferred_height(GtkWidget *widget, gint *minimal_height,
*minimal_height = *natural_height = requisition.height;
}
static gboolean _icon_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _icon_draw(GtkWidget *widget, cairo_t *cr)
{
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_ICON(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkStyle *style = gtk_widget_get_style(widget);
int state = gtk_widget_get_state(widget);
int border = 0;
......@@ -80,9 +80,6 @@ static gboolean _icon_expose(GtkWidget *widget, GdkEventExpose *event)
/* begin cairo drawing */
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int x = allocation.x;
......@@ -107,8 +104,6 @@ static gboolean _icon_expose(GtkWidget *widget, GdkEventExpose *event)
if(DTGTK_ICON(widget)->icon)
DTGTK_ICON(widget)->icon(cr, x + border, y + border, width - (border * 2), height - (border * 2), flags);
cairo_destroy(cr);
return FALSE;
}
......
......@@ -29,7 +29,7 @@ static void _label_size_request(GtkWidget *widget, GtkRequisition *requisition);
// static void _label_realize(GtkWidget *widget);
static void _label_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width);
static void _label_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height);
static gboolean _label_expose(GtkWidget *widget, GdkEventExpose *event);
static gboolean _label_draw(GtkWidget *widget, cairo_t *cr);
// static void _label_destroy(GtkObject *object);
......@@ -39,10 +39,10 @@ static void _label_class_init(GtkDarktableLabelClass *klass)
// GtkObjectClass *object_class=(GtkObjectClass *) klass;
// widget_class->realize = _label_realize;
// widget_class->size_allocate = _label_size_allocate;
widget_class->expose_event = _label_expose;
// object_class->destroy = _label_destroy;
widget_class->get_preferred_width = _label_get_preferred_width;
widget_class->get_preferred_height = _label_get_preferred_height;
widget_class->draw = _label_draw;
}
static void _label_init(GtkDarktableLabel *label)
......@@ -105,11 +105,10 @@ static void _label_get_preferred_height(GtkWidget *widget, gint *minimal_height,
*minimal_height = *natural_height = requisition.height;
}
static gboolean _label_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _label_draw(GtkWidget *widget, cairo_t *cr)
{
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_LABEL(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
......@@ -131,10 +130,6 @@ static gboolean _label_expose(GtkWidget *widget, GdkEventExpose *event)
// Begin cairo drawing
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_rgba(cr, 1, 1, 1, 0.10);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
......@@ -198,7 +193,6 @@ static gboolean _label_expose(GtkWidget *widget, GdkEventExpose *event)
g_object_unref(layout);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
cairo_destroy(cr);
return FALSE;
}
......
......@@ -54,7 +54,7 @@ static void _slider_get_preferred_width(GtkWidget *widget, gint *minimal_width,
static void _slider_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height);
static void _slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
static void _slider_realize(GtkWidget *widget);
static gboolean _slider_expose(GtkWidget *widget, GdkEventExpose *event);
static gboolean _slider_draw(GtkWidget *widget, cairo_t *cr);
// static void _slider_destroy(GtkObject *object);
// Slider Events
......@@ -100,7 +100,7 @@ static void _slider_class_init(GtkDarktableSliderClass *klass)
widget_class->get_preferred_width = _slider_get_preferred_width;
widget_class->get_preferred_height = _slider_get_preferred_height;
widget_class->size_allocate = _slider_size_allocate;
widget_class->expose_event = _slider_expose;
widget_class->draw = _slider_draw;
widget_class->button_press_event = _slider_button_press;
widget_class->button_release_event = _slider_button_release;
widget_class->scroll_event = _slider_scroll_event;
......@@ -477,11 +477,10 @@ static void _slider_draw_rounded_rect(cairo_t *cr, gfloat x, gfloat y, gfloat wi
cairo_fill(cr);
}
static gboolean _slider_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _slider_draw(GtkWidget *widget, cairo_t *cr)
{
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_SLIDER(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
......@@ -499,9 +498,6 @@ static gboolean _slider_expose(GtkWidget *widget, GdkEventExpose *event)
_slider_get_value_area(widget, &vr);
/* create cairo context */
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
/* hardcode state for the rest of control */
state = GTK_STATE_NORMAL;
......@@ -587,8 +583,6 @@ static gboolean _slider_expose(GtkWidget *widget, GdkEventExpose *event)
DTGTK_SLIDER_ADJUST_BUTTON_WIDTH,
DTGTK_SLIDER_ADJUST_BUTTON_WIDTH - DT_PIXEL_APPLY_DPI(4), CPF_DIRECTION_DOWN);
cairo_destroy(cr);
return TRUE;
}
......
......@@ -28,14 +28,14 @@ static void _togglebutton_get_preferred_width(GtkWidget *widget, gint *minimal_w
static void _togglebutton_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height);
static void _togglebutton_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
// static void _togglebutton_realize(GtkWidget *widget);
static gboolean _togglebutton_expose(GtkWidget *widget, GdkEventExpose *event);
static gboolean _togglebutton_draw(GtkWidget *widget, cairo_t *cr);
static void _togglebutton_destroy(GtkObject *object);
void temp()
{
_togglebutton_size_allocate(NULL, NULL);
_togglebutton_size_request(NULL, NULL);
_togglebutton_expose(NULL, NULL);
_togglebutton_draw(NULL, NULL);
_togglebutton_destroy(NULL);
}
......@@ -45,7 +45,7 @@ static void _togglebutton_class_init(GtkDarktableToggleButtonClass *klass)
widget_class->get_preferred_width = _togglebutton_get_preferred_width;
widget_class->get_preferred_height = _togglebutton_get_preferred_height;
widget_class->expose_event = _togglebutton_expose;
widget_class->draw = _togglebutton_draw;
}
static void _togglebutton_init(GtkDarktableToggleButton *slider)
......@@ -128,11 +128,11 @@ static void _togglebutton_destroy(GtkObject *object)
}
}
static gboolean _togglebutton_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _togglebutton_draw(GtkWidget *widget, cairo_t *cr)
{
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_TOGGLEBUTTON(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkStyle *style = gtk_widget_get_style(widget);
int state = gtk_widget_get_state(widget);
......@@ -159,9 +159,6 @@ static gboolean _togglebutton_expose(GtkWidget *widget, GdkEventExpose *event)
flags &= ~CPF_PRELIGHT;
/* begin cairo drawing */
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int x = allocation.x;
......@@ -183,8 +180,8 @@ static gboolean _togglebutton_expose(GtkWidget *widget, GdkEventExpose *event)
else if(!(flags & CPF_BG_TRANSPARENT))
{
/* draw default boxed button */
gtk_paint_box(gtk_widget_get_style(widget), gdk_cairo_create(gtk_widget_get_window(widget)),
gtk_widget_get_state(widget), GTK_SHADOW_OUT, widget, "button", x, y, width, height);
gtk_paint_box(gtk_widget_get_style(widget), cr, gtk_widget_get_state(widget), GTK_SHADOW_OUT, widget,
"button", x, y, width, height);
}
......@@ -233,8 +230,6 @@ static gboolean _togglebutton_expose(GtkWidget *widget, GdkEventExpose *event)
g_object_unref(layout);
}
cairo_destroy(cr);
return FALSE;
}
......
......@@ -32,7 +32,7 @@ static void _tristatebutton_get_preferred_height(GtkWidget *widget, gint *minima
gint *natural_height);
// static void _tristatebutton_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
// static void _tristatebutton_realize(GtkWidget *widget);
static gboolean _tristatebutton_expose(GtkWidget *widget, GdkEventExpose *event);
static gboolean _tristatebutton_draw(GtkWidget *widget, cairo_t *cr);
// static void _tristatebutton_destroy(GtkObject *object);
static void _tristate_emit_state_changed_signal(GtkDarktableTriStateButton *ts)
......@@ -48,7 +48,7 @@ static void _tristatebutton_class_init(GtkDarktableTriStateButtonClass *klass)
widget_class->get_preferred_width = _tristatebutton_get_preferred_width;
widget_class->get_preferred_height = _tristatebutton_get_preferred_height;
// widget_class->size_allocate = _tristatebutton_size_allocate;
widget_class->expose_event = _tristatebutton_expose;
widget_class->draw = _tristatebutton_draw;
// object_class->destroy = _tristatebutton_destroy;
_tristatebutton_signals[STATE_CHANGED]
......@@ -139,11 +139,11 @@ static void _tristatebutton_get_preferred_height(GtkWidget *widget, gint *minima
*minimal_height = *natural_height = requisition.height;
}
static gboolean _tristatebutton_expose(GtkWidget *widget, GdkEventExpose *event)
static gboolean _tristatebutton_draw(GtkWidget *widget, cairo_t *cr)
{
g_return_val_if_fail(widget != NULL, FALSE);
g_return_val_if_fail(DTGTK_IS_TRISTATEBUTTON(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
GtkStyle *style = gtk_widget_get_style(widget);
int state = gtk_widget_get_state(widget);
......@@ -165,9 +165,6 @@ static gboolean _tristatebutton_expose(GtkWidget *widget, GdkEventExpose *event)
/* begin cairo drawing */
cairo_t *cr;
cr = gdk_cairo_create(gtk_widget_get_window(widget));
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int x = allocation.x;
......@@ -260,8 +257,6 @@ static gboolean _tristatebutton_expose(GtkWidget *widget, GdkEventExpose *event)
g_object_unref(layout);
}
cairo_destroy(cr);
return FALSE;
}
......
......@@ -311,7 +311,7 @@ void dt_gui_key_accel_block_on_focus_connect(GtkWidget *w)
(gpointer)w);
}
static gboolean expose_borders(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
static gboolean draw_borders(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
// draw arrows on borders
if(!dt_control_running()) return TRUE;
......@@ -440,23 +440,19 @@ static gboolean expose_borders(GtkWidget *widget, GdkEventExpose *event, gpointe
cairo_fill(cr);
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_set_source_surface(crf, cst, 0, 0);
cairo_paint(crf);
cairo_surface_destroy(cst);
return TRUE;
}
static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
static gboolean draw(GtkWidget *da, cairo_t *cr, gpointer user_data)
{
dt_control_expose(NULL);
if(darktable.gui->surface)
{
cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(da));
cairo_set_source_surface(cr, darktable.gui->surface, 0, 0);
cairo_paint(cr);
cairo_destroy(cr);
}
if(darktable.lib->proxy.colorpicker.module)
......@@ -497,13 +493,13 @@ void dt_gui_gtk_quit()
GtkWidget *widget;
widget = darktable.gui->widgets.left_border;
g_signal_handlers_block_by_func(widget, expose_borders, GINT_TO_POINTER(0));
g_signal_handlers_block_by_func(widget, draw_borders, GINT_TO_POINTER(0));
widget = darktable.gui->widgets.right_border;
g_signal_handlers_block_by_func(widget, expose_borders, GINT_TO_POINTER(1));
g_signal_handlers_block_by_func(widget, draw_borders, GINT_TO_POINTER(1));
widget = darktable.gui->widgets.top_border;
g_signal_handlers_block_by_func(widget, expose_borders, GINT_TO_POINTER(2));
g_signal_handlers_block_by_func(widget, draw_borders, GINT_TO_POINTER(2));
widget = darktable.gui->widgets.bottom_border;
g_signal_handlers_block_by_func(widget, expose_borders, GINT_TO_POINTER(3));
g_signal_handlers_block_by_func(widget, draw_borders, GINT_TO_POINTER(3));
}
gboolean dt_gui_quit_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data)
......@@ -799,7 +795,7 @@ int dt_gui_gtk_init(dt_gui_gtk_t *gui, int argc, char *argv[])
g_signal_connect(G_OBJECT(widget), "key-press-event", G_CALLBACK(key_pressed), NULL);
g_signal_connect(G_OBJECT(widget), "configure-event", G_CALLBACK(configure), NULL);
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(expose), NULL);
g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(draw), NULL);
g_signal_connect(G_OBJECT(widget), "motion-notify-event", G_CALLBACK(mouse_moved), NULL);
g_signal_connect(G_OBJECT(widget), "leave-notify-event", G_CALLBACK(center_leave), NULL);
g_signal_connect(G_OBJECT(widget), "enter-notify-event", G_CALLBACK(center_enter), NULL);
......@@ -810,25 +806,25 @@ int dt_gui_gtk_init(dt_gui_gtk_t *gui, int argc, char *argv[])
// leave-notify-event
widget = darktable.gui->widgets.left_border;
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(expose_borders), GINT_TO_POINTER(0));
g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(draw_borders), GINT_TO_POINTER(0));
g_signal_connect(G_OBJECT(widget), "button-press-event", G_CALLBACK(borders_button_pressed),
darktable.gui->ui);
g_signal_connect(G_OBJECT(widget), "scroll-event", G_CALLBACK(borders_scrolled), GINT_TO_POINTER(0));
g_object_set_data(G_OBJECT(widget), "border", GINT_TO_POINTER(0));
widget = darktable.gui->widgets.right_border;
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(expose_borders), GINT_TO_POINTER(1));
g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(draw_borders), GINT_TO_POINTER(1));
g_signal_connect(G_OBJECT(widget), "button-press-event", G_CALLBACK(borders_button_pressed),
darktable.gui->ui);
g_signal_connect(G_OBJECT(widget), "scroll-event", G_CALLBACK(borders_scrolled), GINT_TO_POINTER(1));
g_object_set_data(G_OBJECT(widget), "border", GINT_TO_POINTER(1));
widget = darktable.gui->widgets.top_border;
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(expose_borders), GINT_TO_POINTER(2));
g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(draw_borders), GINT_TO_POINTER(2));
g_signal_connect(G_OBJECT(widget), "button-press-event", G_CALLBACK(borders_button_pressed),
darktable.gui->ui);
g_signal_connect(G_OBJECT(widget), "scroll-event", G_CALLBACK(borders_scrolled), GINT_TO_POINTER(2));
g_object_set_data(G_OBJECT(widget), "border", GINT_TO_POINTER(2));
widget = darktable.gui->widgets.bottom_border;
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(expose_borders), GINT_TO_POINTER(3));
g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(draw_borders), GINT_TO_POINTER(3));
g_signal_connect(G_OBJECT(widget), "button-press-event", G_CALLBACK(borders_button_pressed),
darktable.gui->ui);
g_signal_connect(G_OBJECT(widget), "scroll-event", G_CALLBACK(borders_scrolled), GINT_TO_POINTER(3));
......@@ -970,7 +966,7 @@ void dt_gui_gtk_run(dt_gui_gtk_t *gui)
gtk_widget_get_allocation(widget, &allocation);
darktable.gui->surface
= dt_cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height);
// need to pre-configure views to avoid crash caused by expose-event coming before configure-event
// need to pre-configure views to avoid crash caused by draw coming before configure-event
darktable.control->tabborder = 8;
int tb = darktable.control->tabborder;
dt_view_manager_configure(darktable.view_manager, allocation.width - 2 * tb, allocation.height - 2 * tb);
......
......@@ -925,7 +925,7 @@ static void get_params(dt_iop_atrous_params_t *p, const int ch, const double mou
}
}
static gboolean area_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
static gboolean area_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
dt_iop_module_t *self = (dt_iop_module_t *)user_data;
dt_iop_atrous_gui_data_t *c = (dt_iop_atrous_gui_data_t *)self->gui_data;
......@@ -1175,10 +1175,8 @@ static gboolean area_expose(GtkWidget *widget, GdkEventExpose *event, gpointer u
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_set_source_surface(crf, cst, 0, 0);
cairo_paint(crf);
cairo_surface_destroy(cst);
return TRUE;
}
......@@ -1401,7 +1399,7 @@ void gui_init(struct dt_iop_module_t *self)
gtk_widget_add_events(GTK_WIDGET(c->area), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK);
g_signal_connect(G_OBJECT(c->area), "expose-event", G_CALLBACK(area_expose), self);
g_signal_connect(G_OBJECT(c->area), "draw", G_CALLBACK(area_draw), self);
g_signal_connect(G_OBJECT(c->area), "button-press-event", G_CALLBACK(area_button_press), self);
g_signal_connect(G_OBJECT(c->area), "button-release-event", G_CALLBACK(area_button_release), self);
g_signal_connect(G_OBJECT(c->area), "motion-notify-event", G_CALLBACK(area_motion_notify), self);
......
......@@ -819,7 +819,7 @@ static float to_lin(const float x, float base)
return x;
}
static gboolean dt_iop_basecurve_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
static gboolean dt_iop_basecurve_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
dt_iop_module_t *self = (dt_iop_module_t *)user_data;
dt_iop_basecurve_gui_data_t *c = (dt_iop_basecurve_gui_data_t *)self->gui_data;
......@@ -945,10 +945,8 @@ static gboolean dt_iop_basecurve_expose(GtkWidget *widget, GdkEventExpose *event
cairo_stroke(cr);
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_set_source_surface(crf, cst, 0, 0);
cairo_paint(crf);
cairo_surface_destroy(cst);
return TRUE;
}
......@@ -1152,7 +1150,7 @@ void gui_init(struct dt_iop_module_t *self)
gtk_widget_add_events(GTK_WIDGET(c->area), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK);
g_signal_connect(G_OBJECT(c->area), "expose-event", G_CALLBACK(dt_iop_basecurve_expose), self);
g_signal_connect(G_OBJECT(c->area), "draw", G_CALLBACK(dt_iop_basecurve_draw), self);
g_signal_connect(G_OBJECT(c->area), "button-press-event", G_CALLBACK(dt_iop_basecurve_button_press), self);
g_signal_connect(G_OBJECT(c->area), "motion-notify-event", G_CALLBACK(dt_iop_basecurve_motion_notify), self);
g_signal_connect(G_OBJECT(c->area), "leave-notify-event", G_CALLBACK(dt_iop_basecurve_leave_notify), self);
......
......@@ -591,7 +591,7 @@ static void request_pick_toggled_frame(GtkToggleButton *togglebutton, dt_iop_mod
request_pick_toggled(togglebutton, self);
}
static gboolean borders_expose(GtkWidget *widget, GdkEventExpose *event, dt_iop_module_t *self)
static gboolean borders_draw(GtkWidget *widget, cairo_t *cr, dt_iop_module_t *self)
{
if(darktable.gui->reset) return FALSE;
if(self->picked_output_color_max[0] < 0) return FALSE;
......@@ -1119,7 +1119,7 @@ void gui_init(struct dt_iop_module_t *self)
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(g->frame_picker), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(self->widget), box, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(self->widget), "expose-event", G_CALLBACK(borders_expose), self);
g_signal_connect(G_OBJECT(self->widget), "draw", G_CALLBACK(borders_draw), self);