diff options
| author | Alexander Kurtakov | 2017-02-15 09:20:20 +0000 |
|---|---|---|
| committer | Alexander Kurtakov | 2017-02-15 09:20:20 +0000 |
| commit | 3ead1bbd14e89294aeaba6f0e1b7ce8f0e2b1522 (patch) | |
| tree | 777d1feb0b93d4632144be3694c7816ff374c351 | |
| parent | 34e1c1ed3a200da94dc833627f60ed56dc75b362 (diff) | |
| download | eclipse.platform.swt-3ead1bbd14e89294aeaba6f0e1b7ce8f0e2b1522.tar.gz eclipse.platform.swt-3ead1bbd14e89294aeaba6f0e1b7ce8f0e2b1522.tar.xz eclipse.platform.swt-3ead1bbd14e89294aeaba6f0e1b7ce8f0e2b1522.zip | |
Revert "Bug 500013 - [Wayland] Keyboard Left and Right Arrow keys are very slow or unresponsive "
This reverts commit 34e1c1ed3a200da94dc833627f60ed56dc75b362.
Change-Id: Ie33fecb562379fe3616a9c2592b1aa9819deb1af
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java | 56 | ||||
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java | 109 |
2 files changed, 53 insertions, 112 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 eca258b90c..8843f9148d 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 @@ -42,7 +42,6 @@ import org.eclipse.swt.internal.gtk.*; public class Canvas extends Composite { Caret caret; IME ime; - boolean drawFlag; Canvas () {} @@ -168,60 +167,13 @@ long /*int*/ gtk_commit (long /*int*/ imcontext, long /*int*/ text) { @Override long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) { if ((state & OBSCURED) != 0) return 0; - long /*int*/ result; - if ( OS.GTK_VERSION < OS.VERSION(3, 22, 0)) { - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - result = super.gtk_draw (widget, cairo); - if (isFocus) caret.setFocus (); - } else { - result = super.gtk_draw (widget, cairo); - if (caret != null && caret.isDrawing) { - drawCaret(widget,cairo); - caret.isDrawing = false; - } - } + boolean isFocus = caret != null && caret.isFocusCaret (); + if (isFocus) caret.killFocus (); + long /*int*/ result = super.gtk_draw (widget, cairo); + if (isFocus) caret.setFocus (); return result; } -private void drawCaret (long /*int*/ widget, long /*int*/ cairo) { - if(this.isDisposed()) return; - if (cairo == 0) error(SWT.ERROR_NO_HANDLES); - Cairo.cairo_save(cairo); - if (!drawFlag) { - Cairo.cairo_set_source_rgb(cairo, 1, 1, 1); - drawFlag = true; - } else { - drawFlag = false; - } - Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_DIFFERENCE); - if (caret.image != null && !caret.image.isDisposed() && caret.image.mask == 0) { - long /*int*/ surface = Cairo.cairo_get_target(cairo); - int nWidth = 0; - switch (Cairo.cairo_surface_get_type(surface)) { - case Cairo.CAIRO_SURFACE_TYPE_IMAGE: - nWidth = Cairo.cairo_image_surface_get_width(surface); - break; - case Cairo.CAIRO_SURFACE_TYPE_XLIB: - nWidth = Cairo.cairo_xlib_surface_get_width(surface); - break; - } - int nX =caret.x; - if ((style & SWT.MIRRORED) != 0) nX = getClientWidth () - nWidth - nX; - Cairo.cairo_translate(cairo, nX, caret.y); - Cairo.cairo_set_source_surface(cairo, caret.image.surface, 0, 0); - Cairo.cairo_paint(cairo); - } else { - int nWidth = caret.width, nHeight = caret.height; - if (nWidth <= 0) nWidth = Caret.DEFAULT_WIDTH; - int nX = caret.x; - if ((style & SWT.MIRRORED) != 0) nX = getClientWidth () - nWidth - nX; - Cairo.cairo_rectangle(cairo, nX, caret.y, nWidth, nHeight); - } - Cairo.cairo_fill(cairo); - Cairo.cairo_restore(cairo); -} - @Override long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) { if ((state & OBSCURED) != 0) return 0; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java index bceeec6637..be0015207c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java @@ -38,7 +38,7 @@ import org.eclipse.swt.internal.gtk.*; public class Caret extends Widget { Canvas parent; int x, y, width, height; - boolean isVisible, isShowing, isDrawing; + boolean isVisible, isShowing; int blinkRate; Image image; Font font; @@ -99,75 +99,64 @@ void createWidget (int index) { boolean drawCaret () { if (parent == null) return false; if (parent.isDisposed ()) return false; - if (OS.GTK_VERSION < OS.VERSION (3, 22, 0)) { - long /*int*/ window = parent.paintWindow (); - if (OS.USE_CAIRO) { - long /*int*/ cairo = OS.gdk_cairo_create(window); - if (cairo == 0) error(SWT.ERROR_NO_HANDLES); - Cairo.cairo_set_source_rgb(cairo, 1, 1, 1); - Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_DIFFERENCE); - if (image != null && !image.isDisposed() && image.mask == 0) { - long /*int*/ surface = Cairo.cairo_get_target(cairo); - int nWidth = 0; - switch (Cairo.cairo_surface_get_type(surface)) { - case Cairo.CAIRO_SURFACE_TYPE_IMAGE: - nWidth = Cairo.cairo_image_surface_get_width(surface); - break; - case Cairo.CAIRO_SURFACE_TYPE_XLIB: - nWidth = Cairo.cairo_xlib_surface_get_width(surface); - break; - } - int nX = x; - if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX; - Cairo.cairo_translate(cairo, nX, y); - Cairo.cairo_set_source_surface(cairo, image.surface, 0, 0); - Cairo.cairo_paint(cairo); - } else { - int nWidth = width, nHeight = height; - if (nWidth <= 0) nWidth = DEFAULT_WIDTH; - int nX = x; - if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX; - Cairo.cairo_rectangle(cairo, nX, y, nWidth, nHeight); - - } - Cairo.cairo_fill(cairo); - Cairo.cairo_destroy(cairo); - return true; - } - long /*int*/ gc = OS.gdk_gc_new (window); - GdkColor color = new GdkColor (); - color.red = (short) 0xffff; - color.green = (short) 0xffff; - color.blue = (short) 0xffff; - long /*int*/ colormap = OS.gdk_colormap_get_system (); - OS.gdk_colormap_alloc_color (colormap, color, true, true); - OS.gdk_gc_set_foreground (gc, color); - OS.gdk_gc_set_function (gc, OS.GDK_XOR); + long /*int*/ window = parent.paintWindow (); + if (OS.USE_CAIRO) { + long /*int*/ cairo = OS.gdk_cairo_create(window); + if (cairo == 0) error(SWT.ERROR_NO_HANDLES); + Cairo.cairo_set_source_rgb(cairo, 1, 1, 1); + Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_DIFFERENCE); if (image != null && !image.isDisposed() && image.mask == 0) { - int[] width = new int[1]; int[] height = new int[1]; - OS.gdk_pixmap_get_size (image.pixmap, width, height); - int nX = x; - if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - width[0] - nX; - OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, nX, y, width[0], height[0]); + long /*int*/ surface = Cairo.cairo_get_target(cairo); + int nWidth = 0; + switch (Cairo.cairo_surface_get_type(surface)) { + case Cairo.CAIRO_SURFACE_TYPE_IMAGE: + nWidth = Cairo.cairo_image_surface_get_width(surface); + break; + case Cairo.CAIRO_SURFACE_TYPE_XLIB: + nWidth = Cairo.cairo_xlib_surface_get_width(surface); + break; + } + int nX = x; + if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX; + Cairo.cairo_translate(cairo, nX, y); + Cairo.cairo_set_source_surface(cairo, image.surface, 0, 0); + Cairo.cairo_paint(cairo); } else { int nWidth = width, nHeight = height; if (nWidth <= 0) nWidth = DEFAULT_WIDTH; int nX = x; if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX; - OS.gdk_draw_rectangle (window, gc, 1, nX, y, nWidth, nHeight); + Cairo.cairo_rectangle(cairo, nX, y, nWidth, nHeight); } - OS.g_object_unref (gc); - OS.gdk_colormap_free_colors (colormap, color, 1); + Cairo.cairo_fill(cairo); + Cairo.cairo_destroy(cairo); return true; + } + long /*int*/ gc = OS.gdk_gc_new (window); + GdkColor color = new GdkColor (); + color.red = (short) 0xffff; + color.green = (short) 0xffff; + color.blue = (short) 0xffff; + long /*int*/ colormap = OS.gdk_colormap_get_system (); + OS.gdk_colormap_alloc_color (colormap, color, true, true); + OS.gdk_gc_set_foreground (gc, color); + OS.gdk_gc_set_function (gc, OS.GDK_XOR); + if (image != null && !image.isDisposed() && image.mask == 0) { + int[] width = new int[1]; int[] height = new int[1]; + OS.gdk_pixmap_get_size (image.pixmap, width, height); + int nX = x; + if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - width[0] - nX; + OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, nX, y, width[0], height[0]); } else { - if (isDrawing) { - return false; - } else { - isDrawing = true; - OS.gtk_widget_queue_draw(parent.handle); - return true; - } + int nWidth = width, nHeight = height; + if (nWidth <= 0) nWidth = DEFAULT_WIDTH; + int nX = x; + if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX; + OS.gdk_draw_rectangle (window, gc, 1, nX, y, nWidth, nHeight); } + OS.g_object_unref (gc); + OS.gdk_colormap_free_colors (colormap, color, 1); + return true; } /** |
