1
0
Fork 0

Patch from Erwann Chenede for raise_or_lower keybinding

2002-05-28  Havoc Pennington  <hp@pobox.com>

        Patch from Erwann Chenede for raise_or_lower keybinding

	* src/display.c, src/common.h: POINT_IN_RECT moved to a common
	location, removed from here
	(meta_rectangle_intersect): move here and make it public

	* src/prefs.c: add raise_or_lower keybinding

	* src/stack.c (meta_stack_get_below, meta_stack_get_above): add an
	arg to only get windows within the same layer

	* src/keybindings.c (handle_raise_or_lower): add handling for a
	"raise window if obscured, else lower" keybinding
This commit is contained in:
Havoc Pennington 2002-05-29 03:11:24 +00:00 committed by Havoc Pennington
parent 4b5eda0b0a
commit 0498d55314
12 changed files with 161 additions and 57 deletions

View file

@ -1,3 +1,19 @@
2002-05-28 Havoc Pennington <hp@pobox.com>
Patch from Erwann Chenede for raise_or_lower keybinding
* src/display.c, src/common.h: POINT_IN_RECT moved to a common
location, removed from here
(meta_rectangle_intersect): move here and make it public
* src/prefs.c: add raise_or_lower keybinding
* src/stack.c (meta_stack_get_below, meta_stack_get_above): add an
arg to only get windows within the same layer
* src/keybindings.c (handle_raise_or_lower): add handling for a
"raise window if obscured, else lower" keybinding
2002-05-28 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_configure_request): handle CWStackMode

View file

@ -151,6 +151,12 @@ typedef enum
#define META_PRIORITY_PREFS_NOTIFY (G_PRIORITY_DEFAULT_IDLE + 10)
#define META_PRIORITY_WORK_AREA_HINT (G_PRIORITY_DEFAULT_IDLE + 15)
#define POINT_IN_RECT(xcoord, ycoord, rect) \
((xcoord) >= (rect).x && \
(xcoord) < ((rect).x + (rect).width) && \
(ycoord) >= (rect).y && \
(ycoord) < ((rect).y + (rect).height))
#endif

View file

@ -810,12 +810,6 @@ reset_ignores (MetaDisplay *display)
display->ungrab_should_not_cause_focus_window = None;
}
#define POINT_IN_RECT(xcoord, ycoord, rect) \
((xcoord) >= (rect).x && \
(xcoord) < ((rect).x + (rect).width) && \
(ycoord) >= (rect).y && \
(ycoord) < ((rect).y + (rect).height))
static gboolean
window_raise_with_delay_callback (void *data)
{
@ -2926,3 +2920,40 @@ meta_resize_gravity_from_grab_op (MetaGrabOp op)
return gravity;
}
gboolean
meta_rectangle_intersect (MetaRectangle *src1,
MetaRectangle *src2,
MetaRectangle *dest)
{
int dest_x, dest_y;
int dest_w, dest_h;
int return_val;
g_return_val_if_fail (src1 != NULL, FALSE);
g_return_val_if_fail (src2 != NULL, FALSE);
g_return_val_if_fail (dest != NULL, FALSE);
return_val = FALSE;
dest_x = MAX (src1->x, src2->x);
dest_y = MAX (src1->y, src2->y);
dest_w = MIN (src1->x + src1->width, src2->x + src2->width) - dest_x;
dest_h = MIN (src1->y + src1->height, src2->y + src2->height) - dest_y;
if (dest_w > 0 && dest_h > 0)
{
dest->x = dest_x;
dest->y = dest_y;
dest->width = dest_w;
dest->height = dest_h;
return_val = TRUE;
}
else
{
dest->width = 0;
dest->height = 0;
}
return return_val;
}

View file

@ -318,4 +318,8 @@ MetaWindow* meta_display_get_tab_next (MetaDisplay *display,
int meta_resize_gravity_from_grab_op (MetaGrabOp op);
gboolean meta_rectangle_intersect (MetaRectangle *src1,
MetaRectangle *src2,
MetaRectangle *dest);
#endif

View file

@ -1596,12 +1596,6 @@ control_rect (MetaFrameControl control,
return rect;
}
#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 15
static MetaFrameControl
get_control (MetaFrames *frames,

View file

@ -94,7 +94,10 @@ static void handle_move_to_workspace (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
static void handle_raise_or_lower (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
/* debug */
static void handle_spew_mark (MetaDisplay *display,
@ -217,6 +220,7 @@ static const MetaKeyHandler window_handlers[] = {
GINT_TO_POINTER (META_MOTION_UP) },
{ META_KEYBINDING_MOVE_WORKSPACE_DOWN, handle_move_to_workspace,
GINT_TO_POINTER (META_MOTION_DOWN) },
{ META_KEYBINDING_RAISE_OR_LOWER, handle_raise_or_lower, NULL},
{ NULL, NULL, NULL }
};
@ -1696,6 +1700,57 @@ handle_move_to_workspace (MetaDisplay *display,
}
}
static void
handle_raise_or_lower (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding)
{
/* Get window at pointer */
MetaScreen *screen;
screen = meta_display_screen_for_root (display, event->xbutton.root);
if (screen == NULL)
return;
if (window)
{
MetaWindow *above = NULL;
/* Check if top */
if (meta_stack_get_top (window->screen->stack) == window)
{
meta_window_lower (window);
return;
}
/* else check if windows in same layer are intersecting it */
above = meta_stack_get_above (window->screen->stack, window, TRUE);
while (above)
{
MetaRectangle tmp, win_rect, above_rect;
meta_window_get_outer_rect (window, &win_rect);
meta_window_get_outer_rect (above, &above_rect);
/* Check if obscured */
if (meta_rectangle_intersect (&win_rect, &above_rect, &tmp))
{
meta_window_raise (window);
return;
}
above = meta_stack_get_above (window->screen->stack, above, TRUE);
}
/* window is not obscured */
meta_window_lower (window);
}
}
static void
handle_spew_mark (MetaDisplay *display,
MetaWindow *window,
@ -1720,5 +1775,3 @@ meta_set_keybindings_disabled (gboolean setting)
"Ignoring keybindings disable message, not in debug mode\n");
}
}

View file

@ -690,6 +690,33 @@ you set
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/window_keybindings/raise_or_lower</key>
<applyto>/apps/metacity/window_keybindings/raise_or_lower</applyto>
<owner>metacity</owner>
<type>string</type>
<!-- no default for this one -->
<locale name="C">
<short>Raise window if obscured, lowers it otherwise</short>
<long>
This keybinding changes whether a window is above or below
other windows. If the window is covered by another window, it raises
the window above other windows. If the window is already fully visible,
it lowers the window below other windows.
The format looks like "&lt;Control&gt;a" or
"&lt;Shift&gt;&lt;Alt&gt;F1.
The parser is fairly liberal and allows lower or upper case,
and also abbreviations such as "&lt;Ctl&gt;" and
"&lt;Ctrl&gt;". If you set the option to the special string
"disabled", then there will be no keybinding for this
action.
</long>
</locale>
</schema>
<!-- Global Keybindings -->
@ -1179,7 +1206,6 @@ you set
</locale>
</schema>
<!-- Not used and/or crackrock -->
<schema>

View file

@ -850,6 +850,7 @@ static MetaKeyPref window_bindings[] = {
{ META_KEYBINDING_MOVE_WORKSPACE_RIGHT, 0, 0 },
{ META_KEYBINDING_MOVE_WORKSPACE_UP, 0, 0 },
{ META_KEYBINDING_MOVE_WORKSPACE_DOWN, 0, 0 },
{ META_KEYBINDING_RAISE_OR_LOWER, 0, 0 },
{ NULL, 0, 0 }
};

View file

@ -111,6 +111,7 @@ void meta_prefs_set_num_workspaces (int n_workspaces);
#define META_KEYBINDING_MOVE_WORKSPACE_RIGHT "move_to_workspace_right"
#define META_KEYBINDING_MOVE_WORKSPACE_UP "move_to_workspace_up"
#define META_KEYBINDING_MOVE_WORKSPACE_DOWN "move_to_workspace_down"
#define META_KEYBINDING_RAISE_OR_LOWER "raise_or_lower"
typedef struct
{

View file

@ -800,43 +800,6 @@ meta_screen_focus_top_window (MetaScreen *screen,
}
}
static gboolean
meta_rectangle_intersect (MetaRectangle *src1,
MetaRectangle *src2,
MetaRectangle *dest)
{
int dest_x, dest_y;
int dest_w, dest_h;
int return_val;
g_return_val_if_fail (src1 != NULL, FALSE);
g_return_val_if_fail (src2 != NULL, FALSE);
g_return_val_if_fail (dest != NULL, FALSE);
return_val = FALSE;
dest_x = MAX (src1->x, src2->x);
dest_y = MAX (src1->y, src2->y);
dest_w = MIN (src1->x + src1->width, src2->x + src2->width) - dest_x;
dest_h = MIN (src1->y + src1->height, src2->y + src2->height) - dest_y;
if (dest_w > 0 && dest_h > 0)
{
dest->x = dest_x;
dest->y = dest_y;
dest->width = dest_w;
dest->height = dest_h;
return_val = TRUE;
}
else
{
dest->width = 0;
dest->height = 0;
}
return return_val;
}
const MetaXineramaScreenInfo*
meta_screen_get_xinerama_for_window (MetaScreen *screen,
MetaWindow *window)

View file

@ -938,7 +938,8 @@ meta_stack_get_bottom (MetaStack *stack)
MetaWindow*
meta_stack_get_above (MetaStack *stack,
MetaWindow *window)
MetaWindow *window,
gboolean only_within_layer)
{
GList *link;
@ -951,13 +952,16 @@ meta_stack_get_above (MetaStack *stack,
if (link->prev)
return link->prev->data;
else if (only_within_layer)
return NULL;
else
return find_next_above_layer (stack, window->layer);
}
MetaWindow*
meta_stack_get_below (MetaStack *stack,
MetaWindow *window)
MetaWindow *window,
gboolean only_within_layer)
{
GList *link;
@ -970,6 +974,8 @@ meta_stack_get_below (MetaStack *stack,
if (link->next)
return link->next->data;
else if (only_within_layer)
return NULL;
else
return find_prev_below_layer (stack, window->layer);
}

View file

@ -93,13 +93,16 @@ void meta_stack_thaw (MetaStack *stack);
MetaWindow* meta_stack_get_top (MetaStack *stack);
MetaWindow* meta_stack_get_bottom (MetaStack *stack);
MetaWindow* meta_stack_get_above (MetaStack *stack,
MetaWindow *window);
MetaWindow *window,
gboolean only_within_layer);
MetaWindow* meta_stack_get_below (MetaStack *stack,
MetaWindow *window);
MetaWindow *window,
gboolean only_within_layer);
MetaWindow* meta_stack_get_default_focus_window (MetaStack *stack,
MetaWorkspace *workspace,
MetaWindow *not_this_one);
/* -1 if a < b, etc. */
int meta_stack_windows_cmp (MetaStack *stack,
MetaWindow *window_a,