summaryrefslogtreecommitdiff
path: root/gtk/window-decorator/gtk-window-decorator.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/window-decorator/gtk-window-decorator.c')
-rw-r--r--gtk/window-decorator/gtk-window-decorator.c260
1 files changed, 137 insertions, 123 deletions
diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c
index 93e38db..86e684f 100644
--- a/gtk/window-decorator/gtk-window-decorator.c
+++ b/gtk/window-decorator/gtk-window-decorator.c
@@ -17,80 +17,20 @@
* Boston, MA 02111-1307, USA.
*
* Author: David Reveman <davidr@novell.com>
+ *
+ * 2D Mode: Copyright © 2009 Sam Spilsbury <smspillaz@gmail.com>
+ * Frames Management: Copright © 2010 Canonical Ltd.
+ * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
*/
#include "gtk-window-decorator.h"
gboolean minimal = FALSE;
-double decoration_alpha = 0.5;
-
#define SWITCHER_SPACE 40
-decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
-decor_extents_t _win_extents = { 6, 6, 6, 6 };
-decor_extents_t _max_win_extents = { 6, 6, 4, 6 };
-decor_extents_t _default_win_extents = { 6, 6, 6, 6 };
-decor_extents_t _switcher_extents = { 6, 6, 6, 6 + SWITCHER_SPACE };
-
-int titlebar_height = 17;
-int max_titlebar_height = 17;
-
-decor_context_t window_context = {
- { 0, 0, 0, 0 },
- 6, 6, 4, 6,
- 0, 0, 0, 0
-};
-
-decor_context_t max_window_context = {
- { 0, 0, 0, 0 },
- 6, 6, 4, 6,
- 0, 0, 0, 0
-};
-
-decor_context_t window_context_no_shadow = {
- { 0, 0, 0, 0 },
- 6, 6, 4, 6,
- 0, 0, 0, 0
-};
-
-decor_context_t max_window_context_no_shadow = {
- { 0, 0, 0, 0 },
- 6, 6, 4, 6,
- 0, 0, 0, 0
-};
-
-decor_context_t switcher_context = {
- { 0, 0, 0, 0 },
- 6, 6, 6, 6 + SWITCHER_SPACE,
- 0, 0, 0, 0
-};
-
-decor_context_t shadow_context = {
- { 0, 0, 0, 0 },
- 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
-
-gdouble shadow_radius = SHADOW_RADIUS;
-gdouble shadow_opacity = SHADOW_OPACITY;
-gushort shadow_color[3] = {
- SHADOW_COLOR_RED,
- SHADOW_COLOR_GREEN,
- SHADOW_COLOR_BLUE
-};
-gint shadow_offset_x = SHADOW_OFFSET_X;
-gint shadow_offset_y = SHADOW_OFFSET_Y;
-
guint cmdline_options = 0;
-decor_shadow_t *no_border_shadow = NULL;
-decor_shadow_t *border_shadow = NULL;
-decor_shadow_t *max_border_shadow = NULL;
-decor_shadow_t *border_no_shadow = NULL;
-decor_shadow_t *max_border_no_shadow = NULL;
-decor_shadow_t *switcher_shadow = NULL;
-
GdkPixmap *decor_normal_pixmap = NULL;
GdkPixmap *decor_active_pixmap = NULL;
@@ -103,10 +43,8 @@ Atom restack_window_atom;
Atom select_window_atom;
Atom mwm_hints_atom;
Atom switcher_fg_atom;
-
Atom compiz_shadow_info_atom;
Atom compiz_shadow_color_atom;
-
Atom toolkit_action_atom;
Atom toolkit_action_window_menu_atom;
Atom toolkit_action_force_quit_dialog_atom;
@@ -140,17 +78,18 @@ struct _pos pos[3][3] = {
{ 6, 2, 16, 16, 0, 0, 0, 0, 0, 0 }
};
+const gchar * window_type_frames[WINDOW_TYPE_FRAMES_NUM] = {
+ "normal", "dialog", "menu", "utility"
+};
+
char *program_name;
-GtkWidget *style_window_rgba;
-GtkWidget *style_window_rgb;
GtkWidget *switcher_label;
GHashTable *frame_table;
GtkWidget *action_menu = NULL;
gboolean action_menu_mapped = FALSE;
decor_color_t _title_color[2];
-PangoContext *pango_context;
gint double_click_timeout = 250;
GtkWidget *tip_window;
@@ -161,47 +100,71 @@ gint tooltip_timer_tag = 0;
GSList *draw_list = NULL;
guint draw_idle_id = 0;
-PangoFontDescription *titlebar_font = NULL;
-gboolean use_system_font = FALSE;
-gint text_height;
-
-gint blur_type = BLUR_TYPE_NONE;
-
-GdkPixmap *switcher_pixmap = NULL;
-GdkPixmap *switcher_buffer_pixmap = NULL;
-gint switcher_width;
-gint switcher_height;
Window switcher_selected_window = None;
decor_t *switcher_window = NULL;
XRenderPictFormat *xformat_rgba;
XRenderPictFormat *xformat_rgb;
+decor_settings_t *settings;
+
int
main (int argc, char *argv[])
{
- GdkDisplay *gdkdisplay;
- Display *xdisplay;
- GdkScreen *gdkscreen;
- WnckScreen *screen;
- gint i, j, status;
- gboolean replace = FALSE;
- unsigned int nchildren;
- Window root_ret, parent_ret;
- Window *children = NULL;
+ GdkDisplay *gdkdisplay;
+ Display *xdisplay;
+ GdkScreen *gdkscreen;
+ WnckScreen *screen;
+ gint i, j, status;
+ gboolean replace = FALSE;
+ unsigned int nchildren;
+ Window root_ret, parent_ret;
+ Window *children = NULL;
+ GList *windows, *win;
+ decor_frame_t *default_p, *bare_p, *switcher_p;
#ifdef USE_METACITY
char *meta_theme = NULL;
+ MetaTheme *theme = NULL;
#endif
program_name = argv[0];
+ settings = malloc (sizeof (decor_settings_t));
+
+ if (!settings)
+ return 1;
+
gtk_init (&argc, &argv);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
+ settings->blur_type = BLUR_TYPE_NONE;
+ settings->use_system_font = FALSE;
+
+ settings->shadow_radius = SHADOW_RADIUS;
+ settings->shadow_opacity = SHADOW_OPACITY;
+ settings->shadow_color[0] = SHADOW_COLOR_RED;
+ settings->shadow_color[1] = SHADOW_COLOR_GREEN;
+ settings->shadow_color[2] = SHADOW_COLOR_BLUE;
+ settings->shadow_offset_x = SHADOW_OFFSET_X;
+ settings->shadow_offset_y = SHADOW_OFFSET_Y;
+ settings->decoration_alpha = 0.5;
+
+#ifdef USE_METACITY
+
+ settings->meta_opacity = META_OPACITY;
+ settings->meta_shade_opacity = META_SHADE_OPACITY;
+ settings->meta_active_opacity = META_ACTIVE_OPACITY;
+ settings->meta_active_shade_opacity = META_ACTIVE_SHADE_OPACITY;
+
+ settings->meta_button_layout_set = FALSE;
+#endif
+
+ settings->font = strdup ("Sans Bold 12");
+
for (i = 0; i < argc; i++)
{
if (strcmp (argv[i], "--minimal") == 0)
@@ -217,9 +180,9 @@ main (int argc, char *argv[])
if (argc > ++i)
{
if (strcmp (argv[i], "titlebar") == 0)
- blur_type = BLUR_TYPE_TITLEBAR;
+ settings->blur_type = BLUR_TYPE_TITLEBAR;
else if (strcmp (argv[i], "all") == 0)
- blur_type = BLUR_TYPE_ALL;
+ settings->blur_type = BLUR_TYPE_ALL;
}
cmdline_options |= CMDLINE_BLUR;
}
@@ -228,23 +191,23 @@ main (int argc, char *argv[])
else if (strcmp (argv[i], "--opacity") == 0)
{
if (argc > ++i)
- meta_opacity = atof (argv[i]);
+ settings->meta_opacity = atof (argv[i]);
cmdline_options |= CMDLINE_OPACITY;
}
else if (strcmp (argv[i], "--no-opacity-shade") == 0)
{
- meta_shade_opacity = FALSE;
+ settings->meta_shade_opacity = FALSE;
cmdline_options |= CMDLINE_OPACITY_SHADE;
}
else if (strcmp (argv[i], "--active-opacity") == 0)
{
if (argc > ++i)
- meta_active_opacity = atof (argv[i]);
+ settings->meta_active_opacity = atof (argv[i]);
cmdline_options |= CMDLINE_ACTIVE_OPACITY;
}
else if (strcmp (argv[i], "--no-active-opacity-shade") == 0)
{
- meta_active_shade_opacity = FALSE;
+ settings->meta_active_shade_opacity = FALSE;
cmdline_options |= CMDLINE_ACTIVE_OPACITY_SHADE;
}
else if (strcmp (argv[i], "--metacity-theme") == 0)
@@ -277,27 +240,6 @@ main (int argc, char *argv[])
}
}
- theme_draw_window_decoration = draw_window_decoration;
- theme_calc_decoration_size = calc_decoration_size;
- theme_update_border_extents = update_border_extents;
- theme_get_event_window_position = get_event_window_position;
- theme_get_button_position = get_button_position;
-
-#ifdef USE_METACITY
- if (meta_theme)
- {
- meta_theme_set_current (meta_theme, TRUE);
- if (meta_theme_get_current ())
- {
- theme_draw_window_decoration = meta_draw_window_decoration;
- theme_calc_decoration_size = meta_calc_decoration_size;
- theme_update_border_extents = meta_update_border_extents;
- theme_get_event_window_position = meta_get_event_window_position;
- theme_get_button_position = meta_get_button_position;
- }
- }
-#endif
-
gdkdisplay = gdk_display_get_default ();
xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);
gdkscreen = gdk_display_get_default_screen (gdkdisplay);
@@ -356,6 +298,49 @@ main (int argc, char *argv[])
return 1;
}
+ screen = wnck_screen_get_default ();
+
+ initialize_decorations ();
+
+ if (!init_settings (screen))
+ {
+ free (settings);
+ fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]);
+ return 1;
+ }
+
+ theme_draw_window_decoration = draw_window_decoration;
+ theme_calc_decoration_size = calc_decoration_size;
+ theme_update_border_extents = update_border_extents;
+ theme_get_event_window_position = get_event_window_position;
+ theme_get_button_position = get_button_position;
+ theme_get_title_scale = get_title_scale;
+
+#ifdef USE_METACITY
+ if (meta_theme)
+ {
+ meta_theme_set_current (meta_theme, TRUE);
+
+ theme = meta_theme_get_current ();
+
+ if (!theme)
+ g_warning ("specified a theme that does not exist! falling back to cairo decoration\n");
+ }
+ else
+ theme = meta_theme_get_current ();
+
+ if (theme)
+ {
+ fprintf (stderr, "setting procs\n");
+ theme_draw_window_decoration = meta_draw_window_decoration;
+ theme_calc_decoration_size = meta_calc_decoration_size;
+ theme_update_border_extents = meta_update_border_extents;
+ theme_get_event_window_position = meta_get_event_window_position;
+ theme_get_button_position = meta_get_button_position;
+ theme_get_title_scale = meta_get_title_scale;
+ }
+#endif
+
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
@@ -373,19 +358,19 @@ main (int argc, char *argv[])
if (!create_tooltip_window ())
{
+ free (settings);
fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
return 1;
}
- screen = wnck_screen_get_default ();
wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
gdk_window_add_filter (NULL,
selection_event_filter_func,
NULL);
- if (!minimal)
- {
+ if (!minimal)
+ {
GdkWindow *root = gdk_window_foreign_new_for_display (gdkdisplay,
gdk_x11_get_default_root_xwindow ());
@@ -418,11 +403,12 @@ main (int argc, char *argv[])
connect_screen (screen);
}
- if (!init_settings (screen))
- {
- fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]);
- return 1;
- }
+ /* Keep the default, bare and switcher decorations around
+ * since otherwise they will be spuriously recreated */
+
+ default_p = gwd_get_decor_frame ("default");
+ bare_p = gwd_get_decor_frame ("bare");
+ switcher_p = gwd_get_decor_frame ("switcher");
decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen),
WINDOW_DECORATION_TYPE_PIXMAP |
@@ -432,5 +418,33 @@ main (int argc, char *argv[])
gtk_main ();
+ win = windows = wnck_screen_get_windows (screen);
+
+ while (win != NULL)
+ {
+ WnckWindow *w = (WnckWindow *) win->data;
+
+ window_closed (screen, w);
+ }
+
+ g_list_free (windows);
+
+ if (screen)
+ g_object_unref (screen);
+
+ if (tip_window)
+ gtk_widget_destroy (GTK_WIDGET (tip_window));
+
+ if (tip_label)
+ gtk_widget_destroy (GTK_WIDGET (tip_label));
+
+ gwd_decor_frame_unref (default_p);
+ gwd_decor_frame_unref (bare_p);
+ gwd_decor_frame_unref (switcher_p);
+
+ g_free (settings->font);
+
+ free (settings);
+
return 0;
}