Apply blackc@speakeasy.net patch, bug #83940, to do mini-workspaces

2002-07-06  Havoc Pennington  <hp@pobox.com>

        Apply blackc@speakeasy.net patch, bug #83940, to do
	mini-workspaces similar to the pager, when switching
	spaces.

	* src/window.c (update_net_wm_state): actually fill in
	wm_state_skip_taskbar, wm_state_skip_pager flags

	* src/tabpopup.c: support drawing a mini-workspace similar to the
	one the pager draws.

	* src/stack.c (meta_stack_list_windows): new function to list
	the windows in stacking order

	* src/screen.c (meta_screen_ensure_workspace_popup): don't pass in
	the ugly default app icon for workspaces

	* src/display.c (event_callback): fix from blackc@speakeasy.net
	to avoid dereferencing a NULL grab window.
This commit is contained in:
Havoc Pennington 2002-07-06 19:05:37 +00:00 committed by Havoc Pennington
parent 8c3437fd27
commit a62b3c8b29
8 changed files with 347 additions and 30 deletions

View File

@ -1,3 +1,24 @@
2002-07-06 Havoc Pennington <hp@pobox.com>
Apply blackc@speakeasy.net patch, bug #83940, to do
mini-workspaces similar to the pager, when switching
spaces.
* src/window.c (update_net_wm_state): actually fill in
wm_state_skip_taskbar, wm_state_skip_pager flags
* src/tabpopup.c: support drawing a mini-workspace similar to the
one the pager draws.
* src/stack.c (meta_stack_list_windows): new function to list
the windows in stacking order
* src/screen.c (meta_screen_ensure_workspace_popup): don't pass in
the ugly default app icon for workspaces
* src/display.c (event_callback): fix from blackc@speakeasy.net
to avoid dereferencing a NULL grab window.
2002-07-06 Havoc Pennington <hp@pobox.com>
* src/display.c (meta_display_open): put _NET_DESKTOP_NAMES in the

View File

@ -996,7 +996,9 @@ event_callback (XEvent *event,
{
meta_verbose ("Ending grab op %d on window %s due to button press\n",
display->grab_op,
display->grab_window->desc);
(display->grab_window ?
display->grab_window->desc :
"none"));
meta_display_end_grab_op (display,
event->xbutton.time);
}

View File

@ -932,15 +932,12 @@ void
meta_screen_ensure_workspace_popup (MetaScreen *screen)
{
MetaTabEntry *entries;
GdkPixbuf *icon;
int len, rows, cols;
int i;
if (screen->tab_popup)
return;
icon = meta_ui_get_default_window_icon (NULL);
len = meta_screen_get_n_workspaces (screen);
entries = g_new (MetaTabEntry, len + 1);
@ -968,7 +965,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
entries[i].key = (MetaTabEntryKey) workspace;
entries[i].title = workspace->name;
entries[i].icon = icon;
entries[i].icon = NULL;
}
}
}
@ -984,7 +981,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
entries[i].key = (MetaTabEntryKey) workspace;
entries[i].title = workspace->name;
entries[i].icon = icon;
entries[i].icon = NULL;
}
}
@ -996,8 +993,6 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
g_free (entries);
g_object_unref (G_OBJECT (icon));
/* don't show tab popup, since proper window isn't selected yet */
}

View File

@ -1035,6 +1035,42 @@ meta_stack_get_default_focus_window (MetaStack *stack,
return topmost_dock;
}
GList*
meta_stack_list_windows (MetaStack *stack,
MetaWorkspace *workspace)
{
GList *workspace_windows = NULL;
int layer = META_LAYER_LAST;
--layer;
while (layer >= 0)
{
GList *link;
g_assert (layer >= 0 && layer < META_LAYER_LAST);
/* top of this layer is at the front of the list */
link = stack->layers[layer];
while (link)
{
MetaWindow *window = link->data;
if (window && meta_window_visible_on_workspace (window, workspace))
{
workspace_windows = g_list_prepend (workspace_windows,
window);
}
link = link->next;
}
--layer;
}
return workspace_windows;
}
int
meta_stack_windows_cmp (MetaStack *stack,
MetaWindow *window_a,

View File

@ -101,6 +101,8 @@ MetaWindow* meta_stack_get_below (MetaStack *stack,
MetaWindow* meta_stack_get_default_focus_window (MetaStack *stack,
MetaWorkspace *workspace,
MetaWindow *not_this_one);
GList* meta_stack_list_windows (MetaStack *stack,
MetaWorkspace *workspace);
/* -1 if a < b, etc. */

View File

@ -24,6 +24,9 @@
#include "util.h"
#include "core.h"
#include "tabpopup.h"
#include "workspace.h" /* FIXME should not be included in this file */
#include "draw-workspace.h"
#include "frame.h"
#include <gtk/gtk.h>
#include <math.h>
@ -57,6 +60,10 @@ static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf);
static void select_image (GtkWidget *widget);
static void unselect_image (GtkWidget *widget);
static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace);
static void select_workspace (GtkWidget *widget);
static void unselect_workspace (GtkWidget *widget);
static gboolean
outline_window_expose (GtkWidget *widget,
GdkEventExpose *event,
@ -150,9 +157,10 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
te = g_new (TabEntry, 1);
te->key = entries[i].key;
te->title = g_strdup (entries[i].title);
te->icon = entries[i].icon;
g_object_ref (G_OBJECT (te->icon));
te->widget = NULL;
te->icon = entries[i].icon;
if (te->icon)
g_object_ref (G_OBJECT (te->icon));
if (outline)
{
@ -219,11 +227,19 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
te = tmp->data;
if (outline)
{
image = selectable_image_new (te->icon);
gtk_misc_set_padding (GTK_MISC (image),
INSIDE_SELECT_RECT + OUTSIDE_SELECT_RECT + 1,
INSIDE_SELECT_RECT + OUTSIDE_SELECT_RECT + 1);
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5);
}
else
{
image = selectable_workspace_new ((MetaWorkspace *) te->key);
}
te->widget = image;
@ -269,6 +285,7 @@ free_entry (gpointer data, gpointer user_data)
te = data;
g_free (te->title);
if (te->icon)
g_object_unref (G_OBJECT (te->icon));
g_free (te);
@ -318,10 +335,19 @@ display_entry (MetaTabPopup *popup,
if (popup->current_selected_entry)
{
if (popup->outline)
unselect_image (popup->current_selected_entry->widget);
else
unselect_workspace (popup->current_selected_entry->widget);
}
gtk_label_set_text (GTK_LABEL (popup->label), te->title);
if (popup->outline)
select_image (te->widget);
else
select_workspace (te->widget);
if (popup->outline)
{
@ -579,3 +605,197 @@ meta_select_image_expose_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
#define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ())
#define META_SELECT_WORKSPACE(obj) (GTK_CHECK_CAST ((obj), META_TYPE_SELECT_WORKSPACE, MetaSelectWorkspace))
typedef struct _MetaSelectWorkspace MetaSelectWorkspace;
typedef struct _MetaSelectWorkspaceClass MetaSelectWorkspaceClass;
struct _MetaSelectWorkspace
{
GtkDrawingArea parent_instance;
MetaWorkspace *workspace;
guint selected : 1;
};
struct _MetaSelectWorkspaceClass
{
GtkDrawingAreaClass parent_class;
};
static GType meta_select_workspace_get_type (void) G_GNUC_CONST;
#define SELECT_OUTLINE_WIDTH 2
static GtkWidget*
selectable_workspace_new (MetaWorkspace *workspace)
{
GtkWidget *widget;
double screen_aspect;
widget = g_object_new (meta_select_workspace_get_type (), NULL);
screen_aspect = (double) workspace->screen->height / (double) workspace->screen->width;
/* account for select rect */
gtk_widget_set_size_request (widget,
META_ICON_WIDTH + SELECT_OUTLINE_WIDTH * 2,
META_ICON_WIDTH * screen_aspect + SELECT_OUTLINE_WIDTH * 2);
META_SELECT_WORKSPACE (widget)->workspace = workspace;
return widget;
}
static void
select_workspace (GtkWidget *widget)
{
META_SELECT_WORKSPACE(widget)->selected = TRUE;
gtk_widget_queue_draw (widget);
}
static void
unselect_workspace (GtkWidget *widget)
{
META_SELECT_WORKSPACE (widget)->selected = FALSE;
gtk_widget_queue_draw (widget);
}
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
GdkEventExpose *event);
GType
meta_select_workspace_get_type (void)
{
static GtkType workspace_type = 0;
if (!workspace_type)
{
static const GTypeInfo workspace_info =
{
sizeof (MetaSelectWorkspaceClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) meta_select_workspace_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (MetaSelectWorkspace),
16, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
workspace_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
"MetaSelectWorkspace",
&workspace_info,
0);
}
return workspace_type;
}
static void
meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass)
{
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->expose_event = meta_select_workspace_expose_event;
}
static gboolean
meta_select_workspace_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
MetaWorkspace *workspace;
WnckWindowDisplayInfo *windows;
int i, n_windows;
GList *tmp, *list;
workspace = META_SELECT_WORKSPACE (widget)->workspace;
list = meta_stack_list_windows (workspace->screen->stack, workspace);
n_windows = g_list_length (list);
windows = g_new (WnckWindowDisplayInfo, n_windows);
tmp = list;
i = 0;
while (tmp != NULL)
{
MetaWindow *window;
window = tmp->data;
if (window->skip_pager ||
window->minimized ||
window->unmaps_pending)
{
--n_windows;
}
else
{
windows[i].icon = window->icon;
windows[i].mini_icon = window->mini_icon;
windows[i].is_active = window->has_focus;
if (window->frame)
{
windows[i].x = window->frame->rect.x;
windows[i].y = window->frame->rect.y;
windows[i].width = window->frame->rect.width;
windows[i].height = window->frame->rect.height;
}
else
{
windows[i].x = window->rect.x;
windows[i].y = window->rect.y;
windows[i].width = window->rect.width;
windows[i].height = window->rect.height;
}
i++;
}
tmp = tmp->next;
}
g_list_free (list);
wnck_draw_workspace (widget,
widget->window,
SELECT_OUTLINE_WIDTH,
SELECT_OUTLINE_WIDTH,
widget->allocation.width - SELECT_OUTLINE_WIDTH * 2,
widget->allocation.height - SELECT_OUTLINE_WIDTH * 2,
workspace->screen->width,
workspace->screen->height,
NULL,
(workspace->screen->active_workspace == workspace),
windows,
n_windows);
g_free (windows);
if (META_SELECT_WORKSPACE (widget)->selected)
{
i = SELECT_OUTLINE_WIDTH - 1;
while (i >= 0)
{
gdk_draw_rectangle (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
FALSE,
i,
i,
widget->allocation.width - i * 2 - 1,
widget->allocation.height - i * 2 - 1);
--i;
}
}
return TRUE;
}

View File

@ -382,6 +382,8 @@ meta_window_new (MetaDisplay *display, Window xwindow,
window->has_fullscreen_func = TRUE;
window->wm_state_modal = FALSE;
window->skip_taskbar = FALSE;
window->skip_pager = FALSE;
window->wm_state_skip_taskbar = FALSE;
window->wm_state_skip_pager = FALSE;
@ -3222,9 +3224,9 @@ meta_window_client_message (MetaWindow *window,
if (first == display->atom_net_wm_state_skip_pager ||
second == display->atom_net_wm_state_skip_pager)
{
window->wm_state_skip_pager =
window->skip_pager =
(action == _NET_WM_STATE_ADD) ||
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_skip_pager);
(action == _NET_WM_STATE_TOGGLE && !window->skip_pager);
set_net_wm_state (window);
}
@ -3232,9 +3234,9 @@ meta_window_client_message (MetaWindow *window,
if (first == display->atom_net_wm_state_skip_taskbar ||
second == display->atom_net_wm_state_skip_taskbar)
{
window->wm_state_skip_taskbar =
window->skip_taskbar =
(action == _NET_WM_STATE_ADD) ||
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_skip_taskbar);
(action == _NET_WM_STATE_TOGGLE && !window->skip_taskbar);
set_net_wm_state (window);
}
@ -4088,6 +4090,8 @@ update_net_wm_state (MetaWindow *window)
window->shaded = FALSE;
window->maximized = FALSE;
window->wm_state_modal = FALSE;
window->wm_state_skip_taskbar = FALSE;
window->wm_state_skip_pager = FALSE;
if (meta_prop_get_atom_list (window->display, window->xwindow,
window->display->atom_net_wm_state,
@ -4106,6 +4110,10 @@ update_net_wm_state (MetaWindow *window)
window->maximized = TRUE;
else if (atoms[i] == window->display->atom_net_wm_state_modal)
window->wm_state_modal = TRUE;
else if (atoms[i] == window->display->atom_net_wm_state_skip_taskbar)
window->wm_state_skip_taskbar = TRUE;
else if (atoms[i] == window->display->atom_net_wm_state_skip_pager)
window->wm_state_skip_pager = TRUE;
++i;
}
@ -5013,6 +5021,37 @@ recalc_window_features (MetaWindow *window)
if (!window->decorated)
window->has_shade_func = FALSE;
window->skip_taskbar = FALSE;
window->skip_pager = FALSE;
if (window->wm_state_skip_taskbar)
window->skip_taskbar = TRUE;
if (window->wm_state_skip_pager)
window->skip_pager = TRUE;
switch (window->type)
{
/* Force skip taskbar/pager on these window types */
case META_WINDOW_DESKTOP:
case META_WINDOW_DOCK:
case META_WINDOW_TOOLBAR:
case META_WINDOW_MENU:
case META_WINDOW_UTILITY:
case META_WINDOW_SPLASHSCREEN:
window->skip_taskbar = TRUE;
window->skip_pager = TRUE;
break;
case META_WINDOW_DIALOG:
case META_WINDOW_MODAL_DIALOG:
window->skip_taskbar = TRUE;
break;
case META_WINDOW_NORMAL:
break;
}
/* FIXME perhaps should ensure if we don't have a shade func,
* we aren't shaded, etc.
*/

View File

@ -152,13 +152,15 @@ struct _MetaWindow
/* Weird "_NET_WM_STATE_MODAL" flag */
guint wm_state_modal : 1;
/* If these are TRUE, it just means a client explicitly
* toggled them on; we compute actual _NET_WM_STATE from
* window type usually
*/
/* TRUE if the client forced these on */
guint wm_state_skip_taskbar : 1;
guint wm_state_skip_pager : 1;
/* Computed whether to skip taskbar or not */
guint skip_taskbar : 1;
guint skip_pager : 1;
/* this flag tracks receipt of focus_in focus_out and
* determines whether we draw the focus
*/