Only consider the bottom of the titlebar a resize control; I keep

2002-01-27  Havoc Pennington  <hp@pobox.com>

	* src/frames.c (get_control): Only consider the bottom of the
	titlebar a resize control; I keep accidentally resizing windows
	instead of activating them. Also, give south resizing priority
	over north, if the window is so small the active regions overlap

	* src/theme.c: add MetaTheme, get MetaFrameStyleSet into
	a usable state

	* src/common.h: move window type back to window.h, decided
	not to use it on frame side
	(MetaFrameType): add this instead
This commit is contained in:
Havoc Pennington 2002-01-27 08:21:53 +00:00 committed by Havoc Pennington
parent 5b4e9c01cc
commit b52ee424e4
6 changed files with 138 additions and 67 deletions

View File

@ -1,3 +1,17 @@
2002-01-27 Havoc Pennington <hp@pobox.com>
* src/frames.c (get_control): Only consider the bottom of the
titlebar a resize control; I keep accidentally resizing windows
instead of activating them. Also, give south resizing priority
over north, if the window is so small the active regions overlap
* src/theme.c: add MetaTheme, get MetaFrameStyleSet into
a usable state
* src/common.h: move window type back to window.h, decided
not to use it on frame side
(MetaFrameType): add this instead
2002-01-27 Havoc Pennington <hp@pobox.com>
* src/theme.h, src/theme.c: implement all kinds of crazy

View File

@ -121,7 +121,6 @@ typedef enum
} MetaCursor;
typedef enum
{
META_FOCUS_MODE_CLICK,
@ -131,16 +130,14 @@ typedef enum
typedef enum
{
META_WINDOW_NORMAL,
META_WINDOW_DESKTOP,
META_WINDOW_DOCK,
META_WINDOW_DIALOG,
META_WINDOW_MODAL_DIALOG,
META_WINDOW_TOOLBAR,
META_WINDOW_MENU,
META_WINDOW_TYPE_LAST
} MetaWindowType;
META_FRAME_TYPE_NORMAL,
META_FRAME_TYPE_DIALOG,
META_FRAME_TYPE_MODAL_DIALOG,
META_FRAME_TYPE_UTILITY,
META_FRAME_TYPE_MENU,
META_FRAME_TYPE_TOOLBAR,
META_FRAME_TYPE_LAST
} MetaFrameType;
/* should investigate changing these to whatever most apps use */
#define META_ICON_WIDTH 32

View File

@ -2101,28 +2101,19 @@ get_control (MetaFrames *frames,
if (has_vert || has_horiz)
{
if (y < fgeom.top_height && x < RESIZE_EXTENDS)
{
if (has_vert && has_horiz)
return META_FRAME_CONTROL_RESIZE_NW;
else if (has_vert)
return META_FRAME_CONTROL_RESIZE_N;
else
return META_FRAME_CONTROL_RESIZE_W;
int bottom_of_titlebar;
}
else if (y < fgeom.top_height && x >= (fgeom.width - RESIZE_EXTENDS))
{
if (has_vert && has_horiz)
return META_FRAME_CONTROL_RESIZE_NE;
else if (has_vert)
return META_FRAME_CONTROL_RESIZE_N;
else
return META_FRAME_CONTROL_RESIZE_E;
bottom_of_titlebar = fgeom.title_rect.y + fgeom.title_rect.height;
}
else if (y >= (fgeom.height - fgeom.bottom_height - RESIZE_EXTENDS) &&
x >= (fgeom.width - fgeom.right_width - RESIZE_EXTENDS))
if (y < bottom_of_titlebar)
goto noresize;
/* South resize always has priority over north resize,
* in case of overlap.
*/
if (y >= (fgeom.height - fgeom.bottom_height - RESIZE_EXTENDS) &&
x >= (fgeom.width - fgeom.right_width - RESIZE_EXTENDS))
{
if (has_vert && has_horiz)
return META_FRAME_CONTROL_RESIZE_SE;
@ -2141,16 +2132,36 @@ get_control (MetaFrames *frames,
else
return META_FRAME_CONTROL_RESIZE_W;
}
else if (y < fgeom.top_height)
else if (y < (fgeom.top_height + RESIZE_EXTENDS) &&
x < RESIZE_EXTENDS)
{
if (has_vert)
if (has_vert && has_horiz)
return META_FRAME_CONTROL_RESIZE_NW;
else if (has_vert)
return META_FRAME_CONTROL_RESIZE_N;
else
return META_FRAME_CONTROL_RESIZE_W;
}
else if (y < (fgeom.top_height + RESIZE_EXTENDS) &&
x >= (fgeom.width - RESIZE_EXTENDS))
{
if (has_vert && has_horiz)
return META_FRAME_CONTROL_RESIZE_NE;
else if (has_vert)
return META_FRAME_CONTROL_RESIZE_N;
else
return META_FRAME_CONTROL_RESIZE_E;
}
else if (y >= (fgeom.height - fgeom.bottom_height - RESIZE_EXTENDS))
{
if (has_vert)
return META_FRAME_CONTROL_RESIZE_S;
}
else if (y >= bottom_of_titlebar && y < fgeom.top_height)
{
if (has_vert)
return META_FRAME_CONTROL_RESIZE_N;
}
else if (x <= fgeom.left_width)
{
if (has_horiz)
@ -2163,6 +2174,8 @@ get_control (MetaFrames *frames,
}
}
noresize:
return META_FRAME_CONTROL_NONE;
}

View File

@ -1267,25 +1267,37 @@ meta_frame_style_set_new (void)
return style_set;
}
static void
free_focus_styles (MetaFrameStyle *focus_styles[META_WINDOW_FOCUS_LAST])
{
int i;
i = 0;
while (i < META_WINDOW_FOCUS_LAST)
{
if (focus_styles[i])
meta_frame_style_unref (focus_styles[i]);
++i;
}
}
void
meta_frame_style_set_free (MetaFrameStyleSet *style_set)
{
int i, j;
int i;
i = 0;
while (i < META_WINDOW_TYPE_LAST)
while (i < META_WINDOW_RESIZE_LAST)
{
j = 0;
while (j < META_WINDOW_STATE_LAST)
{
if (style_set->styles[i][j])
meta_frame_style_unref (style_set->styles[i][j]);
++j;
}
free_focus_styles (style_set->normal_styles[i]);
++i;
}
free_focus_styles (style_set->maximized_styles);
free_focus_styles (style_set->shaded_styles);
free_focus_styles (style_set->maximized_and_shaded_styles);
g_free (style_set);
}

View File

@ -33,6 +33,7 @@ typedef struct _MetaGradientSpec MetaGradientSpec;
typedef struct _MetaColorSpec MetaColorSpec;
typedef struct _MetaFrameLayout MetaFrameLayout;
typedef struct _MetaFrameGeometry MetaFrameGeometry;
typedef struct _MetaTheme MetaTheme;
/* Parameters used to calculate the geometry of the frame */
struct _MetaFrameLayout
@ -265,40 +266,61 @@ struct _MetaFrameStyle
};
/* FIXME dammit, these are not mutually exclusive; how to handle
* the mess...
*
* normal -> noresize / vert only / horz only / both
* focused / unfocused
* max -> focused / unfocused
* shaded -> focused / unfocused
* max/shaded -> focused / unfocused
*
* so 4 states with 8 sub-states in one, 2 sub-states in the other 3,
* meaning 14 total
*
* 14 window states times 7 or 8 window types. Except some
* window types never get a frame so that narrows it down a bit.
*
*/
typedef enum
{
/* FIXME dammit, these are not mutually exclusive; how to handle
* the mess...
*
* normal -> noresize / vert only / horz only / both
focused / unfocused
* max -> focused / unfocused
* shaded -> focused / unfocused
* max/shaded -> focused / unfocused
*
* so 4 states with 8 sub-states in one, 2 sub-states in the other 3,
* meaning 14 total
*
* 14 window states times 7 or 8 window types.
*
*
* MetaFrameStyleSet needs rearranging to think of it this way.
*
*/
META_WINDOW_STATE_NORMAL,
META_WINDOW_STATE_MAXIMIZED,
META_WINDOW_STATE_SHADED,
META_WINDOW_STATE_MAXIMIZED_AND_SHADED,
META_WINDOW_STATE_RESIZE_VERTICAL,
META_WINDOW_STATE_RESIZE_HORIZONTAL,
META_WINDOW_STATE_RESIZE_BOTH,
META_WINDOW_STATE_UNFOCUSED,
META_WINDOW_STATE_FOCUSED,
META_WINDOW_STATE_LAST
} MetaWindowState;
typedef enum
{
META_WINDOW_RESIZE_NONE,
META_WINDOW_RESIZE_VERTICAL,
META_WINDOW_RESIZE_HORIZONTAL,
META_WINDOW_RESIZE_BOTH,
META_WINDOW_RESIZE_LAST
} MetaWindowResize;
typedef enum
{
META_WINDOW_FOCUS_NO,
META_WINDOW_FOCUS_YES,
META_WINDOW_FOCUS_LAST
} MetaWindowFocus;
/* One StyleSet per window type (for window types that get a frame) */
struct _MetaFrameStyleSet
{
MetaFrameStyle *styles[META_WINDOW_TYPE_LAST][META_WINDOW_STATE_LAST];
MetaFrameStyle *normal_styles[META_WINDOW_RESIZE_LAST][META_WINDOW_FOCUS_LAST];
MetaFrameStyle *maximized_styles[META_WINDOW_FOCUS_LAST];
MetaFrameStyle *shaded_styles[META_WINDOW_FOCUS_LAST];
MetaFrameStyle *maximized_and_shaded_styles[META_WINDOW_FOCUS_LAST];
};
struct _MetaTheme
{
char *name;
char *filename;
MetaFrameStyleSet *style_sets[META_FRAME_TYPE_LAST];
};
MetaFrameLayout* meta_frame_layout_new (void);

View File

@ -28,6 +28,19 @@
#include <X11/Xutil.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
typedef enum
{
META_WINDOW_NORMAL,
META_WINDOW_DESKTOP,
META_WINDOW_DOCK,
META_WINDOW_DIALOG,
META_WINDOW_MODAL_DIALOG,
META_WINDOW_TOOLBAR,
META_WINDOW_MENU
/* FIXME add UTILITY, SPLASHSCREEN */
} MetaWindowType;
struct _MetaWindow
{
MetaDisplay *display;