Commit 8ae714ee authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington
Browse files

disable custom log handler and fatal mask for now

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

	* src/main.c (main): disable custom log handler and fatal mask for
	now

	* src/theme.c (meta_draw_op_list_draw):
	Add META_DRAW_CLIP

	* src/main.c: load theme, monitor current theme setting

	* src/prefs.c: add "current theme" setting

	* src/stack.c (meta_stack_free): don't try to free
	last_root_children_stacked if it doesn't exist

	* src/themewidget.c: pluggable GtkMisc subclass to use
	for menu icons

	* src/screen.c (meta_screen_manage_all_windows): fix
	signed/unsigned warning

	* src/frames.c: port to theme system
	(meta_frames_style_set): chain up

	* theme-format.txt: new file

	* configure.in: add more compiler warnings

	* src/theme.c: add various stuff needed to get theme parser
	working. Remove the "spacer" concept from FrameLayout object.
	Add draw op that references a draw op list.

	* configure.in: require GTK 1.3.13

	* src/Makefile.am: add theme-parser.[hc], implement loading a
	theme

	* src/theme.c: add "draw title" and "draw window icon" operations
	(meta_draw_op_draw): put object_width/object_height in expression
	environment before computing x/y. Handle out-of-memory when
	creating pixbufs. Assorted other cleanups.
parent 2be2d8cc
2002-02-06 Havoc Pennington <hp@pobox.com>
* src/main.c (main): disable custom log handler and fatal mask for
now
* src/theme.c (meta_draw_op_list_draw):
Add META_DRAW_CLIP
* src/main.c: load theme, monitor current theme setting
* src/prefs.c: add "current theme" setting
* src/stack.c (meta_stack_free): don't try to free
last_root_children_stacked if it doesn't exist
* src/themewidget.c: pluggable GtkMisc subclass to use
for menu icons
* src/screen.c (meta_screen_manage_all_windows): fix
signed/unsigned warning
* src/frames.c: port to theme system
(meta_frames_style_set): chain up
* theme-format.txt: new file
* configure.in: add more compiler warnings
* src/theme.c: add various stuff needed to get theme parser
working. Remove the "spacer" concept from FrameLayout object.
Add draw op that references a draw op list.
* configure.in: require GTK 1.3.13
* src/Makefile.am: add theme-parser.[hc], implement loading a
theme
* src/theme.c: add "draw title" and "draw window icon" operations
(meta_draw_op_draw): put object_width/object_height in expression
environment before computing x/y. Handle out-of-memory when
creating pixbufs. Assorted other cleanups.
2002-02-07 Anders Carlsson <andersca@gnu.org>
* src/themes/Crux/metacity-theme-1.xml:
......
SUBDIRS=src
EXTRA_DIST=HACKING
EXTRA_DIST=HACKING theme-format.txt
......@@ -26,6 +26,46 @@ if test "x$GCC" = "xyes"; then
*) CFLAGS="$CFLAGS -Wall" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wshadow[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wshadow" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wnested-externs[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wnested-externs" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wpointer-arith[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wpointer-arith" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wcast-align[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wcast-align" ;;
esac
case " $CFLAGS " in
*[\ \ ]-Wsign-compare[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wsign-compare" ;;
esac
if test "x$enable_ansi" = "xyes"; then
case " $CFLAGS " in
*[\ \ ]-ansi[\ \ ]*) ;;
......@@ -44,8 +84,9 @@ ALL_LINGUAS="da es gl lv ms no pt ru sk sv tr uk"
AM_GLIB_GNU_GETTEXT
## here we get the flags we'll actually use
PKG_CHECK_MODULES(METACITY, gtk+-2.0 >= 1.3.11 gconf-2.0 >= 1.1.5)
PKG_CHECK_MODULES(METACITY_RESTART, gtk+-2.0 >= 1.3.11)
PKG_CHECK_MODULES(METACITY, gtk+-2.0 >= 1.3.13 gconf-2.0 >= 1.1.5)
PKG_CHECK_MODULES(METACITY_RESTART, gtk+-2.0 >= 1.3.13)
PKG_CHECK_MODULES(METACITY_RELOAD_THEME, gtk+-2.0 >= 1.3.13)
CFLAGS="$METACITY_CFLAGS $CFLAGS"
......@@ -98,4 +139,5 @@ Makefile
src/Makefile
src/wm-tester/Makefile
src/tools/Makefile
src/themes/Makefile
])
SUBDIRS=wm-tester tools
SUBDIRS=wm-tester tools themes
INCLUDES=@METACITY_CFLAGS@ -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMETACITY_LOCALEDIR=\"$(datadir)/locale\"
INCLUDES=@METACITY_CFLAGS@ -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMETACITY_LOCALEDIR=\"$(datadir)/locale\" -DMETACITY_PKGDATADIR=\"$(pkgdatadir)\"
metacity_SOURCES= \
common.h \
......@@ -44,6 +44,10 @@ metacity_SOURCES= \
tabpopup.h \
theme.c \
theme.h \
theme-parser.c \
theme-parser.h \
themewidget.c \
themewidget.h \
ui.c \
ui.h \
util.c \
......@@ -60,6 +64,8 @@ metacity_theme_viewer_SOURCES= \
gradient.h \
theme.c \
theme.h \
theme-parser.c \
theme-parser.h \
theme-viewer.c \
util.c \
util.h
......
......@@ -135,7 +135,7 @@ typedef enum
META_FRAME_TYPE_MODAL_DIALOG,
META_FRAME_TYPE_UTILITY,
META_FRAME_TYPE_MENU,
META_FRAME_TYPE_TOOLBAR,
/* META_FRAME_TYPE_TOOLBAR, */
META_FRAME_TYPE_LAST
} MetaFrameType;
......
......@@ -60,6 +60,49 @@ meta_core_get_frame_flags (Display *xdisplay,
return meta_frame_get_flags (window->frame);
}
MetaFrameType
meta_core_get_frame_type (Display *xdisplay,
Window frame_xwindow)
{
MetaDisplay *display;
MetaWindow *window;
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);
switch (window->type)
{
case META_WINDOW_NORMAL:
return META_FRAME_TYPE_NORMAL;
break;
case META_WINDOW_DIALOG:
return META_FRAME_TYPE_DIALOG;
break;
case META_WINDOW_MODAL_DIALOG:
return META_FRAME_TYPE_MODAL_DIALOG;
break;
case META_WINDOW_MENU:
return META_FRAME_TYPE_MENU;
break;
case META_WINDOW_DESKTOP:
case META_WINDOW_DOCK:
case META_WINDOW_TOOLBAR:
/* No frame */
return META_FRAME_TYPE_LAST;
break;
}
g_assert_not_reached ();
return META_FRAME_TYPE_LAST;
}
GdkPixbuf*
meta_core_get_mini_icon (Display *xdisplay,
Window frame_xwindow)
......@@ -76,6 +119,22 @@ meta_core_get_mini_icon (Display *xdisplay,
return window->mini_icon;
}
GdkPixbuf*
meta_core_get_icon (Display *xdisplay,
Window frame_xwindow)
{
MetaDisplay *display;
MetaWindow *window;
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);
return window->icon;
}
void
meta_core_queue_frame_resize (Display *xdisplay,
Window frame_xwindow)
......
......@@ -33,9 +33,13 @@ void meta_core_get_client_size (Display *xdisplay,
MetaFrameFlags meta_core_get_frame_flags (Display *xdisplay,
Window frame_xwindow);
MetaFrameType meta_core_get_frame_type (Display *xdisplay,
Window frame_xwindow);
GdkPixbuf* meta_core_get_mini_icon (Display *xdisplay,
Window frame_xwindow);
GdkPixbuf* meta_core_get_icon (Display *xdisplay,
Window frame_xwindow);
void meta_core_queue_frame_resize (Display *xdisplay,
Window frame_xwindow);
......
......@@ -139,9 +139,10 @@ meta_display_open (const char *name)
"_KWM_WIN_ICON",
"_NET_WM_MOVERESIZE",
"_NET_ACTIVE_WINDOW",
"_METACITY_RESTART_MESSAGE",
"_METACITY_RESTART_MESSAGE",
"_NET_WM_STRUT",
"_WIN_HINTS"
"_WIN_HINTS",
"_METACITY_RELOAD_THEME_MESSAGE"
};
Atom atoms[G_N_ELEMENTS(atom_names)];
......@@ -237,6 +238,7 @@ meta_display_open (const char *name)
display->atom_metacity_restart_message = atoms[44];
display->atom_net_wm_strut = atoms[45];
display->atom_win_hints = atoms[46];
display->atom_metacity_reload_theme_message = atoms[47];
/* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK,
* created in screen_new
......@@ -668,7 +670,7 @@ event_callback (XEvent *event,
/* mark double click events, kind of a hack, oh well. */
if (event->type == ButtonPress)
{
if (event->xbutton.button == display->last_button_num &&
if (((int)event->xbutton.button) == display->last_button_num &&
event->xbutton.window == display->last_button_xwindow &&
event->xbutton.time < (display->last_button_time + display->double_click_time))
{
......@@ -716,7 +718,7 @@ event_callback (XEvent *event,
break;
case ButtonPress:
if ((grab_op_is_mouse (display->grab_op) &&
display->grab_button != event->xbutton.button &&
display->grab_button != (int) event->xbutton.button &&
display->grab_window == window) ||
grab_op_is_keyboard (display->grab_op))
{
......@@ -1104,6 +1106,13 @@ event_callback (XEvent *event,
meta_verbose ("Received restart request\n");
meta_restart ();
}
else if (event->xclient.message_type ==
display->atom_metacity_reload_theme_message)
{
meta_verbose ("Received reload theme request\n");
meta_ui_set_current_theme (meta_prefs_get_theme (),
TRUE);
}
}
}
break;
......@@ -1567,15 +1576,15 @@ meta_display_unregister_x_window (MetaDisplay *display,
MetaWorkspace*
meta_display_get_workspace_by_index (MetaDisplay *display,
int index)
int idx)
{
GList *tmp;
/* should be robust, index is maybe from an app */
if (index < 0)
if (idx < 0)
return NULL;
tmp = g_list_nth (display->workspaces, index);
tmp = g_list_nth (display->workspaces, idx);
if (tmp == NULL)
return NULL;
......@@ -1586,13 +1595,13 @@ meta_display_get_workspace_by_index (MetaDisplay *display,
MetaWorkspace*
meta_display_get_workspace_by_screen_index (MetaDisplay *display,
MetaScreen *screen,
int index)
int idx)
{
GList *tmp;
int i;
/* should be robust, index is maybe from an app */
if (index < 0)
/* should be robust, idx is maybe from an app */
if (idx < 0)
return NULL;
i = 0;
......@@ -1603,7 +1612,7 @@ meta_display_get_workspace_by_screen_index (MetaDisplay *display,
if (w->screen == screen)
{
if (i == index)
if (i == idx)
return w;
else
++i;
......
......@@ -106,6 +106,7 @@ struct _MetaDisplay
Atom atom_metacity_restart_message;
Atom atom_net_wm_strut;
Atom atom_win_hints;
Atom atom_metacity_reload_theme_message;
/* This is the actual window from focus events,
* not the one we last set
......
This diff is collapsed.
......@@ -74,10 +74,7 @@ struct _MetaUIFrame
struct _MetaFrames
{
GtkWindow parent_instance;
/* If we did a widget per frame, we wouldn't want to cache this. */
MetaFrameLayout *layout;
int text_height;
GHashTable *frames;
......@@ -121,11 +118,6 @@ void meta_frames_unflicker_bg (MetaFrames *frames,
void meta_frames_queue_draw (MetaFrames *frames,
Window xwindow);
void meta_frames_get_pixmap_for_control (MetaFrames *frames,
MetaFrameControl control,
GdkPixmap **pixmap,
GdkBitmap **mask);
void meta_frames_notify_menu_hide (MetaFrames *frames);
Window meta_frames_get_moving_frame (MetaFrames *frames);
......
......@@ -103,6 +103,8 @@ meta_gradient_create_simple (int width,
case META_GRADIENT_DIAGONAL:
return meta_gradient_create_diagonal (width, height,
from, to);
case META_GRADIENT_LAST:
break;
}
g_assert_not_reached ();
return NULL;
......@@ -126,6 +128,9 @@ meta_gradient_create_multi (int width,
return meta_gradient_create_multi_vertical (width, height, colors, n_colors);
case META_GRADIENT_DIAGONAL:
return meta_gradient_create_multi_diagonal (width, height, colors, n_colors);
case META_GRADIENT_LAST:
g_assert_not_reached ();
break;
}
}
else if (n_colors > 1)
......
......@@ -29,7 +29,8 @@ typedef enum
{
META_GRADIENT_VERTICAL,
META_GRADIENT_HORIZONTAL,
META_GRADIENT_DIAGONAL
META_GRADIENT_DIAGONAL,
META_GRADIENT_LAST
} MetaGradientType;
GdkPixbuf* meta_gradient_create_simple (int width,
......
......@@ -43,6 +43,9 @@ static MetaExitCode meta_exit_code = META_EXIT_SUCCESS;
static GMainLoop *meta_main_loop = NULL;
static gboolean meta_restart_after_quit = FALSE;
static void prefs_changed_callback (MetaPreference pref,
gpointer data);
static void
log_handler (const gchar *log_domain,
GLogLevelFlags log_level,
......@@ -175,12 +178,14 @@ main (int argc, char **argv)
/* Load prefs */
meta_prefs_init ();
meta_prefs_add_listener (prefs_changed_callback, NULL);
meta_ui_init (&argc, &argv);
/* must be after UI init so we can override GDK handlers */
meta_errors_init ();
#if 0
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
log_handler, NULL);
......@@ -205,6 +210,22 @@ main (int argc, char **argv)
if (meta_is_debugging ())
g_log_set_always_fatal (G_LOG_LEVEL_MASK);
#endif
meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE);
/* Try some panic stuff, this is lame but we really
* don't want users to lose their WM :-/
*/
if (!meta_ui_have_a_theme ())
meta_ui_set_current_theme ("Atlanta", FALSE);
if (!meta_ui_have_a_theme ())
meta_ui_set_current_theme ("Crux", FALSE);
if (!meta_ui_have_a_theme ())
meta_fatal (_("Could not find a theme! Be sure %s exits and contains the usual themes."),
METACITY_PKGDATADIR"/themes");
/* Connect to SM as late as possible - but before managing display,
* or we might try to manage a window before we have the session
......@@ -280,3 +301,19 @@ meta_restart (void)
meta_restart_after_quit = TRUE;
meta_quit (META_EXIT_SUCCESS);
}
static void
prefs_changed_callback (MetaPreference pref,
gpointer data)
{
switch (pref)
{
case META_PREF_THEME:
meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE);
break;
default:
/* handled elsewhere or otherwise */
break;
}
}
......@@ -24,6 +24,7 @@
#include "main.h"
#include "util.h"
#include "core.h"
#include "themewidget.h"
typedef struct _MenuItem MenuItem;
typedef struct _MenuData MenuData;
......@@ -117,6 +118,41 @@ activate_cb (GtkWidget *menuitem, gpointer data)
/* menu may now be freed */
}
static void
menu_icon_size_func (MetaArea *area,
int *width,
int *height,
void *user_data)
{
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU,
width, height);
}
static void
menu_icon_expose_func (MetaArea *area,
GdkEventExpose *event,
int x_offset,
int y_offset,
void *user_data)
{
int width, height;
MetaMenuIconType type;
type = GPOINTER_TO_INT (user_data);
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU,
&width, &height);
meta_theme_draw_menu_icon (meta_theme_get_current (),
GTK_WIDGET (area),
GTK_WIDGET (area)->window,
&event->area,
x_offset, y_offset,
width, height,
type);
}
MetaWindowMenu*
meta_window_menu_new (MetaFrames *frames,
MetaMenuOp ops,
......@@ -141,7 +177,7 @@ meta_window_menu_new (MetaFrames *frames,
menu->menu = gtk_menu_new ();
i = 0;
while (i < G_N_ELEMENTS (menuitems))
while (i < (int) G_N_ELEMENTS (menuitems))
{
if (ops & menuitems[i].op || menuitems[i].op == 0)
{
......@@ -155,48 +191,49 @@ meta_window_menu_new (MetaFrames *frames,
else
{
GtkWidget *image;
GdkPixmap *pix;
GdkBitmap *mask;
image = NULL;
pix = NULL;
mask = NULL;
switch (menuitems[i].op)
{
case META_MENU_OP_MAXIMIZE:
meta_frames_get_pixmap_for_control (frames,
META_FRAME_CONTROL_MAXIMIZE,
&pix, &mask);
image = meta_area_new ();
meta_area_setup (META_AREA (image),
menu_icon_size_func,
menu_icon_expose_func,
GINT_TO_POINTER (META_MENU_ICON_TYPE_MAXIMIZE),
NULL);
break;
case META_MENU_OP_UNMAXIMIZE:
meta_frames_get_pixmap_for_control (frames,
META_FRAME_CONTROL_UNMAXIMIZE,
&pix, &mask);
image = meta_area_new ();
meta_area_setup (META_AREA (image),
menu_icon_size_func,
menu_icon_expose_func,
GINT_TO_POINTER (META_MENU_ICON_TYPE_UNMAXIMIZE),
NULL);
break;
case META_MENU_OP_MINIMIZE:
meta_frames_get_pixmap_for_control (frames,
META_FRAME_CONTROL_MINIMIZE,
&pix, &mask);
image = meta_area_new ();
meta_area_setup (META_AREA (image),
menu_icon_size_func,
menu_icon_expose_func,
GINT_TO_POINTER (META_MENU_ICON_TYPE_MINIMIZE),
NULL);
break;
case META_MENU_OP_DELETE:
meta_frames_get_pixmap_for_control (frames,
META_FRAME_CONTROL_DELETE,
&pix, &mask);
image = meta_area_new ();
meta_area_setup (META_AREA (image),
menu_icon_size_func,
menu_icon_expose_func,
GINT_TO_POINTER (META_MENU_ICON_TYPE_CLOSE),
NULL);
break;
default:
break;
}
if (pix)
{
image = gtk_image_new_from_pixmap (pix, mask);
g_object_unref (G_OBJECT (pix));
g_object_unref (G_OBJECT (mask));
}
if (image == NULL &&
menuitems[i].stock_id)
......
......@@ -22,6 +22,21 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/general/theme</key>
<applyto>/apps/metacity/general/theme</applyto>
<owner>metacity</owner>
<type>string</type>
<default>Atlanta</default>
<locale name="C">
<short>Current theme</short>
<long>
The theme determines the appearance of window borders,
titlebar, and so forth.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/general/titlebar_uses_desktop_font</key>
<applyto>/apps/metacity/general/titlebar_uses_desktop_font</applyto>
......
......@@ -29,6 +29,7 @@
* notify listener and of course in the .schemas file
*/
#define KEY_FOCUS_MODE "/apps/metacity/general/focus_mode"
#define KEY_THEME "/apps/metacity/general/theme"
#define KEY_USE_DESKTOP_FONT "/apps/metacity/general/titlebar_uses_desktop_font"
#define KEY_TITLEBAR_FONT "/apps/metacity/general/titlebar_font"
#define KEY_TITLEBAR_FONT_SIZE "/apps/metacity/general/titlebar_font_size"
......@@ -43,6 +44,7 @@ static gboolean use_desktop_font = TRUE;
static PangoFontDescription *titlebar_font = NULL;
static int titlebar_font_size = 0;
static MetaFocusMode focus_mode = META_FOCUS_MODE_CLICK;
static char* current_theme = NULL;
static int num_workspaces = 4;
static gboolean application_based = FALSE;
...