summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-10-26 14:52:30 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-10-26 14:52:30 -0400
commita886f16168f44eb14dce55165728859cc8ee3baa (patch)
tree77507a36826a1bbab089f5996d8b8b798895d212 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets
parentd0069d7ed7376b10efa426e883f2b4851a6c7c22 (diff)
downloadeclipse.platform.swt-a886f16168f44eb14dce55165728859cc8ee3baa.tar.gz
eclipse.platform.swt-a886f16168f44eb14dce55165728859cc8ee3baa.tar.xz
eclipse.platform.swt-a886f16168f44eb14dce55165728859cc8ee3baa.zip
Bug 392841 - [GTK3] Need to replace expose-event signal with draw signal
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java68
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java53
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java39
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java13
9 files changed, 152 insertions, 125 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index e8c43471cc..d7e27f6ae8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
@@ -162,6 +162,15 @@ long /*int*/ gtk_commit (long /*int*/ imcontext, long /*int*/ text) {
return super.gtk_commit (imcontext, text);
}
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if ((state & OBSCURED) != 0) return 0;
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ long /*int*/ result = super.gtk_draw (widget, cairo);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
if ((state & OBSCURED) != 0) return 0;
boolean isFocus = caret != null && caret.isFocusCaret ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index e23bf0a52d..6ffa359a07 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -725,57 +725,31 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
if ((style & SWT.NO_MERGE_PAINTS) == 0) {
return super.gtk_expose_event (widget, eventPtr);
}
- if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
+ if (!hooksPaint ()) return 0;
GdkEventExpose gdkEvent = new GdkEventExpose ();
OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
long /*int*/ [] rectangles = new long /*int*/ [1];
int [] n_rectangles = new int [1];
- if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
- int num = Cairo.cairo_region_num_rectangles (gdkEvent.region);
- for (int n = 0; n < num; n++) {
- Cairo.cairo_region_get_rectangle (gdkEvent.region, n, rectangles[n]);
- }
- cairo_rectangle_int_t rect = new cairo_rectangle_int_t ();
- for (int i=0; i<n_rectangles[0]; i++) {
- Event event = new Event ();
- Cairo.memmove (rect, rectangles [0] + i * cairo_rectangle_int_t.sizeof, cairo_rectangle_int_t.sizeof);
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
- long /*int*/ damageRgn = Cairo.cairo_region_create ();
- Cairo.cairo_region_union_rectangle (damageRgn, rect);
- GCData data = new GCData ();
- data.damageRgn = damageRgn;
- GC gc = event.gc = GC.gtk_new (this, data);
- sendEvent (SWT.Paint, event);
- gc.dispose ();
- Cairo.cairo_region_destroy (damageRgn);
- event.gc = null;
- }
- } else {
- OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles);
- GdkRectangle rect = new GdkRectangle ();
- for (int i=0; i<n_rectangles[0]; i++) {
- Event event = new Event ();
- OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof);
- event.x = rect.x;
- event.y = rect.y;
- event.width = rect.width;
- event.height = rect.height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
- long /*int*/ damageRgn = OS.gdk_region_new ();
- OS.gdk_region_union_with_rect (damageRgn, rect);
- GCData data = new GCData ();
- data.damageRgn = damageRgn;
- GC gc = event.gc = GC.gtk_new (this, data);
- sendEvent (SWT.Paint, event);
- gc.dispose ();
- OS.gdk_region_destroy (damageRgn);
- event.gc = null;
- }
- }
+ OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles);
+ GdkRectangle rect = new GdkRectangle ();
+ for (int i=0; i<n_rectangles[0]; i++) {
+ Event event = new Event ();
+ OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof);
+ event.x = rect.x;
+ event.y = rect.y;
+ event.width = rect.width;
+ event.height = rect.height;
+ if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ long /*int*/ damageRgn = OS.gdk_region_new ();
+ OS.gdk_region_union_with_rect (damageRgn, rect);
+ GCData data = new GCData ();
+ data.damageRgn = damageRgn;
+ GC gc = event.gc = GC.gtk_new (this, data);
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ OS.gdk_region_destroy (damageRgn);
+ event.gc = null;
+ }
OS.g_free (rectangles [0]);
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index aa3762cd38..18815068a5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -172,6 +172,9 @@ boolean drawGripper (int x, int y, int width, int height, boolean vertical) {
return true;
}
+void drawWidget (GC gc) {
+}
+
void enableWidget (boolean enabled) {
OS.gtk_widget_set_sensitive (handle, enabled);
}
@@ -315,9 +318,11 @@ void hookEvents () {
long /*int*/ paintHandle = paintHandle ();
int paintMask = OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK;
OS.gtk_widget_add_events (paintHandle, paintMask);
- if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
+
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT_INVERSE], false);
}
+
/*
* As of GTK 2.17.11, obscured controls no longer send expose
* events. It is no longer necessary to track visiblity notify
@@ -326,9 +331,7 @@ void hookEvents () {
if (OS.GTK_VERSION < OS.VERSION (2, 17, 11)) {
OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [VISIBILITY_NOTIFY_EVENT], 0, display.closures [VISIBILITY_NOTIFY_EVENT], false);
}
- if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
- OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true);
- }
+ OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true);
/* Connect the Input Method signals */
OS.g_signal_connect_closure_by_id (handle, display.signalIds [REALIZE], 0, display.closures [REALIZE], true);
@@ -345,6 +348,10 @@ void hookEvents () {
OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true);
}
+boolean hooksPaint () {
+ return hooks (SWT.Paint) || filters (SWT.Paint);
+}
+
long /*int*/ hoverProc (long /*int*/ widget) {
int [] x = new int [1], y = new int [1], mask = new int [1];
gdk_window_get_device_position (0, x, y, mask);
@@ -3017,9 +3024,32 @@ long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
return 0;
}
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if ((state & OBSCURED) != 0) return 0;
+ if (!hooksPaint ()) return 0;
+ GdkRectangle rect = new GdkRectangle ();
+ OS.gdk_cairo_get_clip_rectangle (cairo, rect);
+ Event event = new Event ();
+ event.count = 1;
+ event.x = rect.x;
+ event.y = rect.y;
+ event.width = rect.width;
+ event.height = rect.height;
+ if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+ GCData data = new GCData ();
+// data.damageRgn = gdkEvent.region;
+ data.cairo = cairo;
+ GC gc = event.gc = GC.gtk_new (this, data);
+ drawWidget (gc);
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ event.gc = null;
+ return 0;
+}
+
long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
if ((state & OBSCURED) != 0) return 0;
- if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
+ if (!hooksPaint ()) return 0;
GdkEventExpose gdkEvent = new GdkEventExpose ();
OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
Event event = new Event ();
@@ -3032,6 +3062,7 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
GCData data = new GCData ();
data.damageRgn = gdkEvent.region;
GC gc = event.gc = GC.gtk_new (this, data);
+ drawWidget (gc);
sendEvent (SWT.Paint, event);
gc.dispose ();
event.gc = null;
@@ -3289,11 +3320,15 @@ public long /*int*/ internal_new_GC (GCData data) {
checkWidget ();
long /*int*/ window = paintWindow ();
if (window == 0) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ gc;
- if (OS.USE_CAIRO) {
- gc = OS.gdk_cairo_create (window);
+ long /*int*/ gc = data.cairo;
+ if (gc != 0) {
+ Cairo.cairo_reference (gc);
} else {
- gc = OS.gdk_gc_new (window);
+ if (OS.USE_CAIRO) {
+ gc = OS.gdk_cairo_create (window);
+ } else {
+ gc = OS.gdk_gc_new (window);
+ }
}
if (gc == 0) error (SWT.ERROR_NO_HANDLES);
if (data != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 89f02622a6..b617c64042 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -2437,9 +2437,7 @@ void initializeCallbacks () {
signalIds [Widget.ENTER_NOTIFY_EVENT] = OS.g_signal_lookup (OS.enter_notify_event, OS.GTK_TYPE_WIDGET ());
signalIds [Widget.EVENT] = OS.g_signal_lookup (OS.event, OS.GTK_TYPE_WIDGET ());
signalIds [Widget.EVENT_AFTER] = OS.g_signal_lookup (OS.event_after, OS.GTK_TYPE_WIDGET ());
- if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
- signalIds [Widget.EXPOSE_EVENT] = OS.g_signal_lookup (OS.expose_event, OS.GTK_TYPE_WIDGET ());
- }
+ signalIds [Widget.EXPOSE_EVENT] = OS.g_signal_lookup (OS.GTK_VERSION >= OS.VERSION(3, 0, 0) ? OS.draw : OS.expose_event, OS.GTK_TYPE_WIDGET ());
signalIds [Widget.FOCUS] = OS.g_signal_lookup (OS.focus, OS.GTK_TYPE_WIDGET ());
signalIds [Widget.FOCUS_IN_EVENT] = OS.g_signal_lookup (OS.focus_in_event, OS.GTK_TYPE_WIDGET ());
signalIds [Widget.FOCUS_OUT_EVENT] = OS.g_signal_lookup (OS.focus_out_event, OS.GTK_TYPE_WIDGET ());
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 42945186d3..916a78fab4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -164,6 +164,26 @@ void createWidget (int index) {
initAccessible ();
}
+void drawWidget(GC gc) {
+ int selStart = selection.x;
+ int selEnd = selection.y;
+ if (selStart > selEnd) {
+ selStart = selection.y;
+ selEnd = selection.x;
+ }
+ // temporary code to disable text selection
+ selStart = selEnd = -1;
+ if ((state & DISABLED) != 0) gc.setForeground (disabledColor);
+ layout.draw (gc, 0, 0, selStart, selEnd, null, null);
+ if (hasFocus () && focusIndex != -1) {
+ Rectangle [] rects = getRectangles (focusIndex);
+ for (int i = 0; i < rects.length; i++) {
+ Rectangle rect = rects [i];
+ gc.drawFocus (rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+}
+
void enableWidget (boolean enabled) {
super.enableWidget (enabled);
if (isDisposed ()) return;
@@ -359,46 +379,6 @@ long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
return result;
}
-long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
- if ((state & OBSCURED) != 0) return 0;
- GdkEventExpose gdkEvent = new GdkEventExpose ();
- OS.memmove (gdkEvent, eventPtr, GdkEventExpose.sizeof);
- GCData data = new GCData ();
- data.damageRgn = gdkEvent.region;
- GC gc = GC.gtk_new (this, data);
- int selStart = selection.x;
- int selEnd = selection.y;
- if (selStart > selEnd) {
- selStart = selection.y;
- selEnd = selection.x;
- }
- // temporary code to disable text selection
- selStart = selEnd = -1;
- if ((state & DISABLED) != 0) gc.setForeground (disabledColor);
- layout.draw (gc, 0, 0, selStart, selEnd, null, null);
- if (hasFocus () && focusIndex != -1) {
- Rectangle [] rects = getRectangles (focusIndex);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- gc.drawFocus (rect.x, rect.y, rect.width, rect.height);
- }
- }
- if (hooks (SWT.Paint) || filters (SWT.Paint)) {
- Event event = new Event ();
- event.count = gdkEvent.count;
- event.x = gdkEvent.area_x;
- event.y = gdkEvent.area_y;
- event.width = gdkEvent.area_width;
- event.height = gdkEvent.area_height;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
- event.gc = gc;
- sendEvent (SWT.Paint, event);
- event.gc = null;
- }
- gc.dispose ();
- return 0;
-}
-
long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ eventPtr) {
long /*int*/ result = super.gtk_key_press_event (widget, eventPtr);
if (result != 0) return result;
@@ -466,6 +446,10 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
return result;
}
+boolean hooksPaint () {
+ return true;
+}
+
boolean mnemonicHit (char key) {
char uckey = Character.toUpperCase (key);
String parsedText = layout.getText();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index c6b59e03fd..b71470f2b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -845,9 +845,7 @@ void hookEvents () {
if (isCustomResize ()) {
int mask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK | OS.GDK_BUTTON_PRESS_MASK | OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK;
OS.gtk_widget_add_events (shellHandle, mask);
- if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures[EXPOSE_EVENT], false);
- }
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures[EXPOSE_EVENT], false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.closures [LEAVE_NOTIFY_EVENT], false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT], false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index 9b939b045c..bc9b9beea5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -1549,14 +1549,10 @@ long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
return super.gtk_event_after (widget, gdkEvent);
}
-long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
- if ((state & OBSCURED) != 0) return 0;
- long /*int*/ result = super.gtk_expose_event (widget, event);
+void drawMessage (long /*int*/ cr) {
if ((style & SWT.SINGLE) != 0 && message.length () > 0) {
long /*int*/ str = OS.gtk_entry_get_text (handle);
if (!gtk_widget_has_focus (handle) && OS.strlen (str) == 0) {
- GdkEventExpose gdkEvent = new GdkEventExpose ();
- OS.memmove (gdkEvent, event, GdkEventExpose.sizeof);
long /*int*/ window = paintWindow ();
int [] w = new int [1], h = new int [1];
gdk_window_get_size (window, w, h);
@@ -1600,11 +1596,11 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
GdkColor baseColor = new GdkColor ();
OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, baseColor);
if (OS.USE_CAIRO) {
- long /*int*/ cairo = OS.gdk_cairo_create(window);
+ long /*int*/ cairo = cr != 0 ? cr : OS.gdk_cairo_create(window);
Cairo.cairo_set_source_rgba(cairo, (textColor.red & 0xFFFF) / (float)0xFFFF, (textColor.green & 0xFFFF) / (float)0xFFFF, (textColor.blue & 0xFFFF) / (float)0xFFFF, 1);
Cairo.cairo_move_to(cairo, x, y);
OS.pango_cairo_show_layout(cairo, layout);
- Cairo.cairo_destroy(cairo);
+ if (cr != cairo) Cairo.cairo_destroy(cairo);
} else {
long /*int*/ gc = OS.gdk_gc_new (window);
OS.gdk_draw_layout_with_colors (window, gc, x, y, layout, textColor, baseColor);
@@ -1613,6 +1609,19 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
OS.g_object_unref (layout);
}
}
+}
+
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if ((state & OBSCURED) != 0) return 0;
+ long /*int*/ result = super.gtk_draw (widget, cairo);
+ drawMessage (cairo);
+ return result;
+}
+
+long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
+ if ((state & OBSCURED) != 0) return 0;
+ long /*int*/ result = super.gtk_expose_event (widget, event);
+ drawMessage (0);
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index fab79b306a..58959e7e63 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -493,23 +493,23 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
return 0;
}
-long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
- if ((state & OBSCURED) != 0) return 0;
+void drawTooltip (long /*int*/ cr) {
long /*int*/ window = gtk_widget_get_window (handle);
int x = BORDER + PADDING;
int y = BORDER + PADDING;
if (OS.USE_CAIRO) {
- long /*int*/ cairo = OS.gdk_cairo_create(window);
+ long /*int*/ cairo = cr != 0 ? cr : OS.gdk_cairo_create(window);
if (cairo == 0) error (SWT.ERROR_NO_HANDLES);
int count = borderPolygon.length / 2;
- if (count == 0) return 0;
- Cairo.cairo_set_line_width(cairo, 1);
- Cairo.cairo_move_to(cairo, borderPolygon[0], borderPolygon[1]);
- for (int i=1,j=2; i<count; i++,j+=2) {
- Cairo.cairo_line_to(cairo, borderPolygon[j]+0.5, borderPolygon[j+1]+0.5);
+ if (count != 0) {
+ Cairo.cairo_set_line_width(cairo, 1);
+ Cairo.cairo_move_to(cairo, borderPolygon[0], borderPolygon[1]);
+ for (int i=1,j=2; i<count; i++,j+=2) {
+ Cairo.cairo_line_to(cairo, borderPolygon[j]+0.5, borderPolygon[j+1]+0.5);
+ }
+ Cairo.cairo_close_path(cairo);
+ Cairo.cairo_stroke(cairo);
}
- Cairo.cairo_close_path(cairo);
- Cairo.cairo_stroke(cairo);
if (spikeAbove) y += TIP_HEIGHT;
if (layoutText != 0) {
byte[] buffer = null;
@@ -550,8 +550,8 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
Cairo.cairo_move_to(cairo, x, y);
OS.pango_cairo_show_layout(cairo, layoutMessage);
}
- Cairo.cairo_destroy(cairo);
- return 0;
+ if (cairo != cr) Cairo.cairo_destroy(cairo);
+ return;
}
long /*int*/ gdkGC = OS.gdk_gc_new (window);
OS.gdk_draw_polygon (window, gdkGC, 0, borderPolygon, borderPolygon.length / 2);
@@ -593,6 +593,17 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
OS.gdk_draw_layout (window, gdkGC, x, y, layoutMessage);
}
OS.g_object_unref (gdkGC);
+}
+
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if ((state & OBSCURED) != 0) return 0;
+ drawTooltip (cairo);
+ return 0;
+}
+
+long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
+ if ((state & OBSCURED) != 0) return 0;
+ drawTooltip (0);
return 0;
}
@@ -617,9 +628,7 @@ long /*int*/ gtk_size_allocate (long /*int*/ widget, long /*int*/ allocation) {
void hookEvents () {
if ((style & SWT.BALLOON) != 0) {
- if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
- OS.g_signal_connect_closure (handle, OS.expose_event, display.closures [EXPOSE_EVENT], false);
- }
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true);
OS.gtk_widget_add_events (handle, OS.GDK_BUTTON_PRESS_MASK);
OS.g_signal_connect_closure (handle, OS.button_press_event, display.closures [BUTTON_PRESS_EVENT], false);
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 7f990b7608..a6010807dd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -126,6 +126,7 @@ public abstract class Widget {
static final int EVENT_AFTER = 16;
static final int EXPAND_COLLAPSE_CURSOR_ROW = 17;
static final int EXPOSE_EVENT = 18;
+ static final int DRAW = EXPOSE_EVENT;
static final int EXPOSE_EVENT_INVERSE = 19;
static final int FOCUS = 20;
static final int FOCUS_IN_EVENT = 21;
@@ -783,6 +784,10 @@ long /*int*/ gtk_expand_collapse_cursor_row (long /*int*/ widget, long /*int*/ l
return 0;
}
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ return 0;
+}
+
long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
return 0;
}
@@ -2046,7 +2051,13 @@ long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ us
case ENTER_NOTIFY_EVENT: return gtk_enter_notify_event (handle, arg0);
case EVENT: return gtk_event (handle, arg0);
case EVENT_AFTER: return gtk_event_after (handle, arg0);
- case EXPOSE_EVENT: return gtk_expose_event (handle, arg0);
+ case EXPOSE_EVENT: {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ return gtk_draw (handle, arg0);
+ } else {
+ return gtk_expose_event (handle, arg0);
+ }
+ }
case FOCUS: return gtk_focus (handle, arg0);
case FOCUS_IN_EVENT: return gtk_focus_in_event (handle, arg0);
case FOCUS_OUT_EVENT: return gtk_focus_out_event (handle, arg0);