mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
Unbreak tab popup a bit.
2001-08-28 Havoc Pennington <hp@pobox.com> Unbreak tab popup a bit. * src/stack.c (meta_stack_get_tab_list): add workspace argument (meta_stack_get_tab_next): add workspace argument * src/window.c: implement recording of the last user-initiated window position, so we can magically handle moving panels around really nicely. * src/wm-tester/main.c (set_up_icon_windows): fix to use new GTK API
This commit is contained in:
parent
4d2f018ddb
commit
db0a7e2978
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
2001-08-28 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
|
Unbreak tab popup a bit.
|
||||||
|
|
||||||
|
* src/stack.c (meta_stack_get_tab_list): add workspace argument
|
||||||
|
(meta_stack_get_tab_next): add workspace argument
|
||||||
|
|
||||||
|
* src/window.c: implement recording of the last user-initiated
|
||||||
|
window position, so we can magically handle moving panels around
|
||||||
|
really nicely.
|
||||||
|
|
||||||
|
* src/wm-tester/main.c (set_up_icon_windows): fix to use new GTK
|
||||||
|
API
|
||||||
|
|
||||||
2001-08-24 Havoc Pennington <hp@pobox.com>
|
2001-08-24 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
* src/window.c (constrain_position): force fullscreen windows to
|
* src/window.c (constrain_position): force fullscreen windows to
|
||||||
|
@ -91,8 +91,7 @@ meta_core_user_move (Display *xdisplay,
|
|||||||
if (window == NULL || window->frame == NULL)
|
if (window == NULL || window->frame == NULL)
|
||||||
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
|
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
|
||||||
|
|
||||||
window->user_has_moved = TRUE;
|
meta_window_move (window, TRUE, x, y);
|
||||||
meta_window_move (window, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -111,8 +110,7 @@ meta_core_user_resize (Display *xdisplay,
|
|||||||
if (window == NULL || window->frame == NULL)
|
if (window == NULL || window->frame == NULL)
|
||||||
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
|
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
|
||||||
|
|
||||||
window->user_has_resized = TRUE;
|
meta_window_resize_with_gravity (window, TRUE, width, height, gravity);
|
||||||
meta_window_resize_with_gravity (window, width, height, gravity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -581,6 +581,7 @@ process_keyboard_move_grab (MetaDisplay *display,
|
|||||||
case XK_Escape:
|
case XK_Escape:
|
||||||
/* End move and restore to original position */
|
/* End move and restore to original position */
|
||||||
meta_window_move_resize (display->grab_window,
|
meta_window_move_resize (display->grab_window,
|
||||||
|
TRUE,
|
||||||
display->grab_initial_window_pos.x,
|
display->grab_initial_window_pos.x,
|
||||||
display->grab_initial_window_pos.y,
|
display->grab_initial_window_pos.y,
|
||||||
display->grab_initial_window_pos.width,
|
display->grab_initial_window_pos.width,
|
||||||
@ -592,7 +593,7 @@ process_keyboard_move_grab (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (handled)
|
if (handled)
|
||||||
meta_window_move (window, x, y);
|
meta_window_move (window, TRUE, x, y);
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
@ -832,6 +833,7 @@ handle_tab_forward (MetaDisplay *display,
|
|||||||
if (display->focus_window != NULL)
|
if (display->focus_window != NULL)
|
||||||
{
|
{
|
||||||
window = meta_stack_get_tab_next (display->focus_window->screen->stack,
|
window = meta_stack_get_tab_next (display->focus_window->screen->stack,
|
||||||
|
display->focus_window->screen->active_workspace,
|
||||||
display->focus_window,
|
display->focus_window,
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
@ -849,7 +851,8 @@ handle_tab_forward (MetaDisplay *display,
|
|||||||
if (screen)
|
if (screen)
|
||||||
{
|
{
|
||||||
window = meta_stack_get_tab_next (screen->stack,
|
window = meta_stack_get_tab_next (screen->stack,
|
||||||
event_window,
|
screen->active_workspace,
|
||||||
|
NULL,
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -890,6 +893,7 @@ handle_tab_backward (MetaDisplay *display,
|
|||||||
if (display->focus_window != NULL)
|
if (display->focus_window != NULL)
|
||||||
{
|
{
|
||||||
window = meta_stack_get_tab_next (display->focus_window->screen->stack,
|
window = meta_stack_get_tab_next (display->focus_window->screen->stack,
|
||||||
|
display->focus_window->screen->active_workspace,
|
||||||
display->focus_window,
|
display->focus_window,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
@ -907,7 +911,8 @@ handle_tab_backward (MetaDisplay *display,
|
|||||||
if (screen)
|
if (screen)
|
||||||
{
|
{
|
||||||
window = meta_stack_get_tab_next (screen->stack,
|
window = meta_stack_get_tab_next (screen->stack,
|
||||||
event_window,
|
screen->active_workspace,
|
||||||
|
NULL,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,29 +945,36 @@ handle_focus_previous (MetaDisplay *display,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
|
MetaScreen *screen;
|
||||||
|
|
||||||
meta_verbose ("Focus previous window\n");
|
meta_verbose ("Focus previous window\n");
|
||||||
|
|
||||||
window = display->prev_focus_window;
|
|
||||||
|
|
||||||
if (window == NULL)
|
|
||||||
{
|
|
||||||
/* Pick first window in tab order */
|
|
||||||
MetaScreen *screen;
|
|
||||||
|
|
||||||
screen = meta_display_screen_for_root (display,
|
screen = meta_display_screen_for_root (display,
|
||||||
event->xkey.root);
|
event->xkey.root);
|
||||||
|
|
||||||
/* We get the screen because event_window may be NULL,
|
if (screen == NULL)
|
||||||
* in which case we can't use event_window->screen
|
return;
|
||||||
*/
|
|
||||||
if (screen)
|
window = display->prev_focus_window;
|
||||||
|
|
||||||
|
if (window &&
|
||||||
|
!meta_workspace_contains_window (screen->active_workspace,
|
||||||
|
window))
|
||||||
|
window = NULL;
|
||||||
|
|
||||||
|
if (window == NULL)
|
||||||
{
|
{
|
||||||
|
/* Pick first window in tab order */
|
||||||
window = meta_stack_get_tab_next (screen->stack,
|
window = meta_stack_get_tab_next (screen->stack,
|
||||||
event_window,
|
screen->active_workspace,
|
||||||
|
NULL,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (window &&
|
||||||
|
!meta_workspace_contains_window (screen->active_workspace,
|
||||||
|
window))
|
||||||
|
window = NULL;
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
|
@ -464,7 +464,8 @@ meta_screen_ensure_tab_popup (MetaScreen *screen)
|
|||||||
if (screen->tab_popup)
|
if (screen->tab_popup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tab_list = meta_stack_get_tab_list (screen->stack);
|
tab_list = meta_stack_get_tab_list (screen->stack,
|
||||||
|
screen->active_workspace);
|
||||||
len = g_slist_length (tab_list);
|
len = g_slist_length (tab_list);
|
||||||
|
|
||||||
entries = g_new (MetaTabEntry, len + 1);
|
entries = g_new (MetaTabEntry, len + 1);
|
||||||
|
28
src/stack.c
28
src/stack.c
@ -863,11 +863,22 @@ find_tab_backward (MetaStack *stack,
|
|||||||
/* This ignores the dock/desktop layers */
|
/* This ignores the dock/desktop layers */
|
||||||
MetaWindow*
|
MetaWindow*
|
||||||
meta_stack_get_tab_next (MetaStack *stack,
|
meta_stack_get_tab_next (MetaStack *stack,
|
||||||
|
MetaWorkspace *workspace,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
gboolean backward)
|
gboolean backward)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (workspace && window)
|
||||||
|
{
|
||||||
|
/* This is a paranoia check, because races can happen where
|
||||||
|
* you get a key shortcut or something on a window just as you
|
||||||
|
* are moving workspaces to one the window isn't on
|
||||||
|
*/
|
||||||
|
if (!meta_workspace_contains_window (workspace, window))
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (stack->windows->len == 0)
|
if (stack->windows->len == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -882,10 +893,6 @@ meta_stack_get_tab_next (MetaStack *stack,
|
|||||||
|
|
||||||
if (w == window->xwindow)
|
if (w == window->xwindow)
|
||||||
{
|
{
|
||||||
MetaWorkspace *workspace;
|
|
||||||
|
|
||||||
workspace = window->screen->active_workspace;
|
|
||||||
|
|
||||||
if (backward)
|
if (backward)
|
||||||
return find_tab_backward (stack, workspace, i);
|
return find_tab_backward (stack, workspace, i);
|
||||||
else
|
else
|
||||||
@ -900,14 +907,15 @@ meta_stack_get_tab_next (MetaStack *stack,
|
|||||||
* window and we need to wrap around
|
* window and we need to wrap around
|
||||||
*/
|
*/
|
||||||
if (backward)
|
if (backward)
|
||||||
return find_tab_backward (stack, NULL,
|
return find_tab_backward (stack, workspace,
|
||||||
stack->windows->len);
|
stack->windows->len);
|
||||||
else
|
else
|
||||||
return find_tab_forward (stack, NULL, -1);
|
return find_tab_forward (stack, workspace, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
meta_stack_get_tab_list (MetaStack *stack)
|
meta_stack_get_tab_list (MetaStack *stack,
|
||||||
|
MetaWorkspace *workspace)
|
||||||
{
|
{
|
||||||
GSList *list;
|
GSList *list;
|
||||||
int i;
|
int i;
|
||||||
@ -918,16 +926,10 @@ meta_stack_get_tab_list (MetaStack *stack)
|
|||||||
while (i < stack->windows->len)
|
while (i < stack->windows->len)
|
||||||
{
|
{
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
MetaWorkspace *workspace;
|
|
||||||
|
|
||||||
window = meta_display_lookup_x_window (stack->screen->display,
|
window = meta_display_lookup_x_window (stack->screen->display,
|
||||||
GET_XWINDOW (stack, i));
|
GET_XWINDOW (stack, i));
|
||||||
|
|
||||||
if (window)
|
|
||||||
workspace = window->screen->active_workspace;
|
|
||||||
else
|
|
||||||
workspace = NULL;
|
|
||||||
|
|
||||||
if (window && IN_TAB_CHAIN (window) &&
|
if (window && IN_TAB_CHAIN (window) &&
|
||||||
(workspace == NULL ||
|
(workspace == NULL ||
|
||||||
meta_workspace_contains_window (workspace, window)))
|
meta_workspace_contains_window (workspace, window)))
|
||||||
|
@ -94,9 +94,12 @@ MetaWindow* meta_stack_get_below (MetaStack *stack,
|
|||||||
MetaWindow *window);
|
MetaWindow *window);
|
||||||
|
|
||||||
MetaWindow* meta_stack_get_tab_next (MetaStack *stack,
|
MetaWindow* meta_stack_get_tab_next (MetaStack *stack,
|
||||||
|
MetaWorkspace *workspace,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
gboolean backward);
|
gboolean backward);
|
||||||
GSList* meta_stack_get_tab_list (MetaStack *stack);
|
GSList* meta_stack_get_tab_list (MetaStack *stack,
|
||||||
|
MetaWorkspace *workspace);
|
||||||
|
|
||||||
/* -1 if a < b, etc. */
|
/* -1 if a < b, etc. */
|
||||||
int meta_stack_windows_cmp (MetaStack *stack,
|
int meta_stack_windows_cmp (MetaStack *stack,
|
||||||
MetaWindow *window_a,
|
MetaWindow *window_a,
|
||||||
|
@ -61,6 +61,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
|
|||||||
GtkWidget *table;
|
GtkWidget *table;
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
|
int max_label_width;
|
||||||
|
|
||||||
popup = g_new (MetaTabPopup, 1);
|
popup = g_new (MetaTabPopup, 1);
|
||||||
popup->window = gtk_window_new (GTK_WINDOW_POPUP);
|
popup->window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||||
@ -118,6 +119,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
|
|||||||
3, 3);
|
3, 3);
|
||||||
|
|
||||||
|
|
||||||
|
max_label_width = 0;
|
||||||
top = 0;
|
top = 0;
|
||||||
bottom = 1;
|
bottom = 1;
|
||||||
tmp = popup->entries;
|
tmp = popup->entries;
|
||||||
@ -130,6 +132,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
|
|||||||
while (tmp && left < width)
|
while (tmp && left < width)
|
||||||
{
|
{
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
|
GtkRequisition req;
|
||||||
|
|
||||||
TabEntry *te;
|
TabEntry *te;
|
||||||
|
|
||||||
@ -149,6 +152,12 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
|
|||||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||||
0, 0);
|
0, 0);
|
||||||
|
|
||||||
|
/* Efficiency rules! */
|
||||||
|
gtk_label_set_text (GTK_LABEL (popup->label),
|
||||||
|
te->title);
|
||||||
|
gtk_widget_size_request (popup->label, &req);
|
||||||
|
max_label_width = MAX (max_label_width, req.width);
|
||||||
|
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
|
|
||||||
++left;
|
++left;
|
||||||
@ -159,6 +168,13 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries)
|
|||||||
++bottom;
|
++bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove all the temporary text */
|
||||||
|
gtk_label_set_text (GTK_LABEL (popup->label), "");
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (popup->window),
|
||||||
|
max_label_width + 20 /* random number */,
|
||||||
|
-1);
|
||||||
|
|
||||||
return popup;
|
return popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
106
src/window.c
106
src/window.c
@ -33,6 +33,14 @@
|
|||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
META_IS_CONFIGURE_REQUEST = 1 << 0,
|
||||||
|
META_DO_GRAVITY_ADJUST = 1 << 1,
|
||||||
|
META_USER_RESIZE = 1 << 2,
|
||||||
|
META_USER_MOVE = 1 << 3
|
||||||
|
} MetaMoveResizeFlags;
|
||||||
|
|
||||||
static void constrain_size (MetaWindow *window,
|
static void constrain_size (MetaWindow *window,
|
||||||
MetaFrameGeometry *fgeom,
|
MetaFrameGeometry *fgeom,
|
||||||
int width,
|
int width,
|
||||||
@ -83,9 +91,9 @@ static void adjust_for_gravity (MetaWindow *window,
|
|||||||
int y,
|
int y,
|
||||||
int *xp,
|
int *xp,
|
||||||
int *yp);
|
int *yp);
|
||||||
|
|
||||||
static void meta_window_move_resize_internal (MetaWindow *window,
|
static void meta_window_move_resize_internal (MetaWindow *window,
|
||||||
gboolean is_configure_request,
|
MetaMoveResizeFlags flags,
|
||||||
gboolean do_gravity_adjust,
|
|
||||||
int resize_gravity,
|
int resize_gravity,
|
||||||
int root_x_nw,
|
int root_x_nw,
|
||||||
int root_y_nw,
|
int root_y_nw,
|
||||||
@ -250,6 +258,7 @@ meta_window_new (MetaDisplay *display, Window xwindow,
|
|||||||
|
|
||||||
/* And this is our unmaximized size */
|
/* And this is our unmaximized size */
|
||||||
window->saved_rect = window->rect;
|
window->saved_rect = window->rect;
|
||||||
|
window->user_rect = window->rect;
|
||||||
|
|
||||||
window->depth = attrs.depth;
|
window->depth = attrs.depth;
|
||||||
window->xvisual = attrs.visual;
|
window->xvisual = attrs.visual;
|
||||||
@ -485,7 +494,8 @@ meta_window_new (MetaDisplay *display, Window xwindow,
|
|||||||
* passing TRUE for is_configure_request, ICCCM says
|
* passing TRUE for is_configure_request, ICCCM says
|
||||||
* initial map is handled same as configure request
|
* initial map is handled same as configure request
|
||||||
*/
|
*/
|
||||||
meta_window_move_resize_internal (window, TRUE, FALSE,
|
meta_window_move_resize_internal (window,
|
||||||
|
META_IS_CONFIGURE_REQUEST,
|
||||||
NorthWestGravity,
|
NorthWestGravity,
|
||||||
window->size_hints.x,
|
window->size_hints.x,
|
||||||
window->size_hints.y,
|
window->size_hints.y,
|
||||||
@ -604,7 +614,7 @@ meta_window_apply_session_info (MetaWindow *window,
|
|||||||
x, y, w, h, window->desc);
|
x, y, w, h, window->desc);
|
||||||
|
|
||||||
meta_window_move_resize_internal (window,
|
meta_window_move_resize_internal (window,
|
||||||
FALSE, TRUE,
|
META_DO_GRAVITY_ADJUST,
|
||||||
NorthWestGravity,
|
NorthWestGravity,
|
||||||
x, y, w, h);
|
x, y, w, h);
|
||||||
}
|
}
|
||||||
@ -1077,6 +1087,7 @@ meta_window_unmaximize (MetaWindow *window)
|
|||||||
window->maximized = FALSE;
|
window->maximized = FALSE;
|
||||||
|
|
||||||
meta_window_move_resize (window,
|
meta_window_move_resize (window,
|
||||||
|
TRUE,
|
||||||
window->saved_rect.x,
|
window->saved_rect.x,
|
||||||
window->saved_rect.y,
|
window->saved_rect.y,
|
||||||
window->saved_rect.width,
|
window->saved_rect.width,
|
||||||
@ -1277,9 +1288,7 @@ adjust_for_gravity (MetaWindow *window,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_move_resize_internal (MetaWindow *window,
|
meta_window_move_resize_internal (MetaWindow *window,
|
||||||
gboolean is_configure_request,
|
MetaMoveResizeFlags flags,
|
||||||
/* only relevant if !is_configure_request */
|
|
||||||
gboolean do_gravity_adjust,
|
|
||||||
int resize_gravity,
|
int resize_gravity,
|
||||||
int root_x_nw,
|
int root_x_nw,
|
||||||
int root_y_nw,
|
int root_y_nw,
|
||||||
@ -1300,13 +1309,24 @@ meta_window_move_resize_internal (MetaWindow *window,
|
|||||||
int pos_dy;
|
int pos_dy;
|
||||||
int frame_size_dx;
|
int frame_size_dx;
|
||||||
int frame_size_dy;
|
int frame_size_dy;
|
||||||
|
gboolean is_configure_request;
|
||||||
|
gboolean do_gravity_adjust;
|
||||||
|
gboolean is_user_resize;
|
||||||
|
gboolean is_user_move;
|
||||||
|
|
||||||
|
is_configure_request = (flags & META_IS_CONFIGURE_REQUEST) != 0;
|
||||||
|
do_gravity_adjust = (flags & META_DO_GRAVITY_ADJUST) != 0;
|
||||||
|
is_user_resize = (flags & META_USER_RESIZE) != 0;
|
||||||
|
is_user_move = (flags & META_USER_MOVE) != 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
int oldx, oldy;
|
int oldx, oldy;
|
||||||
meta_window_get_position (window, &oldx, &oldy);
|
meta_window_get_position (window, &oldx, &oldy);
|
||||||
meta_verbose ("Move/resize %s to %d,%d %dx%d%s from %d,%d %dx%d\n",
|
meta_verbose ("Move/resize %s to %d,%d %dx%d%s%s%s from %d,%d %dx%d\n",
|
||||||
window->desc, root_x_nw, root_y_nw, w, h,
|
window->desc, root_x_nw, root_y_nw, w, h,
|
||||||
is_configure_request ? " (configure request)" : "",
|
is_configure_request ? " (configure request)" : "",
|
||||||
|
is_user_resize ? " (user resize)" : "",
|
||||||
|
is_user_move ? " (user move)" : "",
|
||||||
oldx, oldy, window->rect.width, window->rect.height);
|
oldx, oldy, window->rect.width, window->rect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1549,6 +1569,22 @@ meta_window_move_resize_internal (MetaWindow *window,
|
|||||||
if (need_configure_notify)
|
if (need_configure_notify)
|
||||||
send_configure_notify (window);
|
send_configure_notify (window);
|
||||||
|
|
||||||
|
if (is_user_resize)
|
||||||
|
{
|
||||||
|
window->user_has_resized = TRUE;
|
||||||
|
window->user_rect.width = window->rect.width;
|
||||||
|
window->user_rect.height = window->rect.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_user_move)
|
||||||
|
{
|
||||||
|
window->user_has_moved = TRUE;
|
||||||
|
meta_window_get_position (window,
|
||||||
|
&window->user_rect.x,
|
||||||
|
&window->user_rect.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Invariants leaving this function are:
|
/* Invariants leaving this function are:
|
||||||
* a) window->rect and frame->rect reflect the actual
|
* a) window->rect and frame->rect reflect the actual
|
||||||
* server-side size/pos of window->xwindow and frame->xwindow
|
* server-side size/pos of window->xwindow and frame->xwindow
|
||||||
@ -1558,6 +1594,7 @@ meta_window_move_resize_internal (MetaWindow *window,
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_window_resize (MetaWindow *window,
|
meta_window_resize (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int w,
|
int w,
|
||||||
int h)
|
int h)
|
||||||
{
|
{
|
||||||
@ -1565,17 +1602,20 @@ meta_window_resize (MetaWindow *window,
|
|||||||
|
|
||||||
meta_window_get_position (window, &x, &y);
|
meta_window_get_position (window, &x, &y);
|
||||||
|
|
||||||
meta_window_move_resize_internal (window, FALSE, FALSE,
|
meta_window_move_resize_internal (window,
|
||||||
|
user_op ? META_USER_RESIZE : 0,
|
||||||
NorthWestGravity,
|
NorthWestGravity,
|
||||||
x, y, w, h);
|
x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_move (MetaWindow *window,
|
meta_window_move (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int root_x_nw,
|
int root_x_nw,
|
||||||
int root_y_nw)
|
int root_y_nw)
|
||||||
{
|
{
|
||||||
meta_window_move_resize_internal (window, FALSE, FALSE,
|
meta_window_move_resize_internal (window,
|
||||||
|
user_op ? META_USER_MOVE : 0,
|
||||||
NorthWestGravity,
|
NorthWestGravity,
|
||||||
root_x_nw, root_y_nw,
|
root_x_nw, root_y_nw,
|
||||||
window->rect.width,
|
window->rect.width,
|
||||||
@ -1584,12 +1624,14 @@ meta_window_move (MetaWindow *window,
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_window_move_resize (MetaWindow *window,
|
meta_window_move_resize (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int root_x_nw,
|
int root_x_nw,
|
||||||
int root_y_nw,
|
int root_y_nw,
|
||||||
int w,
|
int w,
|
||||||
int h)
|
int h)
|
||||||
{
|
{
|
||||||
meta_window_move_resize_internal (window, FALSE, FALSE,
|
meta_window_move_resize_internal (window,
|
||||||
|
user_op ? META_USER_MOVE | META_USER_RESIZE : 0,
|
||||||
NorthWestGravity,
|
NorthWestGravity,
|
||||||
root_x_nw, root_y_nw,
|
root_x_nw, root_y_nw,
|
||||||
w, h);
|
w, h);
|
||||||
@ -1597,6 +1639,7 @@ meta_window_move_resize (MetaWindow *window,
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_window_resize_with_gravity (MetaWindow *window,
|
meta_window_resize_with_gravity (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int w,
|
int w,
|
||||||
int h,
|
int h,
|
||||||
int gravity)
|
int gravity)
|
||||||
@ -1605,7 +1648,8 @@ meta_window_resize_with_gravity (MetaWindow *window,
|
|||||||
|
|
||||||
meta_window_get_position (window, &x, &y);
|
meta_window_get_position (window, &x, &y);
|
||||||
|
|
||||||
meta_window_move_resize_internal (window, FALSE, FALSE,
|
meta_window_move_resize_internal (window,
|
||||||
|
user_op ? META_USER_RESIZE : 0,
|
||||||
gravity,
|
gravity,
|
||||||
x, y, w, h);
|
x, y, w, h);
|
||||||
}
|
}
|
||||||
@ -1615,10 +1659,16 @@ meta_window_move_resize_now (MetaWindow *window)
|
|||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
meta_window_get_position (window, &x, &y);
|
/* If constraints have changed then we'll snap back to wherever
|
||||||
|
* the user had the window
|
||||||
|
*/
|
||||||
|
meta_window_get_user_position (window, &x, &y);
|
||||||
|
|
||||||
meta_window_move_resize (window, x, y,
|
meta_window_move_resize (window, FALSE, x, y,
|
||||||
window->rect.width, window->rect.height);
|
window->user_has_resized ?
|
||||||
|
window->user_rect.width : window->rect.width,
|
||||||
|
window->user_has_resized ?
|
||||||
|
window->user_rect.height : window->rect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1649,6 +1699,24 @@ meta_window_get_position (MetaWindow *window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_window_get_user_position (MetaWindow *window,
|
||||||
|
int *x,
|
||||||
|
int *y)
|
||||||
|
{
|
||||||
|
if (window->user_has_moved)
|
||||||
|
{
|
||||||
|
if (x)
|
||||||
|
*x = window->user_rect.x;
|
||||||
|
if (y)
|
||||||
|
*y = window->user_rect.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta_window_get_position (window, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_get_gravity_position (MetaWindow *window,
|
meta_window_get_gravity_position (MetaWindow *window,
|
||||||
int *root_x,
|
int *root_x,
|
||||||
@ -2060,7 +2128,7 @@ meta_window_configure_request (MetaWindow *window,
|
|||||||
* move_resize_internal arguments.
|
* move_resize_internal arguments.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
meta_window_move_resize_internal (window, TRUE, FALSE,
|
meta_window_move_resize_internal (window, META_IS_CONFIGURE_REQUEST,
|
||||||
only_resize ?
|
only_resize ?
|
||||||
window->size_hints.win_gravity : NorthWestGravity,
|
window->size_hints.win_gravity : NorthWestGravity,
|
||||||
window->size_hints.x,
|
window->size_hints.x,
|
||||||
@ -4600,7 +4668,6 @@ update_move (MetaWindow *window,
|
|||||||
dx = x - window->display->grab_root_x;
|
dx = x - window->display->grab_root_x;
|
||||||
dy = y - window->display->grab_root_y;
|
dy = y - window->display->grab_root_y;
|
||||||
|
|
||||||
window->user_has_moved = TRUE;
|
|
||||||
new_x = window->display->grab_initial_window_pos.x + dx;
|
new_x = window->display->grab_initial_window_pos.x + dx;
|
||||||
new_y = window->display->grab_initial_window_pos.y + dy;
|
new_y = window->display->grab_initial_window_pos.y + dy;
|
||||||
|
|
||||||
@ -4611,7 +4678,7 @@ update_move (MetaWindow *window,
|
|||||||
new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
|
new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_window_move (window, new_x, new_y);
|
meta_window_move (window, TRUE, new_x, new_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4696,8 +4763,7 @@ update_resize (MetaWindow *window,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->user_has_resized = TRUE;
|
meta_window_resize_with_gravity (window, TRUE, new_w, new_h, gravity);
|
||||||
meta_window_resize_with_gravity (window, new_w, new_h, gravity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
21
src/window.h
21
src/window.h
@ -156,8 +156,7 @@ struct _MetaWindow
|
|||||||
guint has_focus : 1;
|
guint has_focus : 1;
|
||||||
|
|
||||||
/* Track whether the user has ever manually modified
|
/* Track whether the user has ever manually modified
|
||||||
* the window; if so, we remove some constraints
|
* the window; if so, we can use the saved user size/pos
|
||||||
* that exist on program modifications.
|
|
||||||
*/
|
*/
|
||||||
guint user_has_resized : 1;
|
guint user_has_resized : 1;
|
||||||
guint user_has_moved : 1;
|
guint user_has_moved : 1;
|
||||||
@ -206,6 +205,17 @@ struct _MetaWindow
|
|||||||
*/
|
*/
|
||||||
MetaRectangle saved_rect;
|
MetaRectangle saved_rect;
|
||||||
|
|
||||||
|
/* This is the geometry the window had after the last user-initiated
|
||||||
|
* move/resize operations. We use this whenever we are moving the
|
||||||
|
* implicitly (for example, if we move to avoid a panel, we
|
||||||
|
* can snap back to this position if the panel moves again)
|
||||||
|
*
|
||||||
|
* Position valid if user_has_moved, size valid if user_has_resized
|
||||||
|
*
|
||||||
|
* Position always in root coords, unlike window->rect
|
||||||
|
*/
|
||||||
|
MetaRectangle user_rect;
|
||||||
|
|
||||||
/* Requested geometry */
|
/* Requested geometry */
|
||||||
int border_width;
|
int border_width;
|
||||||
/* x/y/w/h here get filled with ConfigureRequest values */
|
/* x/y/w/h here get filled with ConfigureRequest values */
|
||||||
@ -235,17 +245,21 @@ void meta_window_unstick (MetaWindow *window);
|
|||||||
|
|
||||||
/* args to move are window pos, not frame pos */
|
/* args to move are window pos, not frame pos */
|
||||||
void meta_window_move (MetaWindow *window,
|
void meta_window_move (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int root_x_nw,
|
int root_x_nw,
|
||||||
int root_y_nw);
|
int root_y_nw);
|
||||||
void meta_window_resize (MetaWindow *window,
|
void meta_window_resize (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int w,
|
int w,
|
||||||
int h);
|
int h);
|
||||||
void meta_window_move_resize (MetaWindow *window,
|
void meta_window_move_resize (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int root_x_nw,
|
int root_x_nw,
|
||||||
int root_y_nw,
|
int root_y_nw,
|
||||||
int w,
|
int w,
|
||||||
int h);
|
int h);
|
||||||
void meta_window_resize_with_gravity (MetaWindow *window,
|
void meta_window_resize_with_gravity (MetaWindow *window,
|
||||||
|
gboolean user_op,
|
||||||
int w,
|
int w,
|
||||||
int h,
|
int h,
|
||||||
int gravity);
|
int gravity);
|
||||||
@ -259,6 +273,9 @@ void meta_window_queue_move_resize (MetaWindow *window);
|
|||||||
void meta_window_get_position (MetaWindow *window,
|
void meta_window_get_position (MetaWindow *window,
|
||||||
int *x,
|
int *x,
|
||||||
int *y);
|
int *y);
|
||||||
|
void meta_window_get_user_position (MetaWindow *window,
|
||||||
|
int *x,
|
||||||
|
int *y);
|
||||||
/* gets position we need to set to stay in current position,
|
/* gets position we need to set to stay in current position,
|
||||||
* assuming position will be gravity-compensated. i.e.
|
* assuming position will be gravity-compensated. i.e.
|
||||||
* this is the position a client would send in a configure
|
* this is the position a client would send in a configure
|
||||||
|
@ -185,8 +185,6 @@ set_up_icon_windows (void)
|
|||||||
c = gtk_button_new_with_label ("Icon window");
|
c = gtk_button_new_with_label ("Icon window");
|
||||||
gtk_container_add (GTK_CONTAINER (w), c);
|
gtk_container_add (GTK_CONTAINER (w), c);
|
||||||
|
|
||||||
gtk_widget_realize (w);
|
|
||||||
|
|
||||||
icons = NULL;
|
icons = NULL;
|
||||||
|
|
||||||
pix = gtk_widget_render_icon (w,
|
pix = gtk_widget_render_icon (w,
|
||||||
@ -214,8 +212,7 @@ set_up_icon_windows (void)
|
|||||||
icons = g_list_append (icons, pix);
|
icons = g_list_append (icons, pix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gdk_window_set_icon_list (w->window, icons))
|
gtk_window_set_icon_list (GTK_WINDOW (w), icons);
|
||||||
g_warning ("_NET_WM_ICON not supported?");
|
|
||||||
|
|
||||||
g_list_foreach (icons, (GFunc) g_object_unref, NULL);
|
g_list_foreach (icons, (GFunc) g_object_unref, NULL);
|
||||||
g_list_free (icons);
|
g_list_free (icons);
|
||||||
|
Loading…
Reference in New Issue
Block a user