* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtklabel.h"
#include "gtkimage.h"
#include "gtkbox.h"
+#include "gtksettings.h"
#include "gtksizerequest.h"
+#include "gtkstylecontext.h"
#include "gtkwindowprivate.h"
+#ifdef GDK_WINDOWING_WAYLAND
+#include "wayland/gdkwayland.h"
+#endif
+
+
/**
* SECTION:gtktooltip
* @Short_description: Add tips to your widgets
tooltip->last_window = NULL;
- window = g_object_ref (gtk_window_new (GTK_WINDOW_POPUP));
+ window = gtk_window_new (GTK_WINDOW_POPUP);
screen = gtk_widget_get_screen (window);
visual = gdk_screen_get_rgba_visual (screen);
y = tooltip->last_y - height - 2;
}
+#ifdef GDK_WINDOWING_WAYLAND
+ /* set the transient parent on the tooltip when running with the Wayland
+ * backend to allow correct positioning of the tooltip windows */
+ if (GDK_IS_WAYLAND_DISPLAY (display))
+ {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (tooltip->tooltip_widget);
+ if (GTK_IS_WINDOW (toplevel))
+ gtk_window_set_transient_for (GTK_WINDOW (tooltip->current_window),
+ GTK_WINDOW (toplevel));
+ }
+#endif
+
gtk_window_move (GTK_WINDOW (tooltip->current_window), x, y);
gtk_widget_show (GTK_WIDGET (tooltip->current_window));
}
}
static gboolean
-tooltips_enabled (GdkWindow *window)
+tooltips_enabled (GdkEvent *event)
{
+ GdkDevice *source_device;
+ GdkInputSource source;
+ GdkWindow *window;
gboolean enabled;
- gboolean touchscreen;
GdkScreen *screen;
GtkSettings *settings;
+ window = event->any.window;
+ source_device = gdk_event_get_source_device (event);
+
+ if (!source_device)
+ return FALSE;
+
+ source = gdk_device_get_source (source_device);
screen = gdk_window_get_screen (window);
settings = gtk_settings_get_for_screen (screen);
g_object_get (settings,
- "gtk-touchscreen-mode", &touchscreen,
"gtk-enable-tooltips", &enabled,
NULL);
- return (!touchscreen && enabled);
+ if (enabled && source != GDK_SOURCE_TOUCHSCREEN)
+ return TRUE;
+
+ return FALSE;
}
void
GdkDisplay *display;
GtkTooltip *current_tooltip;
- if (!tooltips_enabled (event->any.window))
+ if (!tooltips_enabled (event))
return;
/* Returns coordinates relative to has_tooltip_widget's allocation. */