...
This commit is contained in:
parent
d090d9f284
commit
5fd26a273d
@ -2,6 +2,8 @@
|
||||
INCLUDES=@METACITY_CFLAGS@ -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\"
|
||||
|
||||
metacity_SOURCES= \
|
||||
core.c \
|
||||
core.h \
|
||||
display.c \
|
||||
display.h \
|
||||
errors.c \
|
||||
@ -16,14 +18,14 @@ metacity_SOURCES= \
|
||||
keybindings.h \
|
||||
main.c \
|
||||
main.h \
|
||||
menu.c \
|
||||
menu.h \
|
||||
screen.c \
|
||||
screen.h \
|
||||
session.c \
|
||||
session.h \
|
||||
stack.c \
|
||||
stack.h \
|
||||
ui.c \
|
||||
ui.h \
|
||||
util.c \
|
||||
util.h \
|
||||
window.c \
|
||||
|
25
src/core.c
25
src/core.c
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "core.h"
|
||||
#include "display.h"
|
||||
#include "frame.h"
|
||||
|
||||
void
|
||||
meta_core_get_frame_size (Display *xdisplay,
|
||||
@ -43,10 +43,9 @@ meta_core_get_frame_size (Display *xdisplay,
|
||||
*height = window->frame->rect.height;
|
||||
}
|
||||
|
||||
void
|
||||
MetaFrameFlags
|
||||
meta_core_get_frame_flags (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaFrameFlags flags)
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaWindow *window;
|
||||
@ -59,3 +58,21 @@ meta_core_get_frame_flags (Display *xdisplay,
|
||||
|
||||
return meta_frame_get_flags (window->frame);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_queue_frame_resize (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);
|
||||
|
||||
|
||||
g_warning ("FIXME");
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,10 @@ void meta_core_get_frame_size (Display *xdisplay,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
void meta_core_get_frame_flags (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaFrameFlags flags);
|
||||
MetaFrameFlags meta_core_get_frame_flags (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
|
||||
void meta_core_queue_frame_resize (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
|
||||
#endif
|
||||
|
@ -197,9 +197,9 @@ meta_display_open (const char *name)
|
||||
*/
|
||||
display->leader_window = None;
|
||||
|
||||
screens = NULL;
|
||||
#if 0
|
||||
/* disable multihead pending GTK support */
|
||||
screens = NULL;
|
||||
i = 0;
|
||||
while (i < ScreenCount (xdisplay))
|
||||
{
|
||||
@ -212,9 +212,12 @@ meta_display_open (const char *name)
|
||||
++i;
|
||||
}
|
||||
#else
|
||||
{
|
||||
MetaScreen *screen;
|
||||
screen = meta_screen_new (display, DefaultScreen (xdisplay));
|
||||
if (screen)
|
||||
screens = g_slist_prepend (screens, screen);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (screens == NULL)
|
||||
@ -753,7 +756,7 @@ event_get_modified_window (MetaDisplay *display,
|
||||
static const char*
|
||||
focus_detail (int d)
|
||||
{
|
||||
const char *detail = "(????)";
|
||||
const char *detail = "???";
|
||||
switch (d)
|
||||
{
|
||||
case NotifyAncestor:
|
||||
@ -788,7 +791,7 @@ focus_detail (int d)
|
||||
static const char*
|
||||
focus_mode (int m)
|
||||
{
|
||||
const char *mode = "(????)";
|
||||
const char *mode = "???";
|
||||
switch (m)
|
||||
{
|
||||
case NotifyNormal:
|
||||
@ -959,7 +962,7 @@ meta_spew_event (MetaDisplay *display,
|
||||
else if (event->xproperty.state == PropertyDelete)
|
||||
state = "PropertyDelete";
|
||||
else
|
||||
state = "(????)";
|
||||
state = "???";
|
||||
|
||||
extra = g_strdup_printf ("atom: %s state: %s",
|
||||
str ? str : "(unknown atom)",
|
||||
|
@ -26,6 +26,17 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include "eventqueue.h"
|
||||
|
||||
/* this doesn't really belong here, oh well. */
|
||||
typedef struct _MetaRectangle MetaRectangle;
|
||||
|
||||
struct _MetaRectangle
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
typedef struct _MetaDisplay MetaDisplay;
|
||||
typedef struct _MetaFrame MetaFrame;
|
||||
typedef struct _MetaScreen MetaScreen;
|
||||
@ -109,7 +120,6 @@ MetaScreen* meta_display_screen_for_x_screen (MetaDisplay *display,
|
||||
Screen *screen);
|
||||
void meta_display_grab (MetaDisplay *display);
|
||||
void meta_display_ungrab (MetaDisplay *display);
|
||||
PangoContext* meta_display_get_pango_context (MetaDisplay *display);
|
||||
gboolean meta_display_is_double_click (MetaDisplay *display);
|
||||
|
||||
/* A given MetaWindow may have various X windows that "belong"
|
||||
|
11
src/frame.c
11
src/frame.c
@ -21,7 +21,6 @@
|
||||
|
||||
#include "frame.h"
|
||||
#include "errors.h"
|
||||
#include "uislave.h"
|
||||
|
||||
void
|
||||
meta_window_ensure_frame (MetaWindow *window)
|
||||
@ -103,7 +102,6 @@ void
|
||||
meta_window_destroy_frame (MetaWindow *window)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaFrameInfo info;
|
||||
|
||||
if (window->frame == NULL)
|
||||
return;
|
||||
@ -156,7 +154,7 @@ meta_frame_get_flags (MetaFrame *frame)
|
||||
flags |= META_FRAME_ALLOWS_DELETE;
|
||||
|
||||
if (frame->window->type == META_WINDOW_NORMAL)
|
||||
flags |= (META_FRAME_ALLOWS_ICONIFY | META_FRAME_ALLOWS_MAXIMIZE);
|
||||
flags |= (META_FRAME_ALLOWS_MINIMIZE | META_FRAME_ALLOWS_MAXIMIZE);
|
||||
|
||||
if (!frame->window->has_maximize_func)
|
||||
flags &= ~META_FRAME_ALLOWS_MAXIMIZE;
|
||||
@ -172,6 +170,8 @@ meta_frame_get_flags (MetaFrame *frame)
|
||||
|
||||
if (frame->window->on_all_workspaces)
|
||||
flags |= META_FRAME_STUCK;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void
|
||||
@ -210,12 +210,11 @@ meta_frame_sync_to_window (MetaFrame *frame,
|
||||
gboolean need_move,
|
||||
gboolean need_resize)
|
||||
{
|
||||
meta_verbose ("Syncing frame geometry %d,%d %dx%d (SE: %d,%d) pixel %ld\n",
|
||||
meta_verbose ("Syncing frame geometry %d,%d %dx%d (SE: %d,%d)\n",
|
||||
frame->rect.x, frame->rect.y,
|
||||
frame->rect.width, frame->rect.height,
|
||||
frame->rect.x + frame->rect.width,
|
||||
frame->rect.y + frame->rect.height,
|
||||
frame->bg_pixel);
|
||||
frame->rect.y + frame->rect.height);
|
||||
|
||||
/* set bg to none to avoid flicker */
|
||||
if (need_resize)
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include "window.h"
|
||||
|
||||
typedef struct _MetaFrameGeometry MetaFrameGeometry;
|
||||
|
||||
struct _MetaFrameGeometry
|
||||
{
|
||||
/* border sizes (space between frame and child) */
|
||||
|
469
src/frames.c
469
src/frames.c
@ -20,8 +20,10 @@
|
||||
*/
|
||||
|
||||
#include "frames.h"
|
||||
#include "util.h"
|
||||
#include "core.h"
|
||||
|
||||
|
||||
#if 0
|
||||
struct _MetaFrameActionGrab
|
||||
{
|
||||
MetaFrameAction action;
|
||||
@ -43,13 +45,13 @@ struct _MetaFrameActionGrab
|
||||
ButtonPressMask | ButtonReleaseMask | \
|
||||
PointerMotionMask | PointerMotionHintMask | \
|
||||
EnterWindowMask | LeaveWindowMask)
|
||||
#endif
|
||||
|
||||
struct _MetaFrame
|
||||
struct _MetaUIFrame
|
||||
{
|
||||
Window xwindow;
|
||||
GdkWindow *window;
|
||||
PangoLayout *layout;
|
||||
MetaFrameFlags flags;
|
||||
};
|
||||
|
||||
struct _MetaFrameProperties
|
||||
@ -98,14 +100,61 @@ struct _MetaFrameGeometry
|
||||
int top_height;
|
||||
int bottom_height;
|
||||
|
||||
MetaRectangle close_rect;
|
||||
MetaRectangle max_rect;
|
||||
MetaRectangle min_rect;
|
||||
MetaRectangle spacer_rect;
|
||||
MetaRectangle menu_rect;
|
||||
MetaRectangle title_rect;
|
||||
GdkRectangle close_rect;
|
||||
GdkRectangle max_rect;
|
||||
GdkRectangle min_rect;
|
||||
GdkRectangle spacer_rect;
|
||||
GdkRectangle menu_rect;
|
||||
GdkRectangle title_rect;
|
||||
};
|
||||
|
||||
static GdkRectangle*
|
||||
control_rect (MetaFrameControl control,
|
||||
MetaFrameGeometry *fgeom)
|
||||
{
|
||||
GdkRectangle *rect;
|
||||
|
||||
rect = NULL;
|
||||
switch (control)
|
||||
{
|
||||
case META_FRAME_CONTROL_TITLE:
|
||||
rect = &fgeom->title_rect;
|
||||
break;
|
||||
case META_FRAME_CONTROL_DELETE:
|
||||
rect = &fgeom->close_rect;
|
||||
break;
|
||||
case META_FRAME_CONTROL_MENU:
|
||||
rect = &fgeom->menu_rect;
|
||||
break;
|
||||
case META_FRAME_CONTROL_MINIMIZE:
|
||||
rect = &fgeom->min_rect;
|
||||
break;
|
||||
case META_FRAME_CONTROL_MAXIMIZE:
|
||||
rect = &fgeom->max_rect;
|
||||
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;
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
static void meta_frames_class_init (MetaFramesClass *klass);
|
||||
static void meta_frames_init (MetaFrames *frames);
|
||||
static void meta_frames_destroy (GtkObject *object);
|
||||
@ -150,12 +199,17 @@ gboolean meta_frames_window_state_event (GtkWidget *widget,
|
||||
|
||||
|
||||
static void meta_frames_calc_geometry (MetaFrames *frames,
|
||||
MetaFrame *frame,
|
||||
MetaUIFrame *frame,
|
||||
MetaFrameGeometry *fgeom);
|
||||
|
||||
static MetaFrame* meta_frames_lookup_window (MetaFrames *frames,
|
||||
static MetaUIFrame* meta_frames_lookup_window (MetaFrames *frames,
|
||||
Window xwindow);
|
||||
|
||||
enum
|
||||
{
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
@ -220,6 +274,8 @@ meta_frames_class_init (MetaFramesClass *class)
|
||||
|
||||
widget_class->style_set = meta_frames_style_set;
|
||||
|
||||
widget_class->expose_event = meta_frames_expose_event;
|
||||
|
||||
INT_PROPERTY ("left_width", 6, _("Left edge"), _("Left window edge width"));
|
||||
INT_PROPERTY ("right_width", 6, _("Right edge"), _("Right window edge width"));
|
||||
INT_PROPERTY ("bottom_height", 7, _("Bottom edge"), _("Bottom window edge height"));
|
||||
@ -299,7 +355,7 @@ meta_frames_destroy (GtkObject *object)
|
||||
tmp = winlist;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
frame = tmp->data;
|
||||
|
||||
@ -327,6 +383,26 @@ meta_frames_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
queue_recalc_func (gpointer key, gpointer value, gpointer data)
|
||||
{
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (data);
|
||||
frame = value;
|
||||
|
||||
/* If a resize occurs it will cause a redraw, but the
|
||||
* resize may not actually be needed so we always redraw
|
||||
* in case of color change.
|
||||
*/
|
||||
gtk_style_set_background (GTK_WIDGET (frames)->style,
|
||||
frame->window, GTK_STATE_NORMAL);
|
||||
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
||||
meta_core_queue_frame_resize (gdk_display,
|
||||
frame->xwindow);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_frames_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style)
|
||||
@ -409,38 +485,43 @@ meta_frames_style_set (GtkWidget *widget,
|
||||
{
|
||||
PangoFontMetrics metrics;
|
||||
PangoFont *font;
|
||||
gchar *lang;
|
||||
PangoLanguage *lang;
|
||||
|
||||
font = pango_context_load_font (gtk_widget_get_pango_context (widget),
|
||||
widget->style->font_desc);
|
||||
lang = pango_context_get_lang (gtk_widget_get_pango_context (widget));
|
||||
lang = pango_context_get_language (gtk_widget_get_pango_context (widget));
|
||||
pango_font_get_metrics (font, lang, &metrics);
|
||||
g_free (lang);
|
||||
|
||||
g_object_unref (G_OBJECT (font));
|
||||
|
||||
frames->text_height = metrics.ascent + metrics.descent;
|
||||
}
|
||||
|
||||
/* Queue a draw/resize on all frames */
|
||||
g_hash_table_foreach (frames->frames,
|
||||
queue_recalc_func, frames);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_frames_calc_geometry (MetaFrames *frames,
|
||||
MetaFrame *frame,
|
||||
MetaUIFrame *frame,
|
||||
MetaFrameGeometry *fgeom)
|
||||
{
|
||||
int x;
|
||||
int button_y;
|
||||
int title_right_edge;
|
||||
gboolean shaded;
|
||||
MetaFrameProperties props;
|
||||
int buttons_height, title_height, spacer_height;
|
||||
int width, height;
|
||||
MetaFrameFlags flags;
|
||||
|
||||
props = *(frames->props);
|
||||
|
||||
meta_core_get_frame_size (gdk_display, frame->xwindow,
|
||||
&width, &height);
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
|
||||
buttons_height = props.button_height +
|
||||
props.button_border.top + props.button_border.bottom;
|
||||
title_height = frames->text_height +
|
||||
@ -454,18 +535,18 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
fgeom->left_width = props.left_width;
|
||||
fgeom->right_width = props.right_width;
|
||||
|
||||
if (frame->flags & META_FRAME_SHADED)
|
||||
if (flags & META_FRAME_SHADED)
|
||||
fgeom->bottom_height = 0;
|
||||
else
|
||||
fgeom->bottom_height = props.bottom_height;
|
||||
|
||||
x = width - fgeom->button_inset;
|
||||
x = width - props.right_inset;
|
||||
|
||||
/* center buttons */
|
||||
button_y = (fgeom->top_height -
|
||||
(props.button_height + props.button_border.top + props.button_border.bottom)) / 2 + props.button_border.top;
|
||||
|
||||
if ((frame->flags & META_FRAME_ALLOWS_DELETE) &&
|
||||
if ((flags & META_FRAME_ALLOWS_DELETE) &&
|
||||
x >= 0)
|
||||
{
|
||||
fgeom->close_rect.x = x - props.button_border.right - props.button_width;
|
||||
@ -483,7 +564,7 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
fgeom->close_rect.height = 0;
|
||||
}
|
||||
|
||||
if ((frame->flags & META_FRAME_ALLOWS_MAXIMIZE) &&
|
||||
if ((flags & META_FRAME_ALLOWS_MAXIMIZE) &&
|
||||
x >= 0)
|
||||
{
|
||||
fgeom->max_rect.x = x - props.button_border.right - props.button_width;
|
||||
@ -501,7 +582,7 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
fgeom->max_rect.height = 0;
|
||||
}
|
||||
|
||||
if ((frame->flags & META_FRAME_ALLOWS_MINIMIZE) &&
|
||||
if ((flags & META_FRAME_ALLOWS_MINIMIZE) &&
|
||||
x >= 0)
|
||||
{
|
||||
fgeom->min_rect.x = x - props.button_border.right - props.button_width;
|
||||
@ -542,9 +623,9 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
title_right_edge = x - props.title_border.right;
|
||||
|
||||
/* Now x changes to be position from the left */
|
||||
x = fgeom->left_inset;
|
||||
x = props.left_inset;
|
||||
|
||||
if ((frame->flags & META_FRAME_ALLOWS_MENU) &&
|
||||
if ((flags & META_FRAME_ALLOWS_MENU) &&
|
||||
x < title_right_edge)
|
||||
{
|
||||
fgeom->menu_rect.x = x + props.button_border.left;
|
||||
@ -578,7 +659,7 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
fgeom->title_rect.x = x + props.title_border.left;
|
||||
fgeom->title_rect.y = props.title_border.top;
|
||||
fgeom->title_rect.width = title_right_edge - fgeom->title_rect.x;
|
||||
fgeom->title_rect.height = frames->top_height - props.title_border.top - props.title_border.bottom;
|
||||
fgeom->title_rect.height = fgeom->top_height - props.title_border.top - props.title_border.bottom;
|
||||
|
||||
/* Nuke title if it won't fit */
|
||||
if (fgeom->title_rect.width < 0 ||
|
||||
@ -589,15 +670,19 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
}
|
||||
}
|
||||
|
||||
MetaFrames*
|
||||
meta_frames_new (void)
|
||||
{
|
||||
return g_object_new (META_TYPE_FRAMES, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_frames_manage_window (MetaFrames *frames,
|
||||
Window xwindow)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
frame = g_new (MetaFrame, 1);
|
||||
frame = g_new (MetaUIFrame, 1);
|
||||
|
||||
frame->window = gdk_window_foreign_new (xwindow);
|
||||
|
||||
@ -632,16 +717,15 @@ meta_frames_manage_window (MetaFrames *frames,
|
||||
|
||||
frame->xwindow = xwindow;
|
||||
frame->layout = NULL;
|
||||
frame->flags = 0;
|
||||
|
||||
g_hash_table_insert (frames->frames, &frame->xwindow);
|
||||
g_hash_table_insert (frames->frames, &frame->xwindow, frame);
|
||||
}
|
||||
|
||||
void
|
||||
meta_frames_unmanage_window (MetaFrames *frames,
|
||||
Window xwindow)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
frame = g_hash_table_lookup (frames->frames, &xwindow);
|
||||
|
||||
@ -657,14 +741,14 @@ meta_frames_unmanage_window (MetaFrames *frames,
|
||||
g_free (frame);
|
||||
}
|
||||
else
|
||||
meta_ui_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
|
||||
meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
|
||||
}
|
||||
|
||||
static MetaFrame*
|
||||
static MetaUIFrame*
|
||||
meta_frames_lookup_window (MetaFrames *frames,
|
||||
Window xwindow)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
frame = g_hash_table_lookup (frames->frames, &xwindow);
|
||||
|
||||
@ -679,7 +763,7 @@ meta_frames_get_geometry (MetaFrames *frames,
|
||||
{
|
||||
MetaFrameGeometry fgeom;
|
||||
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
frame = meta_frames_lookup_window (frames, xwindow);
|
||||
|
||||
@ -703,7 +787,7 @@ meta_frames_reset_bg (MetaFrames *frames,
|
||||
Window xwindow)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
widget = GTK_WIDGET (frames);
|
||||
|
||||
@ -712,32 +796,12 @@ meta_frames_reset_bg (MetaFrames *frames,
|
||||
gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_frames_set_flags (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
MetaFrameFlags flags)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
MetaFrame *frame;
|
||||
|
||||
widget = GTK_WIDGET (frames);
|
||||
|
||||
frame = meta_frames_lookup_window (frames, xwindow);
|
||||
|
||||
if (frame->flags == flags)
|
||||
return;
|
||||
|
||||
frame->flags = flags;
|
||||
|
||||
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
meta_frames_queue_draw (MetaFrames *frames,
|
||||
Window xwindow)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
widget = GTK_WIDGET (frames);
|
||||
|
||||
@ -752,7 +816,7 @@ meta_frames_set_title (MetaFrames *frames,
|
||||
const char *title)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
widget = GTK_WIDGET (frames);
|
||||
|
||||
@ -771,7 +835,7 @@ gboolean
|
||||
meta_frames_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -787,7 +851,7 @@ gboolean
|
||||
meta_frames_button_release_event (GtkWidget *widget,
|
||||
GdkEventButton *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -803,7 +867,7 @@ gboolean
|
||||
meta_frames_motion_notify_event (GtkWidget *widget,
|
||||
GdkEventMotion *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -819,7 +883,7 @@ gboolean
|
||||
meta_frames_destroy_event (GtkWidget *widget,
|
||||
GdkEventAny *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -831,12 +895,59 @@ meta_frames_destroy_event (GtkWidget *widget,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_current_control_bg (MetaFrames *frames,
|
||||
MetaUIFrame *frame,
|
||||
MetaFrameGeometry *fgeom)
|
||||
{
|
||||
GdkRectangle *rect;
|
||||
#if 0
|
||||
rect = control_rect (frames->current_control, fgeom);
|
||||
|
||||
if (rect == NULL)
|
||||
return;
|
||||
|
||||
if (frames->current_control == META_FRAME_CONTROL_TITLE)
|
||||
return;
|
||||
|
||||
switch (frames->current_control_state)
|
||||
{
|
||||
/* FIXME turn this off after testing */
|
||||
case META_STATE_PRELIGHT:
|
||||
XFillRectangle (info->display,
|
||||
info->drawable,
|
||||
screen_data->prelight_gc,
|
||||
xoff + rect->x,
|
||||
yoff + rect->y,
|
||||
rect->width, rect->height);
|
||||
break;
|
||||
|
||||
case META_STATE_ACTIVE:
|
||||
XFillRectangle (info->display,
|
||||
info->drawable,
|
||||
screen_data->active_gc,
|
||||
xoff + rect->x,
|
||||
yoff + rect->y,
|
||||
rect->width, rect->height);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_frames_expose_event (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
MetaFrameGeometry fgeom;
|
||||
MetaFrameFlags flags;
|
||||
int width, height;
|
||||
GtkBorder inner;
|
||||
GdkGCValues vals;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
|
||||
@ -844,6 +955,186 @@ meta_frames_expose_event (GtkWidget *widget,
|
||||
if (frame == NULL)
|
||||
return FALSE;
|
||||
|
||||
meta_frames_calc_geometry (frames, frame, &fgeom);
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
meta_core_get_frame_size (gdk_display, frame->xwindow, &width, &height);
|
||||
|
||||
/* Black line around outside to give definition */
|
||||
gdk_draw_rectangle (frame->window,
|
||||
widget->style->black_gc,
|
||||
FALSE,
|
||||
0, 0, width - 1, height - 1);
|
||||
|
||||
/* Light GC on top/left edges */
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->light_gc[GTK_STATE_NORMAL],
|
||||
1, 1,
|
||||
1, height - 2);
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->light_gc[GTK_STATE_NORMAL],
|
||||
1, 1,
|
||||
width - 2, 1);
|
||||
/* Dark on bottom/right */
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->dark_gc[GTK_STATE_NORMAL],
|
||||
width - 2, 1,
|
||||
width - 2, height - 2);
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->dark_gc[GTK_STATE_NORMAL],
|
||||
1, height - 2,
|
||||
width - 2, height - 2);
|
||||
|
||||
if (flags & META_FRAME_HAS_FOCUS)
|
||||
{
|
||||
/* Black line around inside while we have focus */
|
||||
|
||||
gdk_draw_rectangle (frame->window,
|
||||
widget->style->black_gc,
|
||||
FALSE,
|
||||
fgeom.left_width - 1,
|
||||
fgeom.top_height - 1,
|
||||
width - fgeom.right_width - fgeom.left_width + 1,
|
||||
height - fgeom.bottom_height - fgeom.top_height + 1);
|
||||
}
|
||||
|
||||
draw_current_control_bg (frames, frame, &fgeom);
|
||||
|
||||
if (event->area.y < fgeom.top_height &&
|
||||
fgeom.title_rect.width > 0 && fgeom.title_rect.height > 0)
|
||||
{
|
||||
GdkRectangle clip;
|
||||
GdkGC *layout_gc;
|
||||
|
||||
clip = fgeom.title_rect;
|
||||
clip.x += frames->props->text_border.left;
|
||||
clip.width -= frames->props->text_border.left +
|
||||
frames->props->text_border.right;
|
||||
|
||||
layout_gc = widget->style->text_gc[GTK_STATE_NORMAL];
|
||||
if (flags & META_FRAME_HAS_FOCUS)
|
||||
{
|
||||
layout_gc = widget->style->text_gc[GTK_STATE_SELECTED];
|
||||
|
||||
/* Draw blue background */
|
||||
gdk_draw_rectangle (frame->window,
|
||||
widget->style->base_gc[GTK_STATE_SELECTED],
|
||||
TRUE,
|
||||
fgeom.title_rect.x,
|
||||
fgeom.title_rect.y,
|
||||
fgeom.title_rect.width,
|
||||
fgeom.title_rect.height);
|
||||
}
|
||||
|
||||
gdk_gc_set_clip_rectangle (layout_gc, &clip);
|
||||
gdk_draw_layout (frame->window,
|
||||
layout_gc,
|
||||
fgeom.title_rect.x + frames->props->text_border.left,
|
||||
fgeom.title_rect.y + frames->props->text_border.top,
|
||||
frame->layout);
|
||||
gdk_gc_set_clip_rectangle (layout_gc, NULL);
|
||||
}
|
||||
|
||||
inner = frames->props->inner_button_border;
|
||||
|
||||
if (fgeom.close_rect.width > 0 && fgeom.close_rect.height > 0)
|
||||
{
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
fgeom.close_rect.x + inner.left,
|
||||
fgeom.close_rect.y + inner.top,
|
||||
fgeom.close_rect.x + fgeom.close_rect.width - inner.right,
|
||||
fgeom.close_rect.y + fgeom.close_rect.height - inner.bottom);
|
||||
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
fgeom.close_rect.x + inner.left,
|
||||
fgeom.close_rect.y + fgeom.close_rect.height - inner.bottom,
|
||||
fgeom.close_rect.x + fgeom.close_rect.width - inner.right,
|
||||
fgeom.close_rect.y + inner.top);
|
||||
}
|
||||
|
||||
if (fgeom.max_rect.width > 0 && fgeom.max_rect.height > 0)
|
||||
{
|
||||
gdk_draw_rectangle (frame->window,
|
||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
FALSE,
|
||||
fgeom.max_rect.x + inner.left,
|
||||
fgeom.max_rect.y + inner.top,
|
||||
fgeom.max_rect.width - inner.left - inner.right,
|
||||
fgeom.max_rect.height - inner.top - inner.bottom);
|
||||
|
||||
vals.line_width = 3;
|
||||
gdk_gc_set_values (widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
&vals,
|
||||
GDK_GC_LINE_WIDTH);
|
||||
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
fgeom.max_rect.x + inner.left,
|
||||
fgeom.max_rect.y + inner.top,
|
||||
fgeom.max_rect.x + fgeom.max_rect.width - inner.right,
|
||||
fgeom.max_rect.y + fgeom.max_rect.height - inner.bottom);
|
||||
|
||||
vals.line_width = 0;
|
||||
gdk_gc_set_values (widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
&vals,
|
||||
GDK_GC_LINE_WIDTH);
|
||||
}
|
||||
|
||||
if (fgeom.min_rect.width > 0 && fgeom.min_rect.height > 0)
|
||||
{
|
||||
|
||||
vals.line_width = 3;
|
||||
gdk_gc_set_values (widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
&vals,
|
||||
GDK_GC_LINE_WIDTH);
|
||||
|
||||
gdk_draw_line (frame->window,
|
||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
fgeom.min_rect.x + inner.left,
|
||||
fgeom.min_rect.y + inner.top,
|
||||
fgeom.min_rect.x + fgeom.min_rect.width - inner.right,
|
||||
fgeom.min_rect.y + fgeom.min_rect.height - inner.bottom);
|
||||
|
||||
vals.line_width = 0;
|
||||
gdk_gc_set_values (widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||
&vals,
|
||||
GDK_GC_LINE_WIDTH);
|
||||
}
|
||||
|
||||
if (fgeom.spacer_rect.width > 0 && fgeom.spacer_rect.height > 0)
|
||||
{
|
||||
gtk_paint_vline (widget->style,
|
||||
frame->window,
|
||||
GTK_STATE_NORMAL,
|
||||
&event->area,
|
||||
widget,
|
||||
"metacity_frame_spacer",
|
||||
fgeom.spacer_rect.y,
|
||||
fgeom.spacer_rect.y + fgeom.spacer_rect.height,
|
||||
fgeom.spacer_rect.x + fgeom.spacer_rect.width / 2);
|
||||
}
|
||||
|
||||
if (fgeom.menu_rect.width > 0 && fgeom.menu_rect.height > 0)
|
||||
{
|
||||
int x, y;
|
||||
x = fgeom.menu_rect.x;
|
||||
y = fgeom.menu_rect.y;
|
||||
x += (fgeom.menu_rect.width - 7) / 2;
|
||||
y += (fgeom.menu_rect.height - 5) / 2;
|
||||
|
||||
gtk_paint_arrow (widget->style,
|
||||
frame->window,
|
||||
GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_OUT,
|
||||
&event->area,
|
||||
widget,
|
||||
"metacity_menu_button",
|
||||
GTK_ARROW_DOWN,
|
||||
TRUE,
|
||||
x, y, 7, 5);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -851,7 +1142,7 @@ gboolean
|
||||
meta_frames_key_press_event (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -867,7 +1158,7 @@ gboolean
|
||||
meta_frames_key_release_event (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -883,7 +1174,7 @@ gboolean
|
||||
meta_frames_enter_notify_event (GtkWidget *widget,
|
||||
GdkEventCrossing *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -899,7 +1190,7 @@ gboolean
|
||||
meta_frames_leave_notify_event (GtkWidget *widget,
|
||||
GdkEventCrossing *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -915,7 +1206,7 @@ gboolean
|
||||
meta_frames_configure_event (GtkWidget *widget,
|
||||
GdkEventConfigure *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -931,7 +1222,7 @@ gboolean
|
||||
meta_frames_focus_in_event (GtkWidget *widget,
|
||||
GdkEventFocus *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -947,7 +1238,7 @@ gboolean
|
||||
meta_frames_focus_out_event (GtkWidget *widget,
|
||||
GdkEventFocus *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -963,7 +1254,7 @@ gboolean
|
||||
meta_frames_map_event (GtkWidget *widget,
|
||||
GdkEventAny *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -979,7 +1270,7 @@ gboolean
|
||||
meta_frames_unmap_event (GtkWidget *widget,
|
||||
GdkEventAny *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -995,7 +1286,7 @@ gboolean
|
||||
meta_frames_property_notify_event (GtkWidget *widget,
|
||||
GdkEventProperty *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -1011,7 +1302,7 @@ gboolean
|
||||
meta_frames_client_event (GtkWidget *widget,
|
||||
GdkEventClient *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -1027,7 +1318,7 @@ gboolean
|
||||
meta_frames_window_state_event (GtkWidget *widget,
|
||||
GdkEventWindowState *event)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
MetaFrames *frames;
|
||||
|
||||
frames = META_FRAMES (widget);
|
||||
@ -1043,7 +1334,7 @@ meta_frames_window_state_event (GtkWidget *widget,
|
||||
#if 0
|
||||
|
||||
static void
|
||||
frame_query_root_pointer (MetaFrame *frame,
|
||||
frame_query_root_pointer (MetaUIFrame *frame,
|
||||
int *x, int *y)
|
||||
{
|
||||
Window root_return, child_return;
|
||||
@ -1068,7 +1359,7 @@ frame_query_root_pointer (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
show_tip_now (MetaFrame *frame)
|
||||
show_tip_now (MetaUIFrame *frame)
|
||||
{
|
||||
const char *tiptext;
|
||||
|
||||
@ -1131,7 +1422,7 @@ show_tip_now (MetaFrame *frame)
|
||||
static gboolean
|
||||
tip_timeout_func (gpointer data)
|
||||
{
|
||||
MetaFrame *frame;
|
||||
MetaUIFrame *frame;
|
||||
|
||||
frame = data;
|
||||
|
||||
@ -1142,7 +1433,7 @@ tip_timeout_func (gpointer data)
|
||||
|
||||
#define TIP_DELAY 250
|
||||
static void
|
||||
queue_tip (MetaFrame *frame)
|
||||
queue_tip (MetaUIFrame *frame)
|
||||
{
|
||||
if (frame->tooltip_timeout)
|
||||
g_source_remove (frame->tooltip_timeout);
|
||||
@ -1153,7 +1444,7 @@ queue_tip (MetaFrame *frame)
|
||||
}
|
||||
|
||||
static void
|
||||
clear_tip (MetaFrame *frame)
|
||||
clear_tip (MetaUIFrame *frame)
|
||||
{
|
||||
if (frame->tooltip_timeout)
|
||||
{
|
||||
@ -1164,7 +1455,7 @@ clear_tip (MetaFrame *frame)
|
||||
}
|
||||
|
||||
static MetaFrameControl
|
||||
frame_get_control (MetaFrame *frame,
|
||||
frame_get_control (MetaUIFrame *frame,
|
||||
int x, int y)
|
||||
{
|
||||
MetaFrameInfo info;
|
||||
@ -1181,7 +1472,7 @@ frame_get_control (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
update_move (MetaFrame *frame,
|
||||
update_move (MetaUIFrame *frame,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
@ -1197,7 +1488,7 @@ update_move (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
update_resize_se (MetaFrame *frame,
|
||||
update_resize_se (MetaUIFrame *frame,
|
||||
int x, int y)
|
||||
{
|
||||
int dx, dy;
|
||||
@ -1212,7 +1503,7 @@ update_resize_se (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
update_current_control (MetaFrame *frame,
|
||||
update_current_control (MetaUIFrame *frame,
|
||||
int x_root, int y_root)
|
||||
{
|
||||
MetaFrameControl old;
|
||||
@ -1238,7 +1529,7 @@ update_current_control (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
grab_action (MetaFrame *frame,
|
||||
grab_action (MetaUIFrame *frame,
|
||||
MetaFrameAction action,
|
||||
Time time)
|
||||
{
|
||||
@ -1266,7 +1557,7 @@ grab_action (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
ungrab_action (MetaFrame *frame,
|
||||
ungrab_action (MetaUIFrame *frame,
|
||||
Time time)
|
||||
{
|
||||
int x, y;
|
||||
@ -1289,7 +1580,7 @@ ungrab_action (MetaFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
get_menu_items (MetaFrame *frame,
|
||||
get_menu_items (MetaUIFrame *frame,
|
||||
MetaFrameInfo *info,
|
||||
MetaMessageWindowMenuOps *ops,
|
||||
MetaMessageWindowMenuOps *insensitive)
|
||||
@ -1325,7 +1616,7 @@ get_menu_items (MetaFrame *frame,
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_frame_event (MetaFrame *frame,
|
||||
meta_frame_event (MetaUIFrame *frame,
|
||||
XEvent *event)
|
||||
{
|
||||
switch (event->type)
|
||||
|
16
src/frames.h
16
src/frames.h
@ -49,16 +49,16 @@ typedef enum
|
||||
*/
|
||||
|
||||
#define META_TYPE_FRAMES (meta_frames_get_type ())
|
||||
#define META_FRAMES(obj) (META_CHECK_CAST ((obj), META_TYPE_FRAMES, MetaFrames))
|
||||
#define META_FRAMES_CLASS(klass) (META_CHECK_CLASS_CAST ((klass), META_TYPE_FRAMES, MetaFramesClass))
|
||||
#define META_IS_FRAMES(obj) (META_CHECK_TYPE ((obj), META_TYPE_FRAMES))
|
||||
#define META_IS_FRAMES_CLASS(klass) (META_CHECK_CLASS_TYPE ((klass), META_TYPE_FRAMES))
|
||||
#define META_FRAMES_GET_CLASS(obj) (META_CHECK_GET_CLASS ((obj), META_TYPE_FRAMES, MetaFramesClass))
|
||||
#define META_FRAMES(obj) (GTK_CHECK_CAST ((obj), META_TYPE_FRAMES, MetaFrames))
|
||||
#define META_FRAMES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), META_TYPE_FRAMES, MetaFramesClass))
|
||||
#define META_IS_FRAMES(obj) (GTK_CHECK_TYPE ((obj), META_TYPE_FRAMES))
|
||||
#define META_IS_FRAMES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), META_TYPE_FRAMES))
|
||||
#define META_FRAMES_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), META_TYPE_FRAMES, MetaFramesClass))
|
||||
|
||||
typedef struct _MetaFrames MetaFrames;
|
||||
typedef struct _MetaFramesClass MetaFramesClass;
|
||||
|
||||
typedef struct _MetaFrame MetaFrame;
|
||||
typedef struct _MetaUIFrame MetaUIFrame;
|
||||
typedef struct _MetaFrameProperties MetaFrameProperties;
|
||||
|
||||
struct _MetaFrames
|
||||
@ -99,10 +99,6 @@ void meta_frames_get_geometry (MetaFrames *frames,
|
||||
void meta_frames_reset_bg (MetaFrames *frames,
|
||||
Window xwindow);
|
||||
|
||||
void meta_frames_set_flags (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
MetaFrameFlags flags);
|
||||
|
||||
void meta_frames_queue_draw (MetaFrames *frames,
|
||||
Window xwindow);
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "errors.h"
|
||||
#include "ui.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
170
src/screen.c
170
src/screen.c
@ -98,7 +98,6 @@ meta_screen_new (MetaDisplay *display,
|
||||
Window xroot;
|
||||
Display *xdisplay;
|
||||
Cursor cursor;
|
||||
XGCValues vals;
|
||||
|
||||
/* Only display->name, display->xdisplay, and display->error_traps
|
||||
* can really be used in this function, since normally screens are
|
||||
@ -148,11 +147,6 @@ meta_screen_new (MetaDisplay *display,
|
||||
screen->screen_name = get_screen_name (display, number);
|
||||
screen->xscreen = ScreenOfDisplay (xdisplay, number);
|
||||
screen->xroot = xroot;
|
||||
screen->pango_context = NULL;
|
||||
|
||||
screen->engine = &meta_default_engine;
|
||||
|
||||
screen->showing_tooltip = FALSE;
|
||||
|
||||
if (display->leader_window == None)
|
||||
display->leader_window = XCreateSimpleWindow (display->xdisplay,
|
||||
@ -174,24 +168,13 @@ meta_screen_new (MetaDisplay *display,
|
||||
meta_workspace_new (screen);
|
||||
meta_workspace_new (screen);
|
||||
|
||||
meta_screen_init_visual_info (screen);
|
||||
meta_screen_init_ui_colors (screen);
|
||||
|
||||
meta_screen_grab_keys (screen);
|
||||
|
||||
screen->scratch_gc = XCreateGC (screen->display->xdisplay,
|
||||
screen->xroot,
|
||||
0,
|
||||
&vals);
|
||||
|
||||
screen->ui = meta_ui_new (screen->display,
|
||||
screen->ui = meta_ui_new (screen->display->xdisplay,
|
||||
screen->xscreen);
|
||||
|
||||
screen->stack = meta_stack_new (screen);
|
||||
|
||||
/* hack pango to get its coverage window */
|
||||
meta_screen_get_pango_context (screen, NULL, PANGO_DIRECTION_LTR);
|
||||
|
||||
meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
|
||||
screen->number, screen->screen_name, screen->xroot);
|
||||
|
||||
@ -203,15 +186,10 @@ meta_screen_free (MetaScreen *screen)
|
||||
{
|
||||
meta_screen_ungrab_keys (screen);
|
||||
|
||||
meta_ui_slave_free (screen->uislave);
|
||||
meta_ui_free (screen->ui);
|
||||
|
||||
meta_stack_free (screen->stack);
|
||||
|
||||
XFreeGC (screen->display->xdisplay,
|
||||
screen->scratch_gc);
|
||||
|
||||
if (screen->pango_context)
|
||||
g_object_unref (G_OBJECT (screen->pango_context));
|
||||
g_free (screen->screen_name);
|
||||
g_free (screen);
|
||||
}
|
||||
@ -255,129 +233,6 @@ meta_screen_manage_all_windows (MetaScreen *screen)
|
||||
XFree (children);
|
||||
}
|
||||
|
||||
static GC
|
||||
get_gc_func (PangoContext *context, PangoColor *color, GC base_gc)
|
||||
{
|
||||
MetaScreen *screen;
|
||||
GC new_gc;
|
||||
XGCValues vals;
|
||||
int copy_mask = (GCFunction | GCPlaneMask | GCForeground | GCBackground |
|
||||
GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle |
|
||||
GCFillStyle | GCFillRule | GCTile | GCStipple | GCTileStipXOrigin |
|
||||
GCTileStipYOrigin | GCFont | GCSubwindowMode |
|
||||
GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin |
|
||||
GCDashOffset | GCArcMode);
|
||||
|
||||
screen = g_object_get_data (G_OBJECT (context), "meta-screen");
|
||||
|
||||
new_gc = XCreateGC (screen->display->xdisplay,
|
||||
screen->xroot,
|
||||
0,
|
||||
&vals);
|
||||
|
||||
XCopyGC (screen->display->xdisplay, base_gc, copy_mask, new_gc);
|
||||
|
||||
vals.foreground = meta_screen_get_x_pixel (screen, color);
|
||||
XChangeGC (screen->display->xdisplay, new_gc, GCForeground, &vals);
|
||||
|
||||
return new_gc;
|
||||
}
|
||||
|
||||
static void
|
||||
free_gc_func (PangoContext *context, GC gc)
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = g_object_get_data (G_OBJECT (context), "meta-screen");
|
||||
|
||||
XFreeGC (screen->display->xdisplay, gc);
|
||||
}
|
||||
|
||||
static char*
|
||||
get_default_language (void)
|
||||
{
|
||||
/* Copied from GTK, Copyright 2001 Red Hat Inc. */
|
||||
gchar *lang;
|
||||
gchar *p;
|
||||
|
||||
lang = g_strdup (setlocale (LC_CTYPE, NULL));
|
||||
p = strchr (lang, '.');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
p = strchr (lang, '@');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
|
||||
return lang;
|
||||
}
|
||||
|
||||
PangoContext*
|
||||
meta_screen_get_pango_context (MetaScreen *screen,
|
||||
const PangoFontDescription *desc,
|
||||
PangoDirection direction)
|
||||
{
|
||||
if (screen->pango_context == NULL)
|
||||
{
|
||||
PangoContext *ctx;
|
||||
char *lang;
|
||||
|
||||
/* Copied from GDK, Copyright 2001 Red Hat, Inc. */
|
||||
#ifdef HAVE_XFT
|
||||
static int use_xft = -1;
|
||||
if (use_xft == -1)
|
||||
{
|
||||
char *val = g_getenv ("META_USE_XFT");
|
||||
|
||||
use_xft = val && (atoi (val) != 0);
|
||||
}
|
||||
|
||||
if (use_xft)
|
||||
ctx = pango_xft_get_context (screen->display, screen->number);
|
||||
else
|
||||
#endif /* HAVE_XFT */
|
||||
ctx = pango_x_get_context (screen->display->xdisplay);
|
||||
|
||||
g_object_set_data (G_OBJECT (ctx), "meta-screen", screen);
|
||||
|
||||
pango_x_context_set_funcs (ctx, get_gc_func, free_gc_func);
|
||||
|
||||
lang = get_default_language ();
|
||||
pango_context_set_lang (ctx, lang);
|
||||
g_free (lang);
|
||||
|
||||
/* FIXME these two lines are wrong;
|
||||
* we should be storing a context for each direction/desc,
|
||||
* so that the args to meta_screen_get_pango_context()
|
||||
* are honored.
|
||||
*/
|
||||
pango_context_set_base_dir (ctx, direction);
|
||||
|
||||
if (desc == NULL)
|
||||
{
|
||||
desc = pango_font_description_from_string ("Sans 12");
|
||||
pango_context_set_font_description (ctx, desc);
|
||||
pango_font_description_free (desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
pango_context_set_font_description (ctx, desc);
|
||||
}
|
||||
|
||||
{
|
||||
/* Make Pango grab server now not later */
|
||||
PangoLayout *hack;
|
||||
hack = pango_layout_new (ctx);
|
||||
pango_layout_set_text (hack, "foo", -1);
|
||||
pango_layout_get_extents (hack, NULL, NULL);
|
||||
g_object_unref (G_OBJECT (hack));
|
||||
}
|
||||
|
||||
screen->pango_context = ctx;
|
||||
}
|
||||
|
||||
return screen->pango_context;
|
||||
}
|
||||
|
||||
MetaScreen*
|
||||
meta_screen_for_x_screen (Screen *xscreen)
|
||||
{
|
||||
@ -495,27 +350,6 @@ meta_screen_queue_frame_redraws (MetaScreen *screen)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
meta_screen_show_tip (MetaScreen *screen,
|
||||
int root_x,
|
||||
int root_y,
|
||||
const char *markup)
|
||||
{
|
||||
/* even if screen->showing_tip, may change position/text */
|
||||
meta_ui_slave_show_tip (screen->uislave, root_x, root_y, markup);
|
||||
screen->showing_tooltip = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_hide_tip (MetaScreen *screen)
|
||||
{
|
||||
if (screen->showing_tooltip)
|
||||
{
|
||||
meta_ui_slave_hide_tip (screen->uislave);
|
||||
screen->showing_tooltip = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
meta_screen_get_n_workspaces (MetaScreen *screen)
|
||||
{
|
||||
|
25
src/screen.h
25
src/screen.h
@ -23,7 +23,6 @@
|
||||
#define META_SCREEN_H
|
||||
|
||||
#include "display.h"
|
||||
#include "theme.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include "ui.h"
|
||||
|
||||
@ -37,26 +36,10 @@ struct _MetaScreen
|
||||
char *screen_name;
|
||||
Screen *xscreen;
|
||||
Window xroot;
|
||||
MetaThemeEngine *engine;
|
||||
MetaUI *ui;
|
||||
|
||||
MetaWorkspace *active_workspace;
|
||||
|
||||
XVisualInfo visual_info;
|
||||
MetaUIColors colors;
|
||||
|
||||
/* In screen's visual, no guarantees about colors, shouldn't be
|
||||
* left with a clip.
|
||||
*/
|
||||
GC scratch_gc;
|
||||
|
||||
guint showing_tooltip : 1;
|
||||
|
||||
/* we only need one since we only draw to a single visual (that of
|
||||
* root window)
|
||||
*/
|
||||
PangoContext *pango_context;
|
||||
|
||||
MetaStack *stack;
|
||||
};
|
||||
|
||||
@ -64,19 +47,11 @@ MetaScreen* meta_screen_new (MetaDisplay *displ
|
||||
int number);
|
||||
void meta_screen_free (MetaScreen *screen);
|
||||
void meta_screen_manage_all_windows (MetaScreen *screen);
|
||||
PangoContext* meta_screen_get_pango_context (MetaScreen *screen,
|
||||
const PangoFontDescription *desc,
|
||||
PangoDirection direction);
|
||||
MetaScreen* meta_screen_for_x_screen (Screen *xscreen);
|
||||
void meta_screen_foreach_window (MetaScreen *screen,
|
||||
MetaScreenWindowFunc func,
|
||||
gpointer data);
|
||||
void meta_screen_queue_frame_redraws (MetaScreen *screen);
|
||||
void meta_screen_show_tip (MetaScreen *screen,
|
||||
int root_x,
|
||||
int root_y,
|
||||
const char *markup);
|
||||
void meta_screen_hide_tip (MetaScreen *screen);
|
||||
|
||||
int meta_screen_get_n_workspaces (MetaScreen *screen);
|
||||
|
||||
|
12
src/ui.c
12
src/ui.c
@ -21,6 +21,7 @@
|
||||
|
||||
#include "ui.h"
|
||||
#include "frames.h"
|
||||
#include "util.h"
|
||||
|
||||
struct _MetaUI
|
||||
{
|
||||
@ -32,7 +33,8 @@ struct _MetaUI
|
||||
void
|
||||
meta_ui_init (int *argc, char ***argv)
|
||||
{
|
||||
gtk_init (argc, argv);
|
||||
if (!gtk_init_check (argc, argv))
|
||||
meta_fatal ("Unable to open X display %s\n", gdk_display_name);
|
||||
}
|
||||
|
||||
MetaUI*
|
||||
@ -93,14 +95,6 @@ meta_ui_reset_frame_bg (MetaUI *ui,
|
||||
meta_frames_reset_bg (ui->frames, xwindow);
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_set_frame_flags (MetaUI *ui,
|
||||
Window xwindow,
|
||||
MetaFrameFlags flags)
|
||||
{
|
||||
meta_frames_set_flags (ui->frames, xwindow, flags);
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_queue_frame_draw (MetaUI *ui,
|
||||
Window xwindow)
|
||||
|
6
src/ui.h
6
src/ui.h
@ -23,7 +23,7 @@
|
||||
#define META_UI_H
|
||||
|
||||
/* Don't include gtk.h here */
|
||||
#include "window.h"
|
||||
#include "common.h"
|
||||
|
||||
typedef struct _MetaUI MetaUI;
|
||||
|
||||
@ -46,10 +46,6 @@ void meta_ui_remove_frame (MetaUI *ui,
|
||||
void meta_ui_reset_frame_bg (MetaUI *ui,
|
||||
Window xwindow);
|
||||
|
||||
void meta_ui_set_frame_flags (MetaUI *ui,
|
||||
Window xwindow,
|
||||
MetaFrameFlags flags);
|
||||
|
||||
void meta_ui_queue_frame_draw (MetaUI *ui,
|
||||
Window xwindow);
|
||||
|
||||
|
12
src/util.h
12
src/util.h
@ -24,16 +24,6 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
typedef struct _MetaRectangle MetaRectangle;
|
||||
|
||||
struct _MetaRectangle
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
gboolean meta_is_verbose (void);
|
||||
void meta_set_verbose (gboolean setting);
|
||||
gboolean meta_is_debugging (void);
|
||||
@ -61,3 +51,5 @@ void meta_pop_no_msg_prefix (void);
|
||||
#define _(x) x
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -903,7 +903,6 @@ meta_window_move_resize_internal (MetaWindow *window,
|
||||
window->frame->child_y = fgeom.top_height;
|
||||
window->frame->right_width = fgeom.right_width;
|
||||
window->frame->bottom_height = fgeom.bottom_height;
|
||||
window->frame->bg_pixel = fgeom.background_pixel;
|
||||
}
|
||||
|
||||
/* See ICCCM 4.1.5 for when to send ConfigureNotify */
|
||||
|
Loading…
Reference in New Issue
Block a user