From f0e65558e26ed14400a3826af023a033b76d0c9d Mon Sep 17 00:00:00 2001
From: Bogdan Gheorghe
Date: Fri, 19 Jun 2009 19:59:39 +0000
Subject: 273850 SWT.MouseDown event not fired on combo widget arrow down (GTK
only)
---
.../gtk/org/eclipse/swt/widgets/Combo.java | 46 ++++++++++++++++++++--
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 029149cc62..50f27bc71f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -56,12 +56,12 @@ import org.eclipse.swt.events.*;
* @see Sample code and further information
*/
public class Combo extends Composite {
- int /*long*/ buttonHandle, entryHandle, listHandle, textRenderer, cellHandle, popupHandle;
+ int /*long*/ buttonHandle, entryHandle, listHandle, textRenderer, cellHandle, popupHandle, menuHandle;
int lastEventTime, visibleCount = 5;
int /*long*/ gdkEventKey = 0;
int fixStart = -1, fixEnd = -1;
String [] items = new String [0];
- boolean ignoreSelect, lockText;
+ boolean ignoreSelect, lockText, selectionAdded;
static final int INNER_BORDER = 2;
@@ -459,6 +459,15 @@ void createHandle (int index) {
OS.gtk_cell_layout_pack_start (handle, textRenderer, true);
OS.gtk_cell_layout_set_attributes (handle, textRenderer, OS.text, 0, 0);
+ /*
+ * Feature in GTK. Toggle button creation differs between GTK versions. The
+ * fix is to call size_request() to force the creation of the button
+ * for those versions of GTK that defer the creation.
+ */
+ if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+ OS.gtk_widget_size_request(handle, new GtkRequisition());
+ }
+ if (popupHandle != 0) findMenuHandle ();
/*
* Feature in GTK. There is no API to query the button
* handle from a combo box although it is possible to get the
@@ -564,6 +573,7 @@ void deregister () {
if (buttonHandle != 0) display.removeWidget (buttonHandle);
if (entryHandle != 0) display.removeWidget (entryHandle);
if (listHandle != 0) display.removeWidget (listHandle);
+ if (menuHandle != 0) display.removeWidget (menuHandle);
int /*long*/ imContext = imContext ();
if (imContext != 0) display.removeWidget (imContext);
}
@@ -610,6 +620,23 @@ int /*long*/ findPopupHandle (int /*long*/ oldList) {
return hdl;
}
+void findMenuHandle() {
+ OS.gtk_container_forall (popupHandle, display.allChildrenProc, 0);
+ if (display.allChildren != 0) {
+ int /*long*/ list = display.allChildren;
+ while (list != 0) {
+ int /*long*/ widget = OS.g_list_data (list);
+ if (OS.G_OBJECT_TYPE (widget) == OS.GTK_TYPE_MENU ()) {
+ menuHandle = widget;
+ break;
+ }
+ list = OS.g_list_next (list);
+ }
+ OS.g_list_free (display.allChildren);
+ display.allChildren = 0;
+ }
+}
+
void fixModal (int /*long*/ group, int /*long*/ modalGroup) {
if (popupHandle != 0) {
if (group != 0) {
@@ -677,7 +704,7 @@ void hookEvents () {
}
int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK |
OS.GDK_BUTTON_RELEASE_MASK;
- int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, listHandle};
+ int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, listHandle, menuHandle};
for (int i=0; i