add crackrock window-outlining feature

2001-08-29  Havoc Pennington  <hp@pobox.com>

	* src/tabpopup.c: add crackrock window-outlining feature

	* src/session.c (window_type_to_string): handle fullscreen
This commit is contained in:
Havoc Pennington 2001-08-29 04:53:48 +00:00 committed by Havoc Pennington
parent 27c81cad33
commit 4abbd4b1e5
7 changed files with 101 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2001-08-29 Havoc Pennington <hp@pobox.com>
* src/tabpopup.c: add crackrock window-outlining feature
* src/session.c (window_type_to_string): handle fullscreen
2001-08-29 Havoc Pennington <hp@pobox.com> 2001-08-29 Havoc Pennington <hp@pobox.com>
* src/display.c (meta_display_open): wrong atom name - * src/display.c (meta_display_open): wrong atom name -

View File

@ -23,6 +23,24 @@
#include "frame.h" #include "frame.h"
#include "workspace.h" #include "workspace.h"
void
meta_core_get_outer_rect (Display *xdisplay,
Window frame_xwindow,
GdkRectangle *rect)
{
MetaDisplay *display;
MetaWindow *window;
MetaRectangle r;
display = meta_display_for_x_display (xdisplay);
window = meta_display_lookup_x_window (display, frame_xwindow);
if (window == NULL || window->frame == NULL)
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
}
void void
meta_core_get_frame_size (Display *xdisplay, meta_core_get_frame_size (Display *xdisplay,
Window frame_xwindow, Window frame_xwindow,

View File

@ -28,6 +28,10 @@
#include "frames.h" #include "frames.h"
#include "common.h" #include "common.h"
void meta_core_get_outer_rect (Display *xdisplay,
Window frame_xwindow,
GdkRectangle *rect);
void meta_core_get_frame_size (Display *xdisplay, void meta_core_get_frame_size (Display *xdisplay,
Window frame_xwindow, Window frame_xwindow,
int *width, int *width,

View File

@ -479,12 +479,18 @@ meta_screen_ensure_tab_popup (MetaScreen *screen)
while (i < len) while (i < len)
{ {
MetaWindow *window; MetaWindow *window;
MetaRectangle r;
window = tmp->data; window = tmp->data;
entries[i].xwindow = window->xwindow; entries[i].xwindow = window->xwindow;
entries[i].title = window->title; entries[i].title = window->title;
entries[i].icon = window->icon; entries[i].icon = window->icon;
meta_window_get_outer_rect (window, &r);
entries[i].x = r.x;
entries[i].y = r.y;
entries[i].width = r.width;
entries[i].height = r.height;
++i; ++i;
tmp = tmp->next; tmp = tmp->next;

View File

@ -563,6 +563,9 @@ window_type_to_string (MetaWindowType type)
case META_WINDOW_MENU: case META_WINDOW_MENU:
return "menu"; return "menu";
break; break;
case META_WINDOW_FULLSCREEN:
return "fullscreen";
break;
} }
return ""; return "";
@ -585,6 +588,8 @@ window_type_from_string (const char *str)
return META_WINDOW_TOOLBAR; return META_WINDOW_TOOLBAR;
else if (strcmp (str, "menu") == 0) else if (strcmp (str, "menu") == 0)
return META_WINDOW_MENU; return META_WINDOW_MENU;
else if (strcmp (str, "fullscreen") == 0)
return META_WINDOW_FULLSCREEN;
else else
return META_WINDOW_NORMAL; return META_WINDOW_NORMAL;
} }

View File

@ -35,6 +35,7 @@ struct _TabEntry
char *title; char *title;
GdkPixbuf *icon; GdkPixbuf *icon;
GtkWidget *widget; GtkWidget *widget;
GdkRectangle rect;
}; };
struct _MetaTabPopup struct _MetaTabPopup
@ -44,6 +45,7 @@ struct _MetaTabPopup
GList *current; GList *current;
GList *entries; GList *entries;
GtkWidget *current_selected_widget; GtkWidget *current_selected_widget;
GtkWidget *outline_window;
}; };
static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf); static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf);
@ -64,6 +66,11 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
int max_label_width; int max_label_width;
popup = g_new (MetaTabPopup, 1); popup = g_new (MetaTabPopup, 1);
popup->outline_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (popup->outline_window, TRUE);
gtk_widget_realize (popup->outline_window);
popup->window = gtk_window_new (GTK_WINDOW_POPUP); popup->window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_position (GTK_WINDOW (popup->window), gtk_window_set_position (GTK_WINDOW (popup->window),
GTK_WIN_POS_CENTER_ALWAYS); GTK_WIN_POS_CENTER_ALWAYS);
@ -87,6 +94,11 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
g_object_ref (G_OBJECT (te->icon)); g_object_ref (G_OBJECT (te->icon));
te->widget = NULL; te->widget = NULL;
te->rect.x = entries[i].x;
te->rect.y = entries[i].y;
te->rect.width = entries[i].width;
te->rect.height = entries[i].height;
tab_entries = g_list_prepend (tab_entries, te); tab_entries = g_list_prepend (tab_entries, te);
++i; ++i;
@ -194,7 +206,7 @@ free_entry (gpointer data, gpointer user_data)
void void
meta_ui_tab_popup_free (MetaTabPopup *popup) meta_ui_tab_popup_free (MetaTabPopup *popup)
{ {
gtk_widget_destroy (popup->outline_window);
gtk_widget_destroy (popup->window); gtk_widget_destroy (popup->window);
g_list_foreach (popup->entries, free_entry, NULL); g_list_foreach (popup->entries, free_entry, NULL);
@ -218,12 +230,56 @@ static void
display_entry (MetaTabPopup *popup, display_entry (MetaTabPopup *popup,
TabEntry *te) TabEntry *te)
{ {
GdkRectangle inner;
GdkRectangle rect;
if (popup->current_selected_widget) if (popup->current_selected_widget)
unselect_image (popup->current_selected_widget); unselect_image (popup->current_selected_widget);
gtk_label_set_text (GTK_LABEL (popup->label), te->title); gtk_label_set_text (GTK_LABEL (popup->label), te->title);
select_image (te->widget); select_image (te->widget);
/* Do stuff behind gtk's back */
gdk_window_hide (popup->outline_window->window);
#define OUTLINE_WIDTH 3
rect = te->rect;
rect.x = 0;
rect.y = 0;
inner = rect;
inner.x += OUTLINE_WIDTH;
inner.y += OUTLINE_WIDTH;
inner.width -= OUTLINE_WIDTH * 2;
inner.height -= OUTLINE_WIDTH * 2;
if (inner.width >= 0 || inner.height >= 0)
{
GdkRegion *region;
GdkRegion *inner_region;
gdk_window_move_resize (popup->outline_window->window,
te->rect.x, te->rect.y,
te->rect.width, te->rect.height);
gdk_window_set_background (popup->outline_window->window,
&popup->outline_window->style->black);
region = gdk_region_rectangle (&rect);
inner_region = gdk_region_rectangle (&inner);
gdk_region_subtract (region, inner_region);
gdk_region_destroy (inner_region);
gdk_window_shape_combine_region (popup->outline_window->window,
region,
0, 0);
/* This should piss off gtk a bit, but we don't want to raise
* above the tab popup
*/
gdk_window_show_unraised (popup->outline_window->window);
}
popup->current_selected_widget = te->widget; popup->current_selected_widget = te->widget;
} }

View File

@ -136,6 +136,7 @@ struct _MetaTabEntry
Window xwindow; Window xwindow;
const char *title; const char *title;
GdkPixbuf *icon; GdkPixbuf *icon;
int x, y, width, height;
}; };
MetaTabPopup* meta_ui_tab_popup_new (const MetaTabEntry *entries); MetaTabPopup* meta_ui_tab_popup_new (const MetaTabEntry *entries);