1
0
Fork 0

ui: Kill tooltips

After the changes in style handling in GTK+, mutter's tooltips no
longer match the tooltip style used in applications. Given that
all buttons in the default layout are well-known, killing tooltips
altogether rather than fixing the styling issues looks like a valid
approach.

https://bugzilla.gnome.org/show_bug.cgi?id=645101
This commit is contained in:
Florian Müllner 2011-03-18 13:25:59 +01:00
parent f2f500836e
commit 8ca86fa8bf
4 changed files with 0 additions and 372 deletions

View file

@ -130,8 +130,6 @@ libmutter_la_SOURCES = \
core/core.h \
ui/ui.h \
inlinepixbufs.h \
ui/fixedtip.c \
ui/fixedtip.h \
ui/frames.c \
ui/frames.h \
ui/menu.c \

View file

@ -1,136 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* Mutter fixed tooltip routine */
/*
* Copyright (C) 2001 Havoc Pennington
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <config.h>
#include "fixedtip.h"
#include "ui.h"
/**
* The floating rectangle. This is a GtkWindow, and it contains
* the "label" widget, below.
*/
static GtkWidget *tip = NULL;
/**
* The actual text that gets displayed.
*/
static GtkWidget *label = NULL;
/*
* X coordinate of the right-hand edge of the screen.
*
* \bug This appears to be a bug; screen_right_edge is calculated only when
* the window is redrawn. Actually we should never cache it because
* different windows are different sizes.
*/
static int screen_right_edge = 0;
/*
* Y coordinate of the bottom edge of the screen.
*
* \bug As with screen_right_edge.
*/
static int screen_bottom_edge = 0;
static gboolean
draw_handler (GtkWidget *tooltips,
cairo_t *cr,
gpointer user_data)
{
gtk_render_background (gtk_widget_get_style_context (tooltips),
cr,
0, 0,
gtk_widget_get_allocated_width (tooltips),
gtk_widget_get_allocated_height (tooltips));
return FALSE;
}
void
meta_fixed_tip_show (Display *xdisplay, int screen_number,
int root_x, int root_y,
const char *markup_text)
{
int w, h;
if (tip == NULL)
{
tip = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_type_hint (GTK_WINDOW(tip), GDK_WINDOW_TYPE_HINT_TOOLTIP);
{
GdkScreen *gdk_screen;
GdkRectangle monitor;
gint mon_num;
gdk_screen = gdk_display_get_screen (gdk_display_get_default (),
screen_number);
gtk_window_set_screen (GTK_WINDOW (tip),
gdk_screen);
mon_num = gdk_screen_get_monitor_at_point (gdk_screen, root_x, root_y);
gdk_screen_get_monitor_geometry (gdk_screen, mon_num, &monitor);
screen_right_edge = monitor.x + monitor.width;
screen_bottom_edge = monitor.y + monitor.height;
}
gtk_widget_set_app_paintable (tip, TRUE);
gtk_window_set_resizable (GTK_WINDOW (tip), FALSE);
gtk_widget_set_name (tip, "gtk-tooltips");
gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
g_signal_connect (tip, "draw",
G_CALLBACK (draw_handler), NULL);
label = gtk_label_new (NULL);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
gtk_widget_show (label);
gtk_container_add (GTK_CONTAINER (tip), label);
g_signal_connect (tip, "destroy",
G_CALLBACK (gtk_widget_destroyed), &tip);
}
gtk_label_set_markup (GTK_LABEL (label), markup_text);
gtk_window_get_size (GTK_WINDOW (tip), &w, &h);
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
root_x = MAX(0, root_x - w);
if ((root_x + w) > screen_right_edge)
root_x -= (root_x + w) - screen_right_edge;
gtk_window_move (GTK_WINDOW (tip), root_x, root_y);
gtk_widget_show (tip);
}
void
meta_fixed_tip_hide (void)
{
if (tip)
{
gtk_widget_destroy (tip);
tip = NULL;
}
}

View file

@ -1,69 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2001 Havoc Pennington
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
/**
* \file fixedtip.h Mutter fixed tooltip routine
*
* Sometimes we want to display a small floating rectangle with helpful
* text near the pointer. For example, if the user holds the mouse over
* the maximise button, we can display a tooltip saying "Maximize".
* The text is localised, of course.
*
* This file contains the functions to create and delete these tooltips.
*
* \todo Since we now consider MetaDisplay a singleton, there can be
* only one tooltip per display; this might quite simply live in
* display.c. Alternatively, it could move to frames.c, which
* is the only place this business is called anyway.
*
* \todo Apparently some UI needs changing (check bugzilla)
*/
#ifndef META_FIXED_TIP_H
#define META_FIXED_TIP_H
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
/**
* Displays a tooltip. There can be only one across the entire system.
* This function behaves identically whether or not a tooltip is already
* displayed, but if it is the window will be reused rather than destroyed
* and recreated.
*
* \param xdisplay An X display.
* \param screen_number The number of the screen.
* \param root_x The X coordinate where the tooltip should appear
* \param root_y The Y coordinate where the tooltip should appear
* \param markup_text Text to display in the tooltip; can contain markup
*/
void meta_fixed_tip_show (Display *xdisplay, int screen_number,
int root_x, int root_y,
const char *markup_text);
/**
* Removes the tooltip that was created by meta_fixed_tip_show(). If there
* is no tooltip currently visible, this is a no-op.
*/
void meta_fixed_tip_hide (void);
#endif

View file

@ -31,7 +31,6 @@
#include <meta/util.h>
#include "core.h"
#include "menu.h"
#include "fixedtip.h"
#include <meta/theme.h>
#include <meta/prefs.h>
#include "ui.h"
@ -98,7 +97,6 @@ static MetaFrameControl get_control (MetaFrames *frames,
MetaUIFrame *frame,
int x,
int y);
static void clear_tip (MetaFrames *frames);
static void invalidate_all_caches (MetaFrames *frames);
static void invalidate_whole_window (MetaFrames *frames,
MetaUIFrame *frame);
@ -298,8 +296,6 @@ meta_frames_destroy (GtkWidget *object)
frames = META_FRAMES (object);
clear_tip (frames);
winlist = NULL;
g_hash_table_foreach (frames->frames, listify_func, &winlist);
@ -724,8 +720,6 @@ meta_frames_unmanage_window (MetaFrames *frames,
{
MetaUIFrame *frame;
clear_tip (frames);
frame = g_hash_table_lookup (frames->frames, &xwindow);
if (frame)
@ -1123,155 +1117,6 @@ meta_frames_repaint_frame (MetaFrames *frames,
gdk_window_process_all_updates ();
}
static void
show_tip_now (MetaFrames *frames)
{
const char *tiptext;
MetaUIFrame *frame;
int x, y, root_x, root_y;
Window root, child;
guint mask;
MetaFrameControl control;
Display *display;
frame = frames->last_motion_frame;
if (frame == NULL)
return;
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
XQueryPointer (display,
frame->xwindow,
&root, &child,
&root_x, &root_y,
&x, &y,
&mask);
control = get_control (frames, frame, x, y);
tiptext = NULL;
switch (control)
{
case META_FRAME_CONTROL_TITLE:
break;
case META_FRAME_CONTROL_DELETE:
tiptext = _("Close Window");
break;
case META_FRAME_CONTROL_MENU:
tiptext = _("Window Menu");
break;
case META_FRAME_CONTROL_MINIMIZE:
tiptext = _("Minimize Window");
break;
case META_FRAME_CONTROL_MAXIMIZE:
tiptext = _("Maximize Window");
break;
case META_FRAME_CONTROL_UNMAXIMIZE:
tiptext = _("Restore Window");
break;
case META_FRAME_CONTROL_SHADE:
tiptext = _("Roll Up Window");
break;
case META_FRAME_CONTROL_UNSHADE:
tiptext = _("Unroll Window");
break;
case META_FRAME_CONTROL_ABOVE:
tiptext = _("Keep Window On Top");
break;
case META_FRAME_CONTROL_UNABOVE:
tiptext = _("Remove Window From Top");
break;
case META_FRAME_CONTROL_STICK:
tiptext = _("Always On Visible Workspace");
break;
case META_FRAME_CONTROL_UNSTICK:
tiptext = _("Put Window On Only One Workspace");
break;
case META_FRAME_CONTROL_RESIZE_SE:
break;
case META_FRAME_CONTROL_RESIZE_S:
break;
case META_FRAME_CONTROL_RESIZE_SW:
break;
case META_FRAME_CONTROL_RESIZE_N:
break;
case META_FRAME_CONTROL_RESIZE_NE:
break;
case META_FRAME_CONTROL_RESIZE_NW:
break;
case META_FRAME_CONTROL_RESIZE_W:
break;
case META_FRAME_CONTROL_RESIZE_E:
break;
case META_FRAME_CONTROL_NONE:
break;
case META_FRAME_CONTROL_CLIENT_AREA:
break;
}
if (tiptext)
{
MetaFrameGeometry fgeom;
GdkRectangle *rect;
int dx, dy;
int screen_number;
meta_frames_calc_geometry (frames, frame, &fgeom);
rect = control_rect (control, &fgeom);
/* get conversion delta for root-to-frame coords */
dx = root_x - x;
dy = root_y - y;
/* Align the tooltip to the button right end if RTL */
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
dx += rect->width;
screen_number = gdk_screen_get_number (gtk_widget_get_screen (GTK_WIDGET (frames)));
meta_fixed_tip_show (display,
screen_number,
rect->x + dx,
rect->y + rect->height + 2 + dy,
tiptext);
}
}
static gboolean
tip_timeout_func (gpointer data)
{
MetaFrames *frames;
frames = data;
show_tip_now (frames);
return FALSE;
}
#define TIP_DELAY 450
static void
queue_tip (MetaFrames *frames)
{
clear_tip (frames);
frames->tooltip_timeout = g_timeout_add (TIP_DELAY,
tip_timeout_func,
frames);
}
static void
clear_tip (MetaFrames *frames)
{
if (frames->tooltip_timeout)
{
g_source_remove (frames->tooltip_timeout);
frames->tooltip_timeout = 0;
}
meta_fixed_tip_hide ();
}
static void
redraw_control (MetaFrames *frames,
MetaUIFrame *frame,
@ -1442,8 +1287,6 @@ meta_frames_button_press_event (GtkWidget *widget,
if (frame == NULL)
return FALSE;
clear_tip (frames);
control = get_control (frames, frame, event->x, event->y);
/* focus on click, even if click was on client area */
@ -1708,8 +1551,6 @@ meta_frames_button_release_event (GtkWidget *widget,
if (frame == NULL)
return FALSE;
clear_tip (frames);
op = meta_core_get_grab_op (display);
if (op == META_GRAB_OP_NONE)
@ -1946,8 +1787,6 @@ meta_frames_motion_notify_event (GtkWidget *widget,
if (frame == NULL)
return FALSE;
clear_tip (frames);
frames->last_motion_frame = frame;
grab_op = meta_core_get_grab_op (display);
@ -2018,8 +1857,6 @@ meta_frames_motion_notify_event (GtkWidget *widget,
/* Update prelit control and cursor */
meta_frames_update_prelit_control (frames, frame, control);
queue_tip (frames);
}
break;
@ -2564,8 +2401,6 @@ meta_frames_leave_notify_event (GtkWidget *widget,
meta_frames_update_prelit_control (frames, frame, META_FRAME_CONTROL_NONE);
clear_tip (frames);
return TRUE;
}