mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
...
This commit is contained in:
parent
4ae250ae97
commit
c506b48624
@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
PangoContext*
|
PangoContext*
|
||||||
meta_get_pango_context (Screen *xscreen,
|
meta_get_pango_context (Screen *xscreen,
|
||||||
const PangoFontDescription *desc,
|
const PangoFontDescription *desc)
|
||||||
Window frame)
|
|
||||||
{
|
{
|
||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@ struct _MetaUIColors
|
|||||||
};
|
};
|
||||||
|
|
||||||
PangoContext* meta_get_pango_context (Screen *xscreen,
|
PangoContext* meta_get_pango_context (Screen *xscreen,
|
||||||
const PangoFontDescription *desc,
|
const PangoFontDescription *desc);
|
||||||
Window frame);
|
|
||||||
gulong meta_get_x_pixel (Screen *xscreen,
|
gulong meta_get_x_pixel (Screen *xscreen,
|
||||||
const PangoColor *color);
|
const PangoColor *color);
|
||||||
|
|
||||||
|
@ -191,6 +191,8 @@ meta_display_close (MetaDisplay *display)
|
|||||||
/* If the next node doesn't contain this window
|
/* If the next node doesn't contain this window
|
||||||
* a second time, delete the window.
|
* a second time, delete the window.
|
||||||
*/
|
*/
|
||||||
|
g_assert (tmp->data != NULL);
|
||||||
|
|
||||||
if (tmp->next == NULL ||
|
if (tmp->next == NULL ||
|
||||||
(tmp->next && tmp->next->data != tmp->data))
|
(tmp->next && tmp->next->data != tmp->data))
|
||||||
meta_window_free (tmp->data);
|
meta_window_free (tmp->data);
|
||||||
|
130
src/frame.c
130
src/frame.c
@ -28,8 +28,14 @@ static void
|
|||||||
meta_frame_init_info (MetaFrame *frame,
|
meta_frame_init_info (MetaFrame *frame,
|
||||||
MetaFrameInfo *info)
|
MetaFrameInfo *info)
|
||||||
{
|
{
|
||||||
info->flags = 0;
|
info->flags =
|
||||||
info->frame = frame->xwindow;
|
META_FRAME_ALLOWS_DELETE | META_FRAME_ALLOWS_MENU |
|
||||||
|
META_FRAME_ALLOWS_ICONIFY | META_FRAME_ALLOWS_MAXIMIZE |
|
||||||
|
META_FRAME_ALLOWS_RESIZE;
|
||||||
|
|
||||||
|
info->drawable = None;
|
||||||
|
info->xoffset = 0;
|
||||||
|
info->yoffset = 0;
|
||||||
info->display = frame->window->display->xdisplay;
|
info->display = frame->window->display->xdisplay;
|
||||||
info->screen = frame->window->screen->xscreen;
|
info->screen = frame->window->screen->xscreen;
|
||||||
info->visual = frame->window->xvisual;
|
info->visual = frame->window->xvisual;
|
||||||
@ -136,9 +142,35 @@ meta_frame_calc_geometry (MetaFrame *frame,
|
|||||||
frame->rect.width = frame->rect.width + geom.left_width + geom.right_width;
|
frame->rect.width = frame->rect.width + geom.left_width + geom.right_width;
|
||||||
frame->rect.height = frame->rect.height + geom.top_height + geom.bottom_height;
|
frame->rect.height = frame->rect.height + geom.top_height + geom.bottom_height;
|
||||||
|
|
||||||
|
frame->bg_pixel = geom.background_pixel;
|
||||||
|
|
||||||
*geomp = geom;
|
*geomp = geom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_background_none (MetaFrame *frame)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
|
||||||
|
attrs.background_pixmap = None;
|
||||||
|
XChangeWindowAttributes (frame->window->display->xdisplay,
|
||||||
|
frame->xwindow,
|
||||||
|
CWBackPixmap,
|
||||||
|
&attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_background_color (MetaFrame *frame)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
|
||||||
|
attrs.background_pixel = None;
|
||||||
|
XChangeWindowAttributes (frame->window->display->xdisplay,
|
||||||
|
frame->xwindow,
|
||||||
|
CWBackPixel,
|
||||||
|
&attrs);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_ensure_frame (MetaWindow *window)
|
meta_window_ensure_frame (MetaWindow *window)
|
||||||
{
|
{
|
||||||
@ -176,7 +208,7 @@ meta_window_ensure_frame (MetaWindow *window)
|
|||||||
frame->child_x, frame->child_y,
|
frame->child_x, frame->child_y,
|
||||||
window->size_hints.win_gravity);
|
window->size_hints.win_gravity);
|
||||||
|
|
||||||
attrs.background_pixel = geom.background_pixel;
|
attrs.background_pixel = frame->bg_pixel;
|
||||||
attrs.event_mask =
|
attrs.event_mask =
|
||||||
StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
|
StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
|
||||||
ButtonPressMask | ButtonReleaseMask | OwnerGrabButtonMask |
|
ButtonPressMask | ButtonReleaseMask | OwnerGrabButtonMask |
|
||||||
@ -309,12 +341,14 @@ meta_frame_child_configure_request (MetaFrame *frame)
|
|||||||
frame->window->size_hints.x,
|
frame->window->size_hints.x,
|
||||||
frame->window->size_hints.y);
|
frame->window->size_hints.y);
|
||||||
|
|
||||||
|
set_background_none (frame);
|
||||||
XMoveResizeWindow (frame->window->display->xdisplay,
|
XMoveResizeWindow (frame->window->display->xdisplay,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
frame->rect.x,
|
frame->rect.x,
|
||||||
frame->rect.y,
|
frame->rect.y,
|
||||||
frame->rect.width,
|
frame->rect.width,
|
||||||
frame->rect.height);
|
frame->rect.height);
|
||||||
|
set_background_color (frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -322,7 +356,6 @@ meta_frame_recalc_now (MetaFrame *frame)
|
|||||||
{
|
{
|
||||||
int old_child_x, old_child_y;
|
int old_child_x, old_child_y;
|
||||||
MetaFrameGeometry geom;
|
MetaFrameGeometry geom;
|
||||||
XSetWindowAttributes attrs;
|
|
||||||
|
|
||||||
old_child_x = frame->child_x;
|
old_child_x = frame->child_x;
|
||||||
old_child_y = frame->child_y;
|
old_child_y = frame->child_y;
|
||||||
@ -341,18 +374,14 @@ meta_frame_recalc_now (MetaFrame *frame)
|
|||||||
if (old_child_y != frame->child_y)
|
if (old_child_y != frame->child_y)
|
||||||
frame->rect.y += (frame->child_y - old_child_y);
|
frame->rect.y += (frame->child_y - old_child_y);
|
||||||
|
|
||||||
|
set_background_none (frame);
|
||||||
XMoveResizeWindow (frame->window->display->xdisplay,
|
XMoveResizeWindow (frame->window->display->xdisplay,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
frame->rect.x,
|
frame->rect.x,
|
||||||
frame->rect.y,
|
frame->rect.y,
|
||||||
frame->rect.width,
|
frame->rect.width,
|
||||||
frame->rect.height);
|
frame->rect.height);
|
||||||
|
set_background_color (frame);
|
||||||
attrs.background_pixel = geom.background_pixel;
|
|
||||||
XChangeWindowAttributes (frame->window->display->xdisplay,
|
|
||||||
frame->xwindow,
|
|
||||||
CWBackPixel,
|
|
||||||
&attrs);
|
|
||||||
|
|
||||||
meta_verbose ("Frame of %s recalculated to %d,%d %d x %d child %d,%d\n",
|
meta_verbose ("Frame of %s recalculated to %d,%d %d x %d child %d,%d\n",
|
||||||
frame->window->desc, frame->rect.x, frame->rect.y,
|
frame->window->desc, frame->rect.x, frame->rect.y,
|
||||||
@ -363,15 +392,73 @@ meta_frame_recalc_now (MetaFrame *frame)
|
|||||||
void
|
void
|
||||||
meta_frame_queue_recalc (MetaFrame *frame)
|
meta_frame_queue_recalc (MetaFrame *frame)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* FIXME, actually queue */
|
||||||
meta_frame_recalc_now (frame);
|
meta_frame_recalc_now (frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_frame_draw_now (MetaFrame *frame,
|
||||||
|
int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
MetaFrameInfo info;
|
||||||
|
Pixmap p;
|
||||||
|
XGCValues vals;
|
||||||
|
|
||||||
|
if (frame->xwindow == None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
meta_frame_init_info (frame, &info);
|
||||||
|
|
||||||
|
if (width < 0)
|
||||||
|
width = frame->rect.width;
|
||||||
|
|
||||||
|
if (height < 0)
|
||||||
|
height = frame->rect.height;
|
||||||
|
|
||||||
|
if (width == 0 || height == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
p = XCreatePixmap (frame->window->display->xdisplay,
|
||||||
|
frame->xwindow,
|
||||||
|
width, height,
|
||||||
|
frame->window->screen->visual_info.depth);
|
||||||
|
|
||||||
|
vals.foreground = frame->bg_pixel;
|
||||||
|
XChangeGC (frame->window->display->xdisplay,
|
||||||
|
frame->window->screen->scratch_gc,
|
||||||
|
GCForeground,
|
||||||
|
&vals);
|
||||||
|
|
||||||
|
XFillRectangle (frame->window->display->xdisplay,
|
||||||
|
p,
|
||||||
|
frame->window->screen->scratch_gc,
|
||||||
|
0, 0,
|
||||||
|
width, height);
|
||||||
|
|
||||||
|
info.drawable = p;
|
||||||
|
info.xoffset = - x;
|
||||||
|
info.yoffset = - y;
|
||||||
|
frame->window->screen->engine->expose_frame (&info,
|
||||||
|
0, 0, width, height,
|
||||||
|
frame->theme_data);
|
||||||
|
|
||||||
|
|
||||||
|
XCopyArea (frame->window->display->xdisplay,
|
||||||
|
p, frame->xwindow,
|
||||||
|
frame->window->screen->scratch_gc,
|
||||||
|
0, 0,
|
||||||
|
width, height,
|
||||||
|
x, y);
|
||||||
|
|
||||||
|
XFreePixmap (frame->window->display->xdisplay,
|
||||||
|
p);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_frame_queue_draw (MetaFrame *frame)
|
meta_frame_queue_draw (MetaFrame *frame)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* FIXME, actually queue */
|
||||||
|
meta_frame_draw_now (frame, 0, 0, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -523,10 +610,12 @@ meta_frame_event (MetaFrame *frame,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case META_FRAME_ACTION_NONE:
|
case META_FRAME_ACTION_NONE:
|
||||||
|
#if 0
|
||||||
meta_ui_slave_show_tip (frame->window->screen->uislave,
|
meta_ui_slave_show_tip (frame->window->screen->uislave,
|
||||||
frame->rect.x,
|
frame->rect.x,
|
||||||
frame->rect.y,
|
frame->rect.y,
|
||||||
"Hi this is a tooltip");
|
"Hi this is a tooltip");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -543,16 +632,11 @@ meta_frame_event (MetaFrame *frame,
|
|||||||
case KeymapNotify:
|
case KeymapNotify:
|
||||||
break;
|
break;
|
||||||
case Expose:
|
case Expose:
|
||||||
{
|
meta_frame_draw_now (frame,
|
||||||
MetaFrameInfo info;
|
event->xexpose.x,
|
||||||
meta_frame_init_info (frame, &info);
|
event->xexpose.y,
|
||||||
frame->window->screen->engine->expose_frame (&info,
|
event->xexpose.width,
|
||||||
event->xexpose.x,
|
event->xexpose.height);
|
||||||
event->xexpose.y,
|
|
||||||
event->xexpose.width,
|
|
||||||
event->xexpose.height,
|
|
||||||
frame->theme_data);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GraphicsExpose:
|
case GraphicsExpose:
|
||||||
break;
|
break;
|
||||||
|
@ -39,7 +39,7 @@ struct _MetaFrame
|
|||||||
/* reparent window */
|
/* reparent window */
|
||||||
Window xwindow;
|
Window xwindow;
|
||||||
|
|
||||||
/* This is trusted info from where we put the
|
/* This rect is trusted info from where we put the
|
||||||
* frame, not the result of ConfigureNotify
|
* frame, not the result of ConfigureNotify
|
||||||
*/
|
*/
|
||||||
MetaRectangle rect;
|
MetaRectangle rect;
|
||||||
@ -47,6 +47,7 @@ struct _MetaFrame
|
|||||||
int child_y;
|
int child_y;
|
||||||
|
|
||||||
gpointer theme_data;
|
gpointer theme_data;
|
||||||
|
gulong bg_pixel;
|
||||||
|
|
||||||
MetaFrameAction action;
|
MetaFrameAction action;
|
||||||
/* reference point for drags */
|
/* reference point for drags */
|
||||||
|
10
src/screen.c
10
src/screen.c
@ -46,6 +46,7 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
Window xroot;
|
Window xroot;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
XGCValues vals;
|
||||||
|
|
||||||
/* Only display->name, display->xdisplay, and display->error_traps
|
/* Only display->name, display->xdisplay, and display->error_traps
|
||||||
* can really be used in this function, since normally screens are
|
* can really be used in this function, since normally screens are
|
||||||
@ -102,6 +103,11 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
meta_screen_init_visual_info (screen);
|
meta_screen_init_visual_info (screen);
|
||||||
meta_screen_init_ui_colors (screen);
|
meta_screen_init_ui_colors (screen);
|
||||||
|
|
||||||
|
screen->scratch_gc = XCreateGC (screen->display->xdisplay,
|
||||||
|
screen->xroot,
|
||||||
|
0,
|
||||||
|
&vals);
|
||||||
|
|
||||||
screen->uislave = meta_ui_slave_new (screen->screen_name,
|
screen->uislave = meta_ui_slave_new (screen->screen_name,
|
||||||
ui_slave_func,
|
ui_slave_func,
|
||||||
screen);
|
screen);
|
||||||
@ -116,6 +122,10 @@ void
|
|||||||
meta_screen_free (MetaScreen *screen)
|
meta_screen_free (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
meta_ui_slave_free (screen->uislave);
|
meta_ui_slave_free (screen->uislave);
|
||||||
|
|
||||||
|
XFreeGC (screen->display->xdisplay,
|
||||||
|
screen->scratch_gc);
|
||||||
|
|
||||||
if (screen->pango_context)
|
if (screen->pango_context)
|
||||||
g_object_unref (G_OBJECT (screen->pango_context));
|
g_object_unref (G_OBJECT (screen->pango_context));
|
||||||
g_free (screen->screen_name);
|
g_free (screen->screen_name);
|
||||||
|
@ -42,6 +42,11 @@ struct _MetaScreen
|
|||||||
XVisualInfo visual_info;
|
XVisualInfo visual_info;
|
||||||
MetaUIColors colors;
|
MetaUIColors colors;
|
||||||
|
|
||||||
|
/* In screen's visual, no guarantees about colors, shouldn't be
|
||||||
|
* left with a clip.
|
||||||
|
*/
|
||||||
|
GC scratch_gc;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
|
|
||||||
/* we only need one since we only draw to a single visual (that of
|
/* we only need one since we only draw to a single visual (that of
|
||||||
|
435
src/theme.c
435
src/theme.c
@ -21,14 +21,32 @@
|
|||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
typedef struct _DefaultFrameData DefaultFrameData;
|
typedef struct _DefaultFrameData DefaultFrameData;
|
||||||
typedef struct _DefaultScreenData DefaultScreenData;
|
typedef struct _DefaultScreenData DefaultScreenData;
|
||||||
|
typedef struct _DefaultFrameGeometry DefaultFrameGeometry;
|
||||||
|
|
||||||
|
struct _DefaultFrameGeometry
|
||||||
|
{
|
||||||
|
/* We recalculate this every time, to save RAM */
|
||||||
|
int left_width;
|
||||||
|
int right_width;
|
||||||
|
int top_height;
|
||||||
|
int bottom_height;
|
||||||
|
|
||||||
|
MetaRectangle close_rect;
|
||||||
|
MetaRectangle max_rect;
|
||||||
|
MetaRectangle min_rect;
|
||||||
|
MetaRectangle spacer_rect;
|
||||||
|
MetaRectangle menu_rect;
|
||||||
|
MetaRectangle title_rect;
|
||||||
|
};
|
||||||
|
|
||||||
struct _DefaultFrameData
|
struct _DefaultFrameData
|
||||||
{
|
{
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
int title_height;
|
int layout_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _DefaultScreenData
|
struct _DefaultScreenData
|
||||||
@ -84,13 +102,12 @@ default_acquire_frame (MetaFrameInfo *info)
|
|||||||
|
|
||||||
d = g_new (DefaultFrameData, 1);
|
d = g_new (DefaultFrameData, 1);
|
||||||
|
|
||||||
desc = pango_font_description_from_string ("Sans 16");
|
desc = pango_font_description_from_string ("Sans 12");
|
||||||
d->layout = pango_layout_new (meta_get_pango_context (info->screen,
|
d->layout = pango_layout_new (meta_get_pango_context (info->screen,
|
||||||
desc,
|
desc));
|
||||||
info->frame));
|
|
||||||
pango_font_description_free (desc);
|
pango_font_description_free (desc);
|
||||||
|
|
||||||
d->title_height = 0;
|
d->layout_height = 0;
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@ -109,11 +126,140 @@ default_release_frame (MetaFrameInfo *info,
|
|||||||
g_free (d);
|
g_free (d);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VERTICAL_TEXT_PAD 3
|
#define VERTICAL_TITLE_PAD 2
|
||||||
#define LEFT_WIDTH 15
|
#define HORIZONTAL_TITLE_PAD 3
|
||||||
#define RIGHT_WIDTH 15
|
#define VERTICAL_TEXT_PAD 2
|
||||||
#define BOTTOM_HEIGHT 20
|
#define HORIZONTAL_TEXT_PAD 2
|
||||||
|
#define LEFT_WIDTH 2
|
||||||
|
#define RIGHT_WIDTH 2
|
||||||
|
#define BOTTOM_HEIGHT 5
|
||||||
#define SPACER_SPACING 3
|
#define SPACER_SPACING 3
|
||||||
|
#define SPACER_WIDTH 2
|
||||||
|
#define SPACER_HEIGHT 10
|
||||||
|
#define BUTTON_WIDTH 12
|
||||||
|
#define BUTTON_HEIGHT 12
|
||||||
|
#define BUTTON_PAD 2
|
||||||
|
#define INNER_BUTTON_PAD 1
|
||||||
|
static void
|
||||||
|
calc_geometry (MetaFrameInfo *info,
|
||||||
|
DefaultFrameData *d,
|
||||||
|
DefaultFrameGeometry *fgeom)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int button_y;
|
||||||
|
int title_right_edge;
|
||||||
|
|
||||||
|
fgeom->top_height = MAX (d->layout_height + VERTICAL_TITLE_PAD * 2 + VERTICAL_TEXT_PAD * 2,
|
||||||
|
BUTTON_HEIGHT + BUTTON_PAD * 2);
|
||||||
|
|
||||||
|
fgeom->left_width = LEFT_WIDTH;
|
||||||
|
fgeom->right_width = RIGHT_WIDTH;
|
||||||
|
fgeom->bottom_height = BOTTOM_HEIGHT;
|
||||||
|
|
||||||
|
x = info->width - fgeom->right_width;
|
||||||
|
button_y = (fgeom->top_height - BUTTON_HEIGHT) / 2;
|
||||||
|
|
||||||
|
if (info->flags & META_FRAME_ALLOWS_DELETE)
|
||||||
|
{
|
||||||
|
fgeom->close_rect.x = x - BUTTON_PAD - BUTTON_WIDTH;
|
||||||
|
fgeom->close_rect.y = button_y;
|
||||||
|
fgeom->close_rect.width = BUTTON_WIDTH;
|
||||||
|
fgeom->close_rect.height = BUTTON_HEIGHT;
|
||||||
|
|
||||||
|
x = fgeom->close_rect.x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgeom->close_rect.x = 0;
|
||||||
|
fgeom->close_rect.y = 0;
|
||||||
|
fgeom->close_rect.width = 0;
|
||||||
|
fgeom->close_rect.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->flags & META_FRAME_ALLOWS_MAXIMIZE)
|
||||||
|
{
|
||||||
|
fgeom->max_rect.x = x - BUTTON_PAD - BUTTON_WIDTH;
|
||||||
|
fgeom->max_rect.y = button_y;
|
||||||
|
fgeom->max_rect.width = BUTTON_WIDTH;
|
||||||
|
fgeom->max_rect.height = BUTTON_HEIGHT;
|
||||||
|
|
||||||
|
x = fgeom->max_rect.x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgeom->max_rect.x = 0;
|
||||||
|
fgeom->max_rect.y = 0;
|
||||||
|
fgeom->max_rect.width = 0;
|
||||||
|
fgeom->max_rect.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->flags & META_FRAME_ALLOWS_ICONIFY)
|
||||||
|
{
|
||||||
|
fgeom->min_rect.x = x - BUTTON_PAD - BUTTON_WIDTH;
|
||||||
|
fgeom->min_rect.y = button_y;
|
||||||
|
fgeom->min_rect.width = BUTTON_WIDTH;
|
||||||
|
fgeom->min_rect.height = BUTTON_HEIGHT;
|
||||||
|
|
||||||
|
x = fgeom->min_rect.x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgeom->min_rect.x = 0;
|
||||||
|
fgeom->min_rect.y = 0;
|
||||||
|
fgeom->min_rect.width = 0;
|
||||||
|
fgeom->min_rect.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgeom->close_rect.width > 0 ||
|
||||||
|
fgeom->max_rect.width > 0 ||
|
||||||
|
fgeom->min_rect.width > 0)
|
||||||
|
{
|
||||||
|
fgeom->spacer_rect.x = x - SPACER_SPACING - SPACER_WIDTH;
|
||||||
|
fgeom->spacer_rect.y = (fgeom->top_height - SPACER_HEIGHT) / 2;
|
||||||
|
fgeom->spacer_rect.width = SPACER_WIDTH;
|
||||||
|
fgeom->spacer_rect.height = SPACER_HEIGHT;
|
||||||
|
|
||||||
|
x = fgeom->spacer_rect.x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgeom->spacer_rect.x = 0;
|
||||||
|
fgeom->spacer_rect.y = 0;
|
||||||
|
fgeom->spacer_rect.width = 0;
|
||||||
|
fgeom->spacer_rect.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
title_right_edge = x - HORIZONTAL_TITLE_PAD;
|
||||||
|
|
||||||
|
/* Now x changes to be position from the left */
|
||||||
|
x = fgeom->left_width;
|
||||||
|
|
||||||
|
if (info->flags & META_FRAME_ALLOWS_MENU)
|
||||||
|
{
|
||||||
|
fgeom->menu_rect.x = x + BUTTON_PAD;
|
||||||
|
fgeom->menu_rect.y = button_y;
|
||||||
|
fgeom->menu_rect.width = BUTTON_WIDTH;
|
||||||
|
fgeom->menu_rect.height = BUTTON_HEIGHT;
|
||||||
|
|
||||||
|
x = fgeom->menu_rect.x + fgeom->menu_rect.width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgeom->menu_rect.x = 0;
|
||||||
|
fgeom->menu_rect.y = 0;
|
||||||
|
fgeom->menu_rect.width = 0;
|
||||||
|
fgeom->menu_rect.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fgeom->title_rect.x = x + BUTTON_PAD;
|
||||||
|
fgeom->title_rect.y = VERTICAL_TITLE_PAD;
|
||||||
|
fgeom->title_rect.width = title_right_edge - fgeom->title_rect.x;
|
||||||
|
fgeom->title_rect.height = fgeom->top_height - VERTICAL_TITLE_PAD * 2;
|
||||||
|
|
||||||
|
if (fgeom->title_rect.width < 0)
|
||||||
|
fgeom->title_rect.width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_fill_frame_geometry (MetaFrameInfo *info,
|
default_fill_frame_geometry (MetaFrameInfo *info,
|
||||||
MetaFrameGeometry *geom,
|
MetaFrameGeometry *geom,
|
||||||
@ -121,6 +267,7 @@ default_fill_frame_geometry (MetaFrameInfo *info,
|
|||||||
{
|
{
|
||||||
DefaultFrameData *d;
|
DefaultFrameData *d;
|
||||||
PangoRectangle rect;
|
PangoRectangle rect;
|
||||||
|
DefaultFrameGeometry fgeom;
|
||||||
|
|
||||||
d = frame_data;
|
d = frame_data;
|
||||||
|
|
||||||
@ -131,12 +278,13 @@ default_fill_frame_geometry (MetaFrameInfo *info,
|
|||||||
|
|
||||||
pango_layout_get_pixel_extents (d->layout, NULL, &rect);
|
pango_layout_get_pixel_extents (d->layout, NULL, &rect);
|
||||||
|
|
||||||
d->title_height = rect.height + VERTICAL_TEXT_PAD * 2;
|
d->layout_height = rect.height;
|
||||||
geom->top_height = d->title_height;
|
|
||||||
|
|
||||||
geom->left_width = LEFT_WIDTH;
|
calc_geometry (info, d, &fgeom);
|
||||||
geom->right_width = RIGHT_WIDTH;
|
geom->top_height = fgeom.top_height;
|
||||||
geom->bottom_height = BOTTOM_HEIGHT;
|
geom->left_width = fgeom.left_width;
|
||||||
|
geom->right_width = fgeom.right_width;
|
||||||
|
geom->bottom_height = fgeom.bottom_height;
|
||||||
|
|
||||||
geom->background_pixel = meta_get_x_pixel (info->screen,
|
geom->background_pixel = meta_get_x_pixel (info->screen,
|
||||||
&info->colors->bg[META_STATE_NORMAL]);
|
&info->colors->bg[META_STATE_NORMAL]);
|
||||||
@ -151,6 +299,7 @@ draw_vline (MetaFrameInfo *info,
|
|||||||
int y2,
|
int y2,
|
||||||
int x)
|
int x)
|
||||||
{
|
{
|
||||||
|
/* From GTK+ */
|
||||||
int thickness_light;
|
int thickness_light;
|
||||||
int thickness_dark;
|
int thickness_dark;
|
||||||
int i;
|
int i;
|
||||||
@ -176,6 +325,76 @@ draw_vline (MetaFrameInfo *info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
draw_varrow (MetaFrameInfo *info,
|
||||||
|
Drawable drawable,
|
||||||
|
GC gc,
|
||||||
|
gboolean down,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
gint steps, extra;
|
||||||
|
gint y_start, y_increment;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
/* From GTK+ */
|
||||||
|
|
||||||
|
width = width + width % 2 - 1; /* Force odd */
|
||||||
|
|
||||||
|
steps = 1 + width / 2;
|
||||||
|
|
||||||
|
extra = height - steps;
|
||||||
|
|
||||||
|
if (down)
|
||||||
|
{
|
||||||
|
y_start = y;
|
||||||
|
y_increment = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y_start = y + height - 1;
|
||||||
|
y_increment = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < extra; i++)
|
||||||
|
{
|
||||||
|
XDrawLine (info->display, drawable,
|
||||||
|
gc,
|
||||||
|
x, y_start + i * y_increment,
|
||||||
|
x + width - 1, y_start + i * y_increment);
|
||||||
|
}
|
||||||
|
for (; i < height; i++)
|
||||||
|
{
|
||||||
|
XDrawLine (info->display, drawable,
|
||||||
|
gc,
|
||||||
|
x + (i - extra), y_start + i * y_increment,
|
||||||
|
x + width - (i - extra) - 1, y_start + i * y_increment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_clip (Display *display, GC gc, MetaRectangle *rect)
|
||||||
|
{
|
||||||
|
if (rect)
|
||||||
|
{
|
||||||
|
XRectangle xrect;
|
||||||
|
|
||||||
|
xrect.x = rect->x;
|
||||||
|
xrect.y = rect->y;
|
||||||
|
xrect.width = rect->width;
|
||||||
|
xrect.height = rect->height;
|
||||||
|
|
||||||
|
XSetClipRectangles (display, gc, 0, 0,
|
||||||
|
&xrect, 1, YXBanded);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XSetClipMask (display, gc, None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_expose_frame (MetaFrameInfo *info,
|
default_expose_frame (MetaFrameInfo *info,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
@ -183,56 +402,150 @@ default_expose_frame (MetaFrameInfo *info,
|
|||||||
gpointer frame_data)
|
gpointer frame_data)
|
||||||
{
|
{
|
||||||
DefaultFrameData *d;
|
DefaultFrameData *d;
|
||||||
int close_size;
|
|
||||||
XGCValues vals;
|
XGCValues vals;
|
||||||
|
int xoff, yoff;
|
||||||
|
DefaultFrameGeometry fgeom;
|
||||||
|
|
||||||
d = frame_data;
|
d = frame_data;
|
||||||
|
|
||||||
pango_x_render_layout (info->display,
|
calc_geometry (info, d, &fgeom);
|
||||||
info->frame,
|
|
||||||
screen_data->text_gc,
|
|
||||||
d->layout,
|
|
||||||
LEFT_WIDTH,
|
|
||||||
VERTICAL_TEXT_PAD);
|
|
||||||
|
|
||||||
close_size = d->title_height;
|
xoff = info->xoffset;
|
||||||
|
yoff = info->yoffset;
|
||||||
|
|
||||||
vals.line_width = 2;
|
if (fgeom.title_rect.width > 0 && fgeom.title_rect.height > 0)
|
||||||
XChangeGC (info->display,
|
{
|
||||||
screen_data->fg_gc,
|
int layout_y;
|
||||||
GCLineWidth,
|
MetaRectangle clip;
|
||||||
&vals);
|
|
||||||
|
|
||||||
XDrawLine (info->display,
|
/* center vertically */
|
||||||
info->frame,
|
layout_y = fgeom.title_rect.y +
|
||||||
screen_data->fg_gc,
|
(fgeom.title_rect.height - d->layout_height) / 2;
|
||||||
info->width - RIGHT_WIDTH - close_size,
|
|
||||||
VERTICAL_TEXT_PAD,
|
|
||||||
info->width - RIGHT_WIDTH,
|
|
||||||
d->title_height - VERTICAL_TEXT_PAD);
|
|
||||||
|
|
||||||
XDrawLine (info->display,
|
clip = fgeom.title_rect;
|
||||||
info->frame,
|
clip.x += xoff;
|
||||||
screen_data->fg_gc,
|
clip.y += yoff;
|
||||||
info->width - RIGHT_WIDTH,
|
clip.width -= HORIZONTAL_TEXT_PAD;
|
||||||
VERTICAL_TEXT_PAD,
|
|
||||||
info->width - RIGHT_WIDTH - close_size,
|
|
||||||
d->title_height - VERTICAL_TEXT_PAD);
|
|
||||||
|
|
||||||
vals.line_width = 0;
|
set_clip (info->display, screen_data->text_gc, &clip);
|
||||||
XChangeGC (info->display,
|
if (info->flags & META_FRAME_HAS_FOCUS)
|
||||||
screen_data->fg_gc,
|
{
|
||||||
GCLineWidth,
|
/* FIXME use STATE_SELECTED */
|
||||||
&vals);
|
|
||||||
|
|
||||||
draw_vline (info, info->frame,
|
}
|
||||||
screen_data->light_gc,
|
|
||||||
screen_data->dark_gc,
|
pango_x_render_layout (info->display,
|
||||||
VERTICAL_TEXT_PAD,
|
info->drawable,
|
||||||
d->title_height - VERTICAL_TEXT_PAD,
|
screen_data->text_gc,
|
||||||
info->width - RIGHT_WIDTH - close_size - SPACER_SPACING);
|
d->layout,
|
||||||
|
xoff + fgeom.title_rect.x + HORIZONTAL_TEXT_PAD,
|
||||||
|
yoff + layout_y);
|
||||||
|
set_clip (info->display, screen_data->text_gc, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgeom.close_rect.width > 0 && fgeom.close_rect.height > 0)
|
||||||
|
{
|
||||||
|
XDrawLine (info->display,
|
||||||
|
info->drawable,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
xoff + fgeom.close_rect.x + INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.close_rect.y + INNER_BUTTON_PAD,
|
||||||
|
xoff + fgeom.close_rect.x + fgeom.close_rect.width - INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.close_rect.y + fgeom.close_rect.height - INNER_BUTTON_PAD);
|
||||||
|
|
||||||
|
|
||||||
|
XDrawLine (info->display,
|
||||||
|
info->drawable,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
xoff + fgeom.close_rect.x + INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.close_rect.y + fgeom.close_rect.height - INNER_BUTTON_PAD,
|
||||||
|
xoff + fgeom.close_rect.x + fgeom.close_rect.width - INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.close_rect.y + INNER_BUTTON_PAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgeom.max_rect.width > 0 && fgeom.max_rect.height > 0)
|
||||||
|
{
|
||||||
|
XDrawRectangle (info->display,
|
||||||
|
info->drawable,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
xoff + fgeom.max_rect.x + INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.max_rect.y + INNER_BUTTON_PAD,
|
||||||
|
fgeom.max_rect.width - INNER_BUTTON_PAD * 2,
|
||||||
|
fgeom.max_rect.height - INNER_BUTTON_PAD * 2);
|
||||||
|
|
||||||
|
vals.line_width = 3;
|
||||||
|
XChangeGC (info->display,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
GCLineWidth,
|
||||||
|
&vals);
|
||||||
|
|
||||||
|
XDrawLine (info->display,
|
||||||
|
info->drawable,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
xoff + fgeom.max_rect.x + INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.max_rect.y + INNER_BUTTON_PAD + vals.line_width / 2,
|
||||||
|
xoff + fgeom.max_rect.x + fgeom.max_rect.width - INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.max_rect.y + INNER_BUTTON_PAD + vals.line_width / 2);
|
||||||
|
|
||||||
|
vals.line_width = 0;
|
||||||
|
XChangeGC (info->display,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
GCLineWidth,
|
||||||
|
&vals);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgeom.min_rect.width > 0 && fgeom.min_rect.height > 0)
|
||||||
|
{
|
||||||
|
vals.line_width = 3;
|
||||||
|
XChangeGC (info->display,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
GCLineWidth,
|
||||||
|
&vals);
|
||||||
|
|
||||||
|
XDrawLine (info->display,
|
||||||
|
info->drawable,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
xoff + fgeom.min_rect.x + INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.min_rect.y + fgeom.min_rect.height - INNER_BUTTON_PAD - vals.line_width / 2,
|
||||||
|
xoff + fgeom.min_rect.x + fgeom.min_rect.width - INNER_BUTTON_PAD,
|
||||||
|
yoff + fgeom.min_rect.y + fgeom.min_rect.height - INNER_BUTTON_PAD - vals.line_width / 2);
|
||||||
|
|
||||||
|
vals.line_width = 0;
|
||||||
|
XChangeGC (info->display,
|
||||||
|
screen_data->fg_gc,
|
||||||
|
GCLineWidth,
|
||||||
|
&vals);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgeom.spacer_rect.width > 0 && fgeom.spacer_rect.height > 0)
|
||||||
|
{
|
||||||
|
draw_vline (info, info->drawable,
|
||||||
|
screen_data->light_gc,
|
||||||
|
screen_data->dark_gc,
|
||||||
|
yoff + fgeom.spacer_rect.y,
|
||||||
|
yoff + fgeom.spacer_rect.y + fgeom.spacer_rect.height,
|
||||||
|
xoff + fgeom.spacer_rect.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
draw_varrow (info, info->drawable, screen_data->fg_gc, TRUE,
|
||||||
|
xoff + x, yoff + y, 7, 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define POINT_IN_RECT(xcoord, ycoord, rect) \
|
||||||
|
((xcoord) >= (rect).x && \
|
||||||
|
(xcoord) < ((rect).x + (rect).width) && \
|
||||||
|
(ycoord) >= (rect).y && \
|
||||||
|
(ycoord) < ((rect).y + (rect).height))
|
||||||
|
|
||||||
#define RESIZE_EXTENDS 10
|
#define RESIZE_EXTENDS 10
|
||||||
static MetaFrameControl
|
static MetaFrameControl
|
||||||
default_get_control (MetaFrameInfo *info,
|
default_get_control (MetaFrameInfo *info,
|
||||||
@ -240,20 +553,20 @@ default_get_control (MetaFrameInfo *info,
|
|||||||
gpointer frame_data)
|
gpointer frame_data)
|
||||||
{
|
{
|
||||||
DefaultFrameData *d;
|
DefaultFrameData *d;
|
||||||
int close_size;
|
DefaultFrameGeometry fgeom;
|
||||||
|
|
||||||
d = frame_data;
|
d = frame_data;
|
||||||
|
|
||||||
close_size = d->title_height;
|
calc_geometry (info, d, &fgeom);
|
||||||
if (y < d->title_height &&
|
|
||||||
x > info->width - RIGHT_WIDTH - close_size)
|
if (POINT_IN_RECT (x, y, fgeom.close_rect))
|
||||||
return META_FRAME_CONTROL_DELETE;
|
return META_FRAME_CONTROL_DELETE;
|
||||||
|
|
||||||
if (y < d->title_height)
|
if (POINT_IN_RECT (x, y, fgeom.title_rect))
|
||||||
return META_FRAME_CONTROL_TITLE;
|
return META_FRAME_CONTROL_TITLE;
|
||||||
|
|
||||||
if (y > (info->height - BOTTOM_HEIGHT - RESIZE_EXTENDS) &&
|
if (y > (info->height - fgeom.bottom_height - RESIZE_EXTENDS) &&
|
||||||
x > (info->width - RIGHT_WIDTH - RESIZE_EXTENDS))
|
x > (info->width - fgeom.right_width - RESIZE_EXTENDS))
|
||||||
return META_FRAME_CONTROL_RESIZE_SE;
|
return META_FRAME_CONTROL_RESIZE_SE;
|
||||||
|
|
||||||
return META_FRAME_CONTROL_NONE;
|
return META_FRAME_CONTROL_NONE;
|
||||||
|
@ -40,7 +40,8 @@ typedef enum
|
|||||||
META_FRAME_ALLOWS_ICONIFY = 1 << 2,
|
META_FRAME_ALLOWS_ICONIFY = 1 << 2,
|
||||||
META_FRAME_ALLOWS_MAXIMIZE = 1 << 3,
|
META_FRAME_ALLOWS_MAXIMIZE = 1 << 3,
|
||||||
META_FRAME_ALLOWS_RESIZE = 1 << 4,
|
META_FRAME_ALLOWS_RESIZE = 1 << 4,
|
||||||
META_FRAME_TRANSIENT = 1 << 5
|
META_FRAME_TRANSIENT = 1 << 5,
|
||||||
|
META_FRAME_HAS_FOCUS = 1 << 6
|
||||||
} MetaFrameFlags;
|
} MetaFrameFlags;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -65,7 +66,8 @@ struct _MetaFrameInfo
|
|||||||
{
|
{
|
||||||
/* These are read-only to engines */
|
/* These are read-only to engines */
|
||||||
MetaFrameFlags flags;
|
MetaFrameFlags flags;
|
||||||
Window frame; /* == None in fill_frame_geometry */
|
Window drawable; /* == None except in expose */
|
||||||
|
int xoffset, yoffset; /* add to frame coords to get drawable coords */
|
||||||
Display *display;
|
Display *display;
|
||||||
Screen *screen;
|
Screen *screen;
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
@ -94,7 +96,7 @@ struct _MetaFrameGeometry
|
|||||||
unsigned long background_pixel;
|
unsigned long background_pixel;
|
||||||
|
|
||||||
Pixmap shape_mask;
|
Pixmap shape_mask;
|
||||||
/* FIXME shape region */
|
/* FIXME shape region? */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MetaThemeEngine
|
struct _MetaThemeEngine
|
||||||
|
Loading…
Reference in New Issue
Block a user