2001-05-30 11:36:31 -04:00
|
|
|
/* Metacity X managed windows */
|
|
|
|
|
|
|
|
/*
|
2001-08-05 12:04:52 -04:00
|
|
|
* Copyright (C) 2001 Havoc Pennington, Anders Carlsson
|
2001-05-30 11:36:31 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-12-09 17:41:12 -05:00
|
|
|
#include <config.h>
|
2001-05-30 11:36:31 -04:00
|
|
|
#include "window.h"
|
|
|
|
#include "util.h"
|
2001-05-31 02:42:58 -04:00
|
|
|
#include "frame.h"
|
|
|
|
#include "errors.h"
|
2001-06-06 00:47:37 -04:00
|
|
|
#include "workspace.h"
|
2001-06-10 14:46:46 -04:00
|
|
|
#include "stack.h"
|
2001-06-23 01:49:35 -04:00
|
|
|
#include "keybindings.h"
|
|
|
|
#include "ui.h"
|
2001-06-24 02:47:54 -04:00
|
|
|
#include "place.h"
|
2001-07-27 00:36:44 -04:00
|
|
|
#include "session.h"
|
2001-08-05 12:04:52 -04:00
|
|
|
#include "effects.h"
|
2001-12-10 02:48:21 -05:00
|
|
|
#include "prefs.h"
|
2002-03-17 12:22:23 -05:00
|
|
|
#include "resizepopup.h"
|
2002-01-03 19:58:39 -05:00
|
|
|
#include "xprops.h"
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
META_IS_CONFIGURE_REQUEST = 1 << 0,
|
|
|
|
META_DO_GRAVITY_ADJUST = 1 << 1,
|
2001-09-10 22:57:05 -04:00
|
|
|
META_USER_MOVE_RESIZE = 1 << 2
|
2001-08-28 23:37:03 -04:00
|
|
|
} MetaMoveResizeFlags;
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
WIN_HINTS_SKIP_FOCUS = (1<<0), /* "alt-tab" skips this win */
|
|
|
|
WIN_HINTS_SKIP_WINLIST = (1<<1), /* not in win list */
|
|
|
|
WIN_HINTS_SKIP_TASKBAR = (1<<2), /* not on taskbar */
|
|
|
|
WIN_HINTS_GROUP_TRANSIENT = (1<<3), /* ??????? */
|
|
|
|
WIN_HINTS_FOCUS_ON_CLICK = (1<<4), /* app only accepts focus when clicked */
|
|
|
|
WIN_HINTS_DO_NOT_COVER = (1<<5) /* attempt to not cover this window */
|
|
|
|
} GnomeWinHints;
|
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
static int destroying_windows_disallowed = 0;
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
static void constrain_size (MetaWindow *window,
|
2001-06-10 23:24:20 -04:00
|
|
|
MetaFrameGeometry *fgeom,
|
2001-06-09 17:58:30 -04:00
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int *new_width,
|
|
|
|
int *new_height);
|
|
|
|
static void constrain_position (MetaWindow *window,
|
|
|
|
MetaFrameGeometry *fgeom,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *new_x,
|
|
|
|
int *new_y);
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
static int update_size_hints (MetaWindow *window);
|
|
|
|
static int update_title (MetaWindow *window);
|
|
|
|
static int update_protocols (MetaWindow *window);
|
|
|
|
static int update_wm_hints (MetaWindow *window);
|
2002-01-03 19:58:39 -05:00
|
|
|
static void update_net_wm_state (MetaWindow *window);
|
|
|
|
static void update_mwm_hints (MetaWindow *window);
|
2001-06-09 17:58:30 -04:00
|
|
|
static int update_wm_class (MetaWindow *window);
|
|
|
|
static int update_transient_for (MetaWindow *window);
|
|
|
|
static void update_sm_hints (MetaWindow *window);
|
2002-01-03 22:25:53 -05:00
|
|
|
static void update_role (MetaWindow *window);
|
|
|
|
static void update_net_wm_type (MetaWindow *window);
|
2001-06-12 20:56:08 -04:00
|
|
|
static int update_initial_workspace (MetaWindow *window);
|
2001-06-23 22:22:10 -04:00
|
|
|
static int update_icon_name (MetaWindow *window);
|
2002-02-09 18:03:52 -05:00
|
|
|
static int update_icon (MetaWindow *window);
|
2002-05-24 04:16:59 -04:00
|
|
|
static void redraw_icon (MetaWindow *window);
|
2002-01-10 01:31:31 -05:00
|
|
|
static void update_struts (MetaWindow *window);
|
2001-06-09 23:17:15 -04:00
|
|
|
static void recalc_window_type (MetaWindow *window);
|
2001-06-23 14:30:27 -04:00
|
|
|
static void recalc_window_features (MetaWindow *window);
|
2002-01-10 01:31:31 -05:00
|
|
|
static void recalc_do_not_cover_struts(MetaWindow *window);
|
|
|
|
static void invalidate_work_areas (MetaWindow *window);
|
2001-06-06 00:47:37 -04:00
|
|
|
static int set_wm_state (MetaWindow *window,
|
|
|
|
int state);
|
2001-06-10 03:52:35 -04:00
|
|
|
static int set_net_wm_state (MetaWindow *window);
|
2001-06-06 00:47:37 -04:00
|
|
|
static void send_configure_notify (MetaWindow *window);
|
|
|
|
static gboolean process_property_notify (MetaWindow *window,
|
|
|
|
XPropertyEvent *event);
|
|
|
|
static void meta_window_show (MetaWindow *window);
|
|
|
|
static void meta_window_hide (MetaWindow *window);
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
static GList* meta_window_get_workspaces (MetaWindow *window);
|
|
|
|
|
2001-08-05 12:04:52 -04:00
|
|
|
static gboolean meta_window_get_icon_geometry (MetaWindow *window,
|
|
|
|
MetaRectangle *rect);
|
|
|
|
|
2001-07-28 02:35:19 -04:00
|
|
|
static void adjust_for_gravity (MetaWindow *window,
|
|
|
|
MetaFrameGeometry *fgeom,
|
|
|
|
gboolean coords_assume_border,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *xp,
|
|
|
|
int *yp);
|
2001-08-28 23:37:03 -04:00
|
|
|
|
|
|
|
static void meta_window_move_resize_internal (MetaWindow *window,
|
|
|
|
MetaMoveResizeFlags flags,
|
|
|
|
int resize_gravity,
|
|
|
|
int root_x_nw,
|
|
|
|
int root_y_nw,
|
|
|
|
int w,
|
|
|
|
int h);
|
2001-07-28 02:35:19 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
void meta_window_move_resize_now (MetaWindow *window);
|
2001-06-23 14:30:27 -04:00
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
static char* get_text_property (MetaDisplay *display,
|
|
|
|
Window xwindow,
|
|
|
|
Atom atom);
|
|
|
|
|
2001-06-21 23:20:21 -04:00
|
|
|
void meta_window_unqueue_calc_showing (MetaWindow *window);
|
2001-10-29 02:00:46 -05:00
|
|
|
void meta_window_flush_calc_showing (MetaWindow *window);
|
2001-06-21 23:20:21 -04:00
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
void meta_window_unqueue_move_resize (MetaWindow *window);
|
|
|
|
void meta_window_flush_move_resize (MetaWindow *window);
|
|
|
|
|
2001-07-27 00:36:44 -04:00
|
|
|
static void meta_window_apply_session_info (MetaWindow *window,
|
|
|
|
const MetaWindowSessionInfo *info);
|
|
|
|
|
2002-03-10 10:48:38 -05:00
|
|
|
static const char*
|
|
|
|
wm_state_to_string (int state)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case NormalState:
|
|
|
|
return "NormalState";
|
|
|
|
case IconicState:
|
|
|
|
return "IconicState";
|
|
|
|
case WithdrawnState:
|
|
|
|
return "WithdrawnState";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
|
2001-05-30 11:36:31 -04:00
|
|
|
MetaWindow*
|
2001-06-11 01:47:51 -04:00
|
|
|
meta_window_new (MetaDisplay *display, Window xwindow,
|
|
|
|
gboolean must_be_viewable)
|
2001-05-30 11:36:31 -04:00
|
|
|
{
|
|
|
|
MetaWindow *window;
|
|
|
|
XWindowAttributes attrs;
|
|
|
|
GSList *tmp;
|
2001-06-12 20:56:08 -04:00
|
|
|
MetaWorkspace *space;
|
2001-06-24 02:47:54 -04:00
|
|
|
gulong existing_wm_state;
|
2002-04-13 00:58:45 -04:00
|
|
|
char *str;
|
|
|
|
unsigned long cardinal;
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-05-31 02:42:58 -04:00
|
|
|
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2002-01-05 22:15:49 -05:00
|
|
|
if (xwindow == display->no_focus_window)
|
|
|
|
{
|
|
|
|
meta_verbose ("Not managing no_focus_window 0x%lx\n",
|
|
|
|
xwindow);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
/* Grab server */
|
|
|
|
meta_display_grab (display);
|
2001-05-31 02:42:58 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (display);
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
XGetWindowAttributes (display->xdisplay,
|
|
|
|
xwindow, &attrs);
|
|
|
|
|
|
|
|
if (meta_error_trap_pop (display))
|
|
|
|
{
|
|
|
|
meta_verbose ("Failed to get attributes for window 0x%lx\n",
|
|
|
|
xwindow);
|
|
|
|
meta_display_ungrab (display);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrs.override_redirect)
|
2001-05-31 02:42:58 -04:00
|
|
|
{
|
2001-06-02 21:33:27 -04:00
|
|
|
meta_verbose ("Deciding not to manage override_redirect window 0x%lx\n", xwindow);
|
2001-06-10 23:24:20 -04:00
|
|
|
meta_display_ungrab (display);
|
2001-05-31 02:42:58 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2002-03-10 10:48:38 -05:00
|
|
|
meta_verbose ("must_be_viewable = %d attrs.map_state = %d (%s)\n",
|
|
|
|
must_be_viewable,
|
2001-08-19 02:23:59 -04:00
|
|
|
attrs.map_state,
|
|
|
|
(attrs.map_state == IsUnmapped) ?
|
|
|
|
"IsUnmapped" :
|
|
|
|
(attrs.map_state == IsViewable) ?
|
|
|
|
"IsViewable" :
|
|
|
|
(attrs.map_state == IsUnviewable) ?
|
|
|
|
"IsUnviewable" :
|
|
|
|
"(unknown)");
|
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
existing_wm_state = WithdrawnState;
|
2001-06-11 01:47:51 -04:00
|
|
|
if (must_be_viewable && attrs.map_state != IsViewable)
|
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
/* Only manage if WM_STATE is IconicState or NormalState */
|
|
|
|
gulong state;
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
/* WM_STATE isn't a cardinal, it's type WM_STATE, but is an int */
|
|
|
|
if (!(meta_prop_get_cardinal_with_atom_type (display, xwindow,
|
|
|
|
display->atom_wm_state,
|
|
|
|
display->atom_wm_state,
|
|
|
|
&state) &&
|
2001-06-23 14:30:27 -04:00
|
|
|
(state == IconicState || state == NormalState)))
|
|
|
|
{
|
|
|
|
meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow);
|
|
|
|
meta_display_ungrab (display);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
existing_wm_state = state;
|
2002-03-10 10:48:38 -05:00
|
|
|
meta_verbose ("WM_STATE of %lx = %s\n", xwindow,
|
|
|
|
wm_state_to_string (existing_wm_state));
|
2001-06-11 01:47:51 -04:00
|
|
|
}
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
meta_error_trap_push (display);
|
2001-05-31 02:42:58 -04:00
|
|
|
|
|
|
|
XAddToSaveSet (display->xdisplay, xwindow);
|
|
|
|
|
|
|
|
XSelectInput (display->xdisplay, xwindow,
|
2001-06-04 00:58:22 -04:00
|
|
|
PropertyChangeMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
FocusChangeMask);
|
|
|
|
|
|
|
|
/* Get rid of any borders */
|
|
|
|
if (attrs.border_width != 0)
|
|
|
|
XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
/* Get rid of weird gravities */
|
|
|
|
if (attrs.win_gravity != NorthWestGravity)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes set_attrs;
|
|
|
|
|
|
|
|
set_attrs.win_gravity = NorthWestGravity;
|
|
|
|
|
|
|
|
XChangeWindowAttributes (display->xdisplay,
|
|
|
|
xwindow,
|
|
|
|
CWWinGravity,
|
|
|
|
&set_attrs);
|
|
|
|
}
|
2001-05-31 02:42:58 -04:00
|
|
|
|
|
|
|
if (meta_error_trap_pop (display) != Success)
|
2001-05-30 11:36:31 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
|
|
|
|
xwindow);
|
2001-06-10 23:24:20 -04:00
|
|
|
meta_display_ungrab (display);
|
2001-05-30 11:36:31 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-06-10 23:24:20 -04:00
|
|
|
|
|
|
|
g_assert (!attrs.override_redirect);
|
2001-05-30 11:36:31 -04:00
|
|
|
|
|
|
|
window = g_new (MetaWindow, 1);
|
|
|
|
|
2002-04-13 00:58:45 -04:00
|
|
|
window->dialog_pid = -1;
|
|
|
|
window->dialog_pipe = -1;
|
|
|
|
|
2001-05-30 11:36:31 -04:00
|
|
|
window->xwindow = xwindow;
|
2001-05-31 02:42:58 -04:00
|
|
|
|
|
|
|
/* this is in window->screen->display, but that's too annoying to
|
|
|
|
* type
|
|
|
|
*/
|
|
|
|
window->display = display;
|
2001-06-06 00:47:37 -04:00
|
|
|
window->workspaces = NULL;
|
2001-05-30 11:36:31 -04:00
|
|
|
|
|
|
|
window->screen = NULL;
|
|
|
|
tmp = display->screens;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
2002-05-27 15:26:56 -04:00
|
|
|
MetaScreen *scr = tmp->data;
|
|
|
|
|
|
|
|
if (scr->xroot == attrs.root)
|
2001-05-30 11:36:31 -04:00
|
|
|
{
|
|
|
|
window->screen = tmp->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (window->screen);
|
2001-06-04 00:58:22 -04:00
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
/* avoid tons of stack updates */
|
|
|
|
meta_stack_freeze (window->screen->stack);
|
|
|
|
|
2001-06-04 00:58:22 -04:00
|
|
|
/* Remember this rect is the actual window size */
|
2001-05-31 02:42:58 -04:00
|
|
|
window->rect.x = attrs.x;
|
|
|
|
window->rect.y = attrs.y;
|
|
|
|
window->rect.width = attrs.width;
|
|
|
|
window->rect.height = attrs.height;
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-09-10 22:57:05 -04:00
|
|
|
window->size_hints.flags = 0;
|
|
|
|
|
2001-06-04 00:58:22 -04:00
|
|
|
/* And border width, size_hints are the "request" */
|
|
|
|
window->border_width = attrs.border_width;
|
2001-06-02 21:33:27 -04:00
|
|
|
window->size_hints.x = attrs.x;
|
|
|
|
window->size_hints.y = attrs.y;
|
|
|
|
window->size_hints.width = attrs.width;
|
|
|
|
window->size_hints.height = attrs.height;
|
2001-06-07 01:18:10 -04:00
|
|
|
|
|
|
|
/* And this is our unmaximized size */
|
|
|
|
window->saved_rect = window->rect;
|
2001-08-28 23:37:03 -04:00
|
|
|
window->user_rect = window->rect;
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-05-31 02:42:58 -04:00
|
|
|
window->depth = attrs.depth;
|
|
|
|
window->xvisual = attrs.visual;
|
2002-05-09 18:34:00 -04:00
|
|
|
window->colormap = attrs.colormap;
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
window->title = NULL;
|
2001-06-23 22:22:10 -04:00
|
|
|
window->icon_name = NULL;
|
|
|
|
window->icon = NULL;
|
2001-09-15 20:30:45 -04:00
|
|
|
window->mini_icon = NULL;
|
2002-02-09 18:03:52 -05:00
|
|
|
meta_icon_cache_init (&window->icon_cache);
|
|
|
|
window->wm_hints_pixmap = None;
|
|
|
|
window->wm_hints_mask = None;
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
window->desc = g_strdup_printf ("0x%lx", window->xwindow);
|
2001-06-02 21:33:27 -04:00
|
|
|
|
|
|
|
window->frame = NULL;
|
2001-06-04 00:58:22 -04:00
|
|
|
window->has_focus = FALSE;
|
2001-06-04 02:17:52 -04:00
|
|
|
|
2001-09-10 22:57:05 -04:00
|
|
|
window->user_has_move_resized = FALSE;
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-06-07 01:18:10 -04:00
|
|
|
window->maximized = FALSE;
|
2002-02-23 17:58:02 -05:00
|
|
|
window->fullscreen = FALSE;
|
2001-06-09 23:17:15 -04:00
|
|
|
window->on_all_workspaces = FALSE;
|
2001-06-07 22:17:48 -04:00
|
|
|
window->shaded = FALSE;
|
2001-06-04 02:17:52 -04:00
|
|
|
window->initially_iconic = FALSE;
|
|
|
|
window->minimized = FALSE;
|
|
|
|
window->iconic = FALSE;
|
2001-06-21 23:20:21 -04:00
|
|
|
window->mapped = attrs.map_state != IsUnmapped;
|
|
|
|
/* if already mapped we don't want to do the placement thing */
|
|
|
|
window->placed = window->mapped;
|
2001-06-24 04:09:10 -04:00
|
|
|
if (window->placed)
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Not placing window 0x%lx since it's already mapped\n",
|
|
|
|
xwindow);
|
2001-06-21 23:20:21 -04:00
|
|
|
window->unmanaging = FALSE;
|
|
|
|
window->calc_showing_queued = FALSE;
|
2002-01-18 22:50:03 -05:00
|
|
|
window->move_resize_queued = FALSE;
|
2001-06-23 01:49:35 -04:00
|
|
|
window->keys_grabbed = FALSE;
|
|
|
|
window->grab_on_frame = FALSE;
|
2001-07-11 02:22:00 -04:00
|
|
|
window->all_keys_grabbed = FALSE;
|
2001-06-23 14:30:27 -04:00
|
|
|
window->withdrawn = FALSE;
|
2001-06-24 02:47:54 -04:00
|
|
|
window->initial_workspace_set = FALSE;
|
2001-06-24 04:09:10 -04:00
|
|
|
window->calc_placement = FALSE;
|
2001-06-21 23:20:21 -04:00
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
window->unmaps_pending = 0;
|
2001-08-19 23:17:40 -04:00
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
window->mwm_decorated = TRUE;
|
|
|
|
window->mwm_has_close_func = TRUE;
|
|
|
|
window->mwm_has_minimize_func = TRUE;
|
|
|
|
window->mwm_has_maximize_func = TRUE;
|
|
|
|
window->mwm_has_move_func = TRUE;
|
|
|
|
window->mwm_has_resize_func = TRUE;
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
window->decorated = TRUE;
|
|
|
|
window->has_close_func = TRUE;
|
|
|
|
window->has_minimize_func = TRUE;
|
|
|
|
window->has_maximize_func = TRUE;
|
2001-06-23 14:30:27 -04:00
|
|
|
window->has_move_func = TRUE;
|
|
|
|
window->has_resize_func = TRUE;
|
|
|
|
|
2001-06-23 02:54:28 -04:00
|
|
|
window->has_shade_func = TRUE;
|
2002-02-23 17:58:02 -05:00
|
|
|
|
|
|
|
window->has_fullscreen_func = TRUE;
|
2001-06-23 02:54:28 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
window->wm_state_modal = FALSE;
|
2001-06-11 01:47:51 -04:00
|
|
|
window->wm_state_skip_taskbar = FALSE;
|
|
|
|
window->wm_state_skip_pager = FALSE;
|
2001-06-09 23:17:15 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
window->res_class = NULL;
|
|
|
|
window->res_name = NULL;
|
|
|
|
window->role = NULL;
|
|
|
|
window->sm_client_id = NULL;
|
2002-04-13 00:58:45 -04:00
|
|
|
window->wm_client_machine = NULL;
|
|
|
|
|
|
|
|
window->net_wm_pid = -1;
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
window->xtransient_for = None;
|
|
|
|
window->xgroup_leader = None;
|
|
|
|
window->xclient_leader = None;
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
window->type = META_WINDOW_NORMAL;
|
|
|
|
window->type_atom = None;
|
2001-06-10 03:27:11 -04:00
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
window->has_struts = FALSE;
|
2002-06-08 02:29:19 -04:00
|
|
|
window->do_not_cover = FALSE;
|
2002-01-10 01:31:31 -05:00
|
|
|
window->left_strut = 0;
|
|
|
|
window->right_strut = 0;
|
|
|
|
window->top_strut = 0;
|
|
|
|
window->bottom_strut = 0;
|
|
|
|
|
2001-06-10 03:27:11 -04:00
|
|
|
window->layer = META_LAYER_NORMAL;
|
|
|
|
window->stack_op = NULL;
|
2001-06-24 02:47:54 -04:00
|
|
|
window->initial_workspace = 0; /* not used */
|
2001-05-31 02:42:58 -04:00
|
|
|
meta_display_register_x_window (display, &window->xwindow, window);
|
2001-05-30 11:36:31 -04:00
|
|
|
|
2002-04-13 00:58:45 -04:00
|
|
|
if (meta_prop_get_latin1_string (window->display, window->xwindow,
|
|
|
|
window->display->atom_wm_client_machine,
|
|
|
|
&str))
|
|
|
|
{
|
|
|
|
window->wm_client_machine = g_strdup (str);
|
|
|
|
meta_XFree (str);
|
|
|
|
|
|
|
|
meta_verbose ("Window has client machine \"%s\"\n",
|
|
|
|
window->wm_client_machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (meta_prop_get_cardinal (window->display, window->xwindow,
|
|
|
|
window->display->atom_net_wm_pid,
|
|
|
|
&cardinal))
|
|
|
|
{
|
|
|
|
if (cardinal <= 0)
|
|
|
|
meta_warning (_("Application set a bogus _NET_WM_PID %ld\n"),
|
|
|
|
cardinal);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->net_wm_pid = cardinal;
|
|
|
|
meta_verbose ("Window has _NET_WM_PID %d\n",
|
|
|
|
window->net_wm_pid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
update_size_hints (window);
|
|
|
|
update_title (window);
|
2001-08-19 21:42:44 -04:00
|
|
|
update_protocols (window);
|
2001-06-04 00:58:22 -04:00
|
|
|
update_wm_hints (window);
|
2002-01-10 01:31:31 -05:00
|
|
|
update_struts (window);
|
2001-10-14 18:13:53 -04:00
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
update_net_wm_state (window);
|
2001-10-14 18:13:53 -04:00
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
update_mwm_hints (window);
|
2001-06-09 17:58:30 -04:00
|
|
|
update_wm_class (window);
|
|
|
|
update_transient_for (window);
|
|
|
|
update_sm_hints (window); /* must come after transient_for */
|
|
|
|
update_role (window);
|
2001-06-09 23:17:15 -04:00
|
|
|
update_net_wm_type (window);
|
2001-06-12 20:56:08 -04:00
|
|
|
update_initial_workspace (window);
|
2001-06-23 22:22:10 -04:00
|
|
|
update_icon_name (window);
|
2002-02-09 18:03:52 -05:00
|
|
|
update_icon (window);
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2001-06-04 02:17:52 -04:00
|
|
|
if (window->initially_iconic)
|
|
|
|
{
|
2001-06-06 00:47:37 -04:00
|
|
|
/* WM_HINTS said minimized */
|
|
|
|
window->minimized = TRUE;
|
|
|
|
meta_verbose ("Window %s asked to start out minimized\n", window->desc);
|
2001-06-04 02:17:52 -04:00
|
|
|
}
|
2001-06-24 02:47:54 -04:00
|
|
|
|
|
|
|
if (existing_wm_state == IconicState)
|
|
|
|
{
|
|
|
|
/* WM_STATE said minimized */
|
|
|
|
window->minimized = TRUE;
|
|
|
|
meta_verbose ("Window %s had preexisting WM_STATE = IconicState, minimizing\n",
|
|
|
|
window->desc);
|
|
|
|
|
|
|
|
/* Assume window was previously placed, though perhaps it's
|
|
|
|
* been iconic its whole life, we have no way of knowing.
|
|
|
|
*/
|
|
|
|
window->placed = TRUE;
|
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
/* FIXME we have a tendency to set this then immediately
|
|
|
|
* change it again.
|
|
|
|
*/
|
|
|
|
set_wm_state (window, window->iconic ? IconicState : NormalState);
|
2001-06-10 23:24:20 -04:00
|
|
|
set_net_wm_state (window);
|
2001-06-23 01:49:35 -04:00
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
if (window->decorated)
|
|
|
|
meta_window_ensure_frame (window);
|
2001-06-04 02:17:52 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
meta_window_grab_keys (window);
|
2001-07-25 22:55:35 -04:00
|
|
|
meta_display_grab_window_buttons (window->display, window->xwindow);
|
2001-12-10 23:03:58 -05:00
|
|
|
meta_display_grab_focus_window_button (window->display, window->xwindow);
|
2001-07-25 22:55:35 -04:00
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
/* For the workspace, first honor hints,
|
|
|
|
* if that fails put transients with parents,
|
|
|
|
* otherwise put window on active space
|
|
|
|
*/
|
2001-06-12 20:56:08 -04:00
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
if (window->initial_workspace_set)
|
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
if (window->initial_workspace == (int) 0xFFFFFFFF)
|
2001-10-24 21:39:36 -04:00
|
|
|
{
|
2002-03-03 23:54:46 -05:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Window %s is initially on all spaces\n",
|
|
|
|
window->desc);
|
|
|
|
|
2001-10-24 21:39:36 -04:00
|
|
|
meta_workspace_add_window (window->screen->active_workspace, window);
|
|
|
|
window->on_all_workspaces = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-03-03 23:54:46 -05:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Window %s is initially on space %d\n",
|
|
|
|
window->desc, window->initial_workspace);
|
|
|
|
|
2001-10-24 21:39:36 -04:00
|
|
|
space =
|
|
|
|
meta_display_get_workspace_by_screen_index (window->display,
|
|
|
|
window->screen,
|
|
|
|
window->initial_workspace);
|
|
|
|
|
|
|
|
if (space)
|
|
|
|
meta_workspace_add_window (space, window);
|
|
|
|
}
|
2001-06-24 02:47:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (window->workspaces == NULL &&
|
|
|
|
window->xtransient_for != None)
|
|
|
|
{
|
|
|
|
/* Try putting dialog on parent's workspace */
|
|
|
|
MetaWindow *parent;
|
|
|
|
|
|
|
|
parent = meta_display_lookup_x_window (window->display,
|
|
|
|
window->xtransient_for);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
GList *tmp_list;
|
2002-03-03 23:54:46 -05:00
|
|
|
|
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Putting window %s on some workspaces as parent %s\n",
|
|
|
|
window->desc, parent->desc);
|
2001-06-24 02:47:54 -04:00
|
|
|
|
|
|
|
if (parent->on_all_workspaces)
|
|
|
|
window->on_all_workspaces = TRUE;
|
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
tmp_list = parent->workspaces;
|
|
|
|
while (tmp_list != NULL)
|
2001-06-24 02:47:54 -04:00
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
meta_workspace_add_window (tmp_list->data, window);
|
2001-06-24 02:47:54 -04:00
|
|
|
|
2002-02-06 22:07:56 -05:00
|
|
|
tmp_list = tmp_list->next;
|
2001-06-24 02:47:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->workspaces == NULL)
|
|
|
|
{
|
2002-03-03 23:54:46 -05:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Putting window %s on active workspace\n",
|
|
|
|
window->desc);
|
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
space = window->screen->active_workspace;
|
|
|
|
|
|
|
|
meta_workspace_add_window (space, window);
|
|
|
|
}
|
2001-08-25 22:09:53 -04:00
|
|
|
|
2001-06-23 02:54:28 -04:00
|
|
|
if (window->type == META_WINDOW_DESKTOP ||
|
|
|
|
window->type == META_WINDOW_DOCK)
|
|
|
|
{
|
2001-06-24 02:47:54 -04:00
|
|
|
/* Change the default, but don't enforce this if
|
|
|
|
* the user focuses the dock/desktop and unsticks it
|
|
|
|
* using key shortcuts
|
|
|
|
*/
|
2001-06-23 02:54:28 -04:00
|
|
|
window->on_all_workspaces = TRUE;
|
|
|
|
}
|
2001-10-25 23:54:55 -04:00
|
|
|
|
|
|
|
/* for the various on_all_workspaces = TRUE possible above */
|
|
|
|
meta_window_set_current_workspace_hint (window);
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* Put our state back where it should be,
|
|
|
|
* passing TRUE for is_configure_request, ICCCM says
|
|
|
|
* initial map is handled same as configure request
|
|
|
|
*/
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize_internal (window,
|
|
|
|
META_IS_CONFIGURE_REQUEST,
|
2001-06-30 19:17:52 -04:00
|
|
|
NorthWestGravity,
|
2001-06-09 17:58:30 -04:00
|
|
|
window->size_hints.x,
|
|
|
|
window->size_hints.y,
|
|
|
|
window->size_hints.width,
|
|
|
|
window->size_hints.height);
|
|
|
|
|
2002-03-11 23:34:17 -05:00
|
|
|
/* add to MRU list */
|
|
|
|
window->display->mru_list =
|
|
|
|
g_list_append (window->display->mru_list, window);
|
|
|
|
|
2001-06-10 14:46:46 -04:00
|
|
|
meta_stack_add (window->screen->stack,
|
|
|
|
window);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-07-27 00:36:44 -04:00
|
|
|
/* Now try applying saved stuff from the session */
|
|
|
|
{
|
|
|
|
const MetaWindowSessionInfo *info;
|
|
|
|
|
|
|
|
info = meta_window_lookup_saved_state (window);
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
meta_window_apply_session_info (window, info);
|
|
|
|
meta_window_release_saved_state (info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
/* Sync stack changes */
|
|
|
|
meta_stack_thaw (window->screen->stack);
|
2002-05-11 01:47:04 -04:00
|
|
|
|
|
|
|
/* disable show desktop mode unless we're a desktop component */
|
|
|
|
if (window->display->showing_desktop &&
|
|
|
|
window->type != META_WINDOW_DESKTOP &&
|
|
|
|
window->type != META_WINDOW_DOCK)
|
|
|
|
meta_display_unshow_desktop (window->display);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
meta_window_queue_calc_showing (window);
|
2002-05-11 01:47:04 -04:00
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
meta_display_ungrab (display);
|
2001-05-31 02:42:58 -04:00
|
|
|
|
2001-05-30 11:36:31 -04:00
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2001-07-27 00:36:44 -04:00
|
|
|
/* This function should only be called from the end of meta_window_new () */
|
|
|
|
static void
|
|
|
|
meta_window_apply_session_info (MetaWindow *window,
|
|
|
|
const MetaWindowSessionInfo *info)
|
|
|
|
{
|
|
|
|
if (info->on_all_workspaces_set)
|
|
|
|
{
|
|
|
|
window->on_all_workspaces = info->on_all_workspaces;
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring sticky state %d for window %s\n",
|
|
|
|
window->on_all_workspaces, window->desc);
|
2001-07-27 00:36:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (info->workspace_indices)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
GSList *spaces;
|
|
|
|
|
|
|
|
spaces = NULL;
|
|
|
|
|
|
|
|
tmp = info->workspace_indices;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWorkspace *space;
|
|
|
|
|
|
|
|
space =
|
|
|
|
meta_display_get_workspace_by_screen_index (window->display,
|
|
|
|
window->screen,
|
|
|
|
GPOINTER_TO_INT (tmp->data));
|
|
|
|
|
|
|
|
if (space)
|
|
|
|
spaces = g_slist_prepend (spaces, space);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spaces)
|
|
|
|
{
|
|
|
|
/* This briefly breaks the invariant that we are supposed
|
|
|
|
* to always be on some workspace. But we paranoically
|
|
|
|
* ensured that one of the workspaces from the session was
|
|
|
|
* indeed valid, so we know we'll go right back to one.
|
|
|
|
*/
|
|
|
|
while (window->workspaces)
|
2001-07-28 02:35:19 -04:00
|
|
|
meta_workspace_remove_window (window->workspaces->data, window);
|
2001-07-27 00:36:44 -04:00
|
|
|
|
|
|
|
tmp = spaces;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWorkspace *space;
|
|
|
|
|
|
|
|
space = tmp->data;
|
|
|
|
|
|
|
|
meta_workspace_add_window (space, window);
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring saved window %s to workspace %d\n",
|
|
|
|
window->desc,
|
|
|
|
meta_workspace_screen_index (space));
|
2001-07-27 00:36:44 -04:00
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (spaces);
|
|
|
|
}
|
|
|
|
}
|
2001-07-28 02:35:19 -04:00
|
|
|
|
|
|
|
if (info->geometry_set)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
|
|
|
|
window->placed = TRUE; /* don't do placement algorithms later */
|
|
|
|
|
|
|
|
x = info->rect.x;
|
|
|
|
y = info->rect.y;
|
|
|
|
|
|
|
|
w = window->size_hints.base_width +
|
|
|
|
info->rect.width * window->size_hints.width_inc;
|
|
|
|
h = window->size_hints.base_height +
|
|
|
|
info->rect.height * window->size_hints.height_inc;
|
|
|
|
|
|
|
|
/* Force old gravity, ignoring anything now set */
|
|
|
|
window->size_hints.win_gravity = info->gravity;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_SM,
|
|
|
|
"Restoring pos %d,%d size %d x %d for %s\n",
|
|
|
|
x, y, w, h, window->desc);
|
2001-07-28 02:35:19 -04:00
|
|
|
|
|
|
|
meta_window_move_resize_internal (window,
|
2001-08-28 23:37:03 -04:00
|
|
|
META_DO_GRAVITY_ADJUST,
|
2001-07-28 02:35:19 -04:00
|
|
|
NorthWestGravity,
|
|
|
|
x, y, w, h);
|
|
|
|
}
|
2001-07-27 00:36:44 -04:00
|
|
|
}
|
|
|
|
|
2001-05-30 11:36:31 -04:00
|
|
|
void
|
|
|
|
meta_window_free (MetaWindow *window)
|
|
|
|
{
|
2001-06-06 00:47:37 -04:00
|
|
|
GList *tmp;
|
|
|
|
|
2001-05-31 02:42:58 -04:00
|
|
|
meta_verbose ("Unmanaging 0x%lx\n", window->xwindow);
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
if (destroying_windows_disallowed > 0)
|
|
|
|
meta_bug ("Tried to destroy window %s while destruction was not allowed\n",
|
|
|
|
window->desc);
|
|
|
|
|
2001-06-21 23:20:21 -04:00
|
|
|
window->unmanaging = TRUE;
|
2002-01-03 18:28:19 -05:00
|
|
|
|
|
|
|
/* If we have the focus, focus some other window.
|
|
|
|
* This is done first, so that if the unmap causes
|
|
|
|
* an EnterNotify the EnterNotify will have final say
|
|
|
|
* on what gets focused, maintaining sloppy focus
|
|
|
|
* invariants.
|
|
|
|
*/
|
|
|
|
if (window->has_focus)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing top window since we're unmanaging %s\n",
|
|
|
|
window->desc);
|
|
|
|
meta_screen_focus_top_window (window->screen, window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Unmanaging window %s which doesn't currently have focus\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
2002-01-10 22:31:14 -05:00
|
|
|
|
|
|
|
if (window->has_struts)
|
2002-02-07 22:34:26 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Unmanaging window %s which has struts, so invalidating work areas\n",
|
|
|
|
window->desc);
|
|
|
|
invalidate_work_areas (window);
|
|
|
|
}
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2001-07-11 02:22:00 -04:00
|
|
|
if (window->display->grab_window == window)
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_display_end_grab_op (window->display,
|
|
|
|
meta_display_get_current_time (window->display));
|
2002-03-06 17:27:24 -05:00
|
|
|
|
|
|
|
g_assert (window->display->grab_window != window);
|
2001-07-11 02:22:00 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
if (window->display->focus_window == window)
|
|
|
|
window->display->focus_window = NULL;
|
2001-06-23 23:18:10 -04:00
|
|
|
|
2002-03-11 23:34:17 -05:00
|
|
|
window->display->mru_list =
|
|
|
|
g_list_remove (window->display->mru_list, window);
|
2001-06-21 23:20:21 -04:00
|
|
|
|
|
|
|
meta_window_unqueue_calc_showing (window);
|
2002-01-18 22:50:03 -05:00
|
|
|
meta_window_unqueue_move_resize (window);
|
2002-04-13 00:58:45 -04:00
|
|
|
meta_window_free_delete_dialog (window);
|
2001-06-21 23:20:21 -04:00
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
tmp = window->workspaces;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
GList *next;
|
|
|
|
|
|
|
|
next = tmp->next;
|
|
|
|
|
|
|
|
/* pops front of list */
|
|
|
|
meta_workspace_remove_window (tmp->data, window);
|
|
|
|
|
|
|
|
tmp = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (window->workspaces == NULL);
|
2001-06-07 01:18:10 -04:00
|
|
|
|
2001-06-10 14:46:46 -04:00
|
|
|
meta_stack_remove (window->screen->stack, window);
|
|
|
|
|
2001-06-07 01:18:10 -04:00
|
|
|
/* FIXME restore original size if window has maximized */
|
2001-06-23 01:49:35 -04:00
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
if (window->withdrawn)
|
2002-03-10 10:48:38 -05:00
|
|
|
{
|
|
|
|
/* We need to clean off the window's state so it
|
|
|
|
* won't be restored if the app maps it again.
|
|
|
|
*/
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
meta_verbose ("Cleaning state from window %s\n", window->desc);
|
|
|
|
XDeleteProperty (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_net_wm_desktop);
|
|
|
|
XDeleteProperty (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_net_wm_state);
|
|
|
|
set_wm_state (window, WithdrawnState);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We need to put WM_STATE so that others will understand it on
|
|
|
|
* restart.
|
|
|
|
*/
|
|
|
|
if (!window->minimized)
|
|
|
|
{
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
set_wm_state (window, NormalState);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
}
|
2001-06-23 14:30:27 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
if (window->frame)
|
|
|
|
meta_window_destroy_frame (window);
|
2001-05-31 23:00:01 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
meta_window_ungrab_keys (window);
|
2001-07-25 22:55:35 -04:00
|
|
|
meta_display_ungrab_window_buttons (window->display, window->xwindow);
|
2001-12-10 23:03:58 -05:00
|
|
|
meta_display_ungrab_focus_window_button (window->display, window->xwindow);
|
2001-07-25 22:55:35 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
meta_display_unregister_x_window (window->display, window->xwindow);
|
|
|
|
|
2002-03-27 22:49:18 -05:00
|
|
|
|
2001-06-04 02:17:52 -04:00
|
|
|
meta_error_trap_push (window->display);
|
2002-03-27 22:49:18 -05:00
|
|
|
|
|
|
|
/* Put back anything we messed up */
|
2001-06-04 02:17:52 -04:00
|
|
|
if (window->border_width != 0)
|
|
|
|
XSetWindowBorderWidth (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
window->border_width);
|
2002-03-27 22:49:18 -05:00
|
|
|
|
|
|
|
/* No save set */
|
|
|
|
XRemoveFromSaveSet (window->display->xdisplay,
|
|
|
|
window->xwindow);
|
|
|
|
|
|
|
|
/* Don't get events on not-managed windows */
|
|
|
|
XSelectInput (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
NoEventMask);
|
2001-06-04 02:17:52 -04:00
|
|
|
|
|
|
|
meta_error_trap_pop (window->display);
|
2001-06-12 00:38:24 -04:00
|
|
|
|
2001-08-19 14:09:10 -04:00
|
|
|
if (window->icon)
|
|
|
|
g_object_unref (G_OBJECT (window->icon));
|
2001-09-15 20:30:45 -04:00
|
|
|
|
|
|
|
if (window->mini_icon)
|
|
|
|
g_object_unref (G_OBJECT (window->mini_icon));
|
2002-02-09 18:03:52 -05:00
|
|
|
|
|
|
|
meta_icon_cache_free (&window->icon_cache);
|
2001-08-19 14:09:10 -04:00
|
|
|
|
2001-06-12 00:38:24 -04:00
|
|
|
g_free (window->sm_client_id);
|
2002-04-13 00:58:45 -04:00
|
|
|
g_free (window->wm_client_machine);
|
2001-06-12 00:38:24 -04:00
|
|
|
g_free (window->role);
|
|
|
|
g_free (window->res_class);
|
|
|
|
g_free (window->res_name);
|
2001-06-02 21:33:27 -04:00
|
|
|
g_free (window->title);
|
2001-06-23 22:22:10 -04:00
|
|
|
g_free (window->icon_name);
|
2001-06-02 21:33:27 -04:00
|
|
|
g_free (window->desc);
|
2001-05-30 11:36:31 -04:00
|
|
|
g_free (window);
|
|
|
|
}
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
static int
|
|
|
|
set_wm_state (MetaWindow *window,
|
|
|
|
int state)
|
|
|
|
{
|
2001-06-10 23:24:20 -04:00
|
|
|
unsigned long data[2];
|
2002-03-10 10:48:38 -05:00
|
|
|
|
|
|
|
meta_verbose ("Setting wm state %s on %s\n",
|
|
|
|
wm_state_to_string (state), window->desc);
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
/* twm sets the icon window as data[1], I couldn't find that in
|
|
|
|
* ICCCM.
|
|
|
|
*/
|
|
|
|
data[0] = state;
|
2001-06-10 23:24:20 -04:00
|
|
|
data[1] = None;
|
2001-06-06 00:47:37 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XChangeProperty (window->display->xdisplay, window->xwindow,
|
|
|
|
window->display->atom_wm_state,
|
|
|
|
window->display->atom_wm_state,
|
2001-06-10 23:24:20 -04:00
|
|
|
32, PropModeReplace, (guchar*) data, 2);
|
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
set_net_wm_state (MetaWindow *window)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned long data[10];
|
2001-06-11 01:47:51 -04:00
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
i = 0;
|
|
|
|
if (window->shaded)
|
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_shaded;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (window->wm_state_modal)
|
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_modal;
|
|
|
|
++i;
|
|
|
|
}
|
2002-02-08 23:15:41 -05:00
|
|
|
if (window->wm_state_skip_pager)
|
2001-06-11 01:47:51 -04:00
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_skip_pager;
|
|
|
|
++i;
|
|
|
|
}
|
2002-02-08 23:15:41 -05:00
|
|
|
if (window->wm_state_skip_taskbar)
|
2001-06-11 01:47:51 -04:00
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_skip_taskbar;
|
|
|
|
++i;
|
|
|
|
}
|
2001-06-10 23:24:20 -04:00
|
|
|
if (window->maximized)
|
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_maximized_horz;
|
|
|
|
++i;
|
|
|
|
data[i] = window->display->atom_net_wm_state_maximized_vert;
|
|
|
|
++i;
|
|
|
|
}
|
2002-02-23 17:58:02 -05:00
|
|
|
if (window->fullscreen)
|
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_fullscreen;
|
|
|
|
++i;
|
|
|
|
}
|
2002-02-08 23:50:58 -05:00
|
|
|
if (window->shaded || window->minimized)
|
|
|
|
{
|
|
|
|
data[i] = window->display->atom_net_wm_state_hidden;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
meta_verbose ("Setting _NET_WM_STATE with %d atoms\n", i);
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XChangeProperty (window->display->xdisplay, window->xwindow,
|
|
|
|
window->display->atom_net_wm_state,
|
|
|
|
XA_ATOM,
|
|
|
|
32, PropModeReplace, (guchar*) data, i);
|
2001-06-06 00:47:37 -04:00
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-10-25 00:51:25 -04:00
|
|
|
gboolean
|
|
|
|
meta_window_visible_on_workspace (MetaWindow *window,
|
|
|
|
MetaWorkspace *workspace)
|
|
|
|
{
|
|
|
|
return window->on_all_workspaces ||
|
|
|
|
meta_workspace_contains_window (workspace, window);
|
|
|
|
}
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
void
|
|
|
|
meta_window_calc_showing (MetaWindow *window)
|
|
|
|
{
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
gboolean showing, on_workspace;
|
2001-07-03 22:10:54 -04:00
|
|
|
|
|
|
|
meta_verbose ("Calc showing for window %s\n", window->desc);
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
|
|
|
|
/* 1. See if we're on the workspace */
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2001-10-25 00:51:25 -04:00
|
|
|
on_workspace = meta_window_visible_on_workspace (window,
|
|
|
|
window->screen->active_workspace);
|
2001-06-06 00:47:37 -04:00
|
|
|
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
showing = on_workspace;
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
if (!on_workspace)
|
|
|
|
meta_verbose ("Window %s is not on workspace %d\n",
|
|
|
|
window->desc,
|
|
|
|
meta_workspace_index (window->screen->active_workspace));
|
|
|
|
else
|
|
|
|
meta_verbose ("Window %s is on the active workspace %d\n",
|
|
|
|
window->desc,
|
|
|
|
meta_workspace_index (window->screen->active_workspace));
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
if (window->on_all_workspaces)
|
2001-10-25 00:51:25 -04:00
|
|
|
meta_verbose ("Window %s is on all workspaces\n", window->desc);
|
2001-10-14 23:39:41 -04:00
|
|
|
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
/* 2. See if we're minimized */
|
|
|
|
if (window->minimized)
|
|
|
|
showing = FALSE;
|
|
|
|
|
|
|
|
/* 3. See if we're in "show desktop" mode */
|
|
|
|
|
|
|
|
if (showing &&
|
2001-10-14 23:39:41 -04:00
|
|
|
window->display->showing_desktop &&
|
|
|
|
window->type != META_WINDOW_DESKTOP &&
|
|
|
|
window->type != META_WINDOW_DOCK)
|
|
|
|
{
|
|
|
|
meta_verbose ("Window %s is on current workspace, but we're showing the desktop\n",
|
|
|
|
window->desc);
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
showing = FALSE;
|
2001-10-14 23:39:41 -04:00
|
|
|
}
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
|
|
|
|
/* 4. See if an ancestor is minimized (note that
|
|
|
|
* ancestor's "mapped" field may not be up to date
|
|
|
|
* since it's being computed in this same idle queue)
|
|
|
|
*/
|
2001-06-06 00:47:37 -04:00
|
|
|
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
if (showing)
|
|
|
|
{
|
|
|
|
MetaWindow *w;
|
|
|
|
|
|
|
|
w = window;
|
|
|
|
while (w != NULL)
|
|
|
|
{
|
|
|
|
if (w->minimized)
|
|
|
|
{
|
|
|
|
showing = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w->xtransient_for == None)
|
|
|
|
break;
|
|
|
|
|
|
|
|
w = meta_display_lookup_x_window (w->display, w->xtransient_for);
|
|
|
|
|
|
|
|
if (w == window)
|
|
|
|
break; /* Cute, someone thought they'd make a transient_for cycle */
|
|
|
|
|
|
|
|
/* w may be null... */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Actually show/hide the window */
|
|
|
|
|
|
|
|
if (!showing)
|
2001-06-06 00:47:37 -04:00
|
|
|
{
|
2001-08-05 12:04:52 -04:00
|
|
|
/* Really this effects code should probably
|
|
|
|
* be in meta_window_hide so the window->mapped
|
|
|
|
* test isn't duplicated here. Anyhow, we animate
|
|
|
|
* if we are mapped now, we are supposed to
|
|
|
|
* be minimized, and we are on the current workspace.
|
|
|
|
*/
|
|
|
|
if (on_workspace && window->minimized && window->mapped)
|
|
|
|
{
|
|
|
|
MetaRectangle icon_rect, window_rect;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
/* Check if the window has an icon geometry */
|
|
|
|
result = meta_window_get_icon_geometry (window, &icon_rect);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
/* just animate into the corner somehow - maybe
|
|
|
|
* not a good idea...
|
|
|
|
*/
|
|
|
|
icon_rect.x = window->screen->width;
|
|
|
|
icon_rect.y = window->screen->height;
|
|
|
|
icon_rect.width = 1;
|
|
|
|
icon_rect.height = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_get_outer_rect (window, &window_rect);
|
|
|
|
|
|
|
|
/* Draw a nice cool animation */
|
|
|
|
meta_effects_draw_box_animation (window->screen,
|
|
|
|
&window_rect,
|
|
|
|
&icon_rect,
|
2002-03-05 00:05:00 -05:00
|
|
|
META_MINIMIZE_ANIMATION_LENGTH,
|
|
|
|
META_BOX_ANIM_SCALE);
|
2001-08-05 12:04:52 -04:00
|
|
|
}
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
meta_window_hide (window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_window_show (window);
|
|
|
|
}
|
|
|
|
}
|
2001-06-21 23:20:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
static guint calc_showing_idle = 0;
|
|
|
|
static GSList *calc_showing_pending = NULL;
|
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
static int
|
|
|
|
stackcmp (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
MetaWindow *aw = (gpointer) a;
|
|
|
|
MetaWindow *bw = (gpointer) b;
|
|
|
|
|
|
|
|
if (aw->screen != bw->screen)
|
|
|
|
return 0; /* don't care how they sort with respect to each other */
|
|
|
|
else
|
|
|
|
return meta_stack_windows_cmp (aw->screen->stack,
|
|
|
|
aw, bw);
|
|
|
|
}
|
|
|
|
|
2001-06-21 23:20:21 -04:00
|
|
|
static gboolean
|
|
|
|
idle_calc_showing (gpointer data)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
2001-10-29 21:00:53 -05:00
|
|
|
GSList *copy;
|
2001-06-21 23:20:21 -04:00
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Clearing the calc_showing queue\n");
|
2001-10-29 21:00:53 -05:00
|
|
|
|
|
|
|
/* Work with a copy, for reentrancy. The allowed reentrancy isn't
|
|
|
|
* complete; destroying a window while we're in here would result in
|
|
|
|
* badness. But it's OK to queue/unqueue calc_showings.
|
|
|
|
*/
|
|
|
|
copy = g_slist_copy (calc_showing_pending);
|
|
|
|
g_slist_free (calc_showing_pending);
|
|
|
|
calc_showing_pending = NULL;
|
|
|
|
calc_showing_idle = 0;
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
destroying_windows_disallowed += 1;
|
2001-07-03 22:10:54 -04:00
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
/* sort them from bottom to top, so we map the
|
|
|
|
* bottom windows first, so that placement (e.g. cascading)
|
|
|
|
* works properly
|
|
|
|
*/
|
2001-10-29 21:00:53 -05:00
|
|
|
copy = g_slist_sort (copy, stackcmp);
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2001-10-29 21:00:53 -05:00
|
|
|
tmp = copy;
|
2001-06-21 23:20:21 -04:00
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *window;
|
|
|
|
|
|
|
|
window = tmp->data;
|
|
|
|
|
|
|
|
meta_window_calc_showing (window);
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
/* important to set this here for reentrancy -
|
|
|
|
* if we queue a window again while it's in "copy",
|
|
|
|
* then queue_calc_showing will just return since
|
|
|
|
* calc_showing_queued = TRUE still
|
|
|
|
*/
|
2001-06-21 23:20:21 -04:00
|
|
|
window->calc_showing_queued = FALSE;
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
2001-10-29 21:00:53 -05:00
|
|
|
g_slist_free (copy);
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
destroying_windows_disallowed -= 1;
|
2001-06-21 23:20:21 -04:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_unqueue_calc_showing (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (!window->calc_showing_queued)
|
|
|
|
return;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Removing %s from the calc_showing queue\n",
|
|
|
|
window->desc);
|
2001-10-29 21:00:53 -05:00
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
/* Note that window may not actually be in move_resize_pending
|
|
|
|
* because it may have been in "copy" inside the idle handler
|
|
|
|
*/
|
2001-06-21 23:20:21 -04:00
|
|
|
calc_showing_pending = g_slist_remove (calc_showing_pending, window);
|
|
|
|
window->calc_showing_queued = FALSE;
|
|
|
|
|
|
|
|
if (calc_showing_pending == NULL &&
|
|
|
|
calc_showing_idle != 0)
|
|
|
|
{
|
|
|
|
g_source_remove (calc_showing_idle);
|
|
|
|
calc_showing_idle = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-29 02:00:46 -05:00
|
|
|
void
|
|
|
|
meta_window_flush_calc_showing (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->calc_showing_queued)
|
|
|
|
{
|
|
|
|
meta_window_unqueue_calc_showing (window);
|
|
|
|
meta_window_calc_showing (window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
void
|
|
|
|
meta_window_queue_calc_showing (MetaWindow *window)
|
|
|
|
{
|
2002-03-10 10:48:38 -05:00
|
|
|
/* if withdrawn = TRUE then unmanaging should also be TRUE,
|
|
|
|
* really.
|
|
|
|
*/
|
|
|
|
if (window->unmanaging || window->withdrawn)
|
2001-06-21 23:20:21 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (window->calc_showing_queued)
|
|
|
|
return;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Putting %s in the calc_showing queue\n",
|
|
|
|
window->desc);
|
2001-06-21 23:20:21 -04:00
|
|
|
|
|
|
|
window->calc_showing_queued = TRUE;
|
|
|
|
|
|
|
|
if (calc_showing_idle == 0)
|
|
|
|
calc_showing_idle = g_idle_add (idle_calc_showing, NULL);
|
|
|
|
|
|
|
|
calc_showing_pending = g_slist_prepend (calc_showing_pending, window);
|
2001-06-06 00:47:37 -04:00
|
|
|
}
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
void
|
|
|
|
meta_window_show (MetaWindow *window)
|
|
|
|
{
|
2001-10-29 21:00:53 -05:00
|
|
|
gboolean did_placement;
|
2002-02-08 01:01:58 -05:00
|
|
|
gboolean did_show;
|
2001-10-29 21:00:53 -05:00
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Showing window %s, shaded: %d iconic: %d placed: %d\n",
|
|
|
|
window->desc, window->shaded, window->iconic, window->placed);
|
2001-06-07 22:17:48 -04:00
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
did_show = FALSE;
|
2001-10-29 21:00:53 -05:00
|
|
|
did_placement = FALSE;
|
2001-06-24 04:09:10 -04:00
|
|
|
if (!window->placed)
|
|
|
|
{
|
|
|
|
/* We have to recalc the placement here since other windows may
|
|
|
|
* have been mapped/placed since we last did constrain_position
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* calc_placement is an efficiency hack to avoid
|
|
|
|
* multiple placement calculations before we finally
|
|
|
|
* show the window.
|
|
|
|
*/
|
|
|
|
window->calc_placement = TRUE;
|
|
|
|
meta_window_move_resize_now (window);
|
|
|
|
window->calc_placement = FALSE;
|
|
|
|
|
|
|
|
/* don't ever do the initial position constraint thing again.
|
|
|
|
* This is toggled here so that initially-iconified windows
|
|
|
|
* still get placed when they are ultimately shown.
|
|
|
|
*/
|
2001-10-29 21:00:53 -05:00
|
|
|
window->placed = TRUE;
|
|
|
|
did_placement = TRUE;
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
2001-06-21 23:20:21 -04:00
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
/* Shaded means the frame is mapped but the window is not */
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
if (window->frame && !window->frame->mapped)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Frame actually needs map\n");
|
2001-06-09 23:17:15 -04:00
|
|
|
window->frame->mapped = TRUE;
|
2001-06-19 23:01:26 -04:00
|
|
|
meta_ui_map_frame (window->screen->ui, window->frame->xwindow);
|
2002-02-08 23:50:58 -05:00
|
|
|
did_show = TRUE;
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
if (window->shaded)
|
|
|
|
{
|
2001-06-09 23:17:15 -04:00
|
|
|
if (window->mapped)
|
2002-01-03 18:28:19 -05:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"%s actually needs unmap (shaded)\n", window->desc);
|
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Incrementing unmaps_pending on %s for shade\n",
|
|
|
|
window->desc);
|
2001-06-09 23:17:15 -04:00
|
|
|
window->mapped = FALSE;
|
2001-06-10 23:24:20 -04:00
|
|
|
window->unmaps_pending += 1;
|
2001-06-09 23:17:15 -04:00
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XUnmapWindow (window->display->xdisplay, window->xwindow);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
if (!window->iconic)
|
|
|
|
{
|
|
|
|
window->iconic = TRUE;
|
|
|
|
set_wm_state (window, IconicState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-06-06 00:47:37 -04:00
|
|
|
{
|
2001-06-09 23:17:15 -04:00
|
|
|
if (!window->mapped)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"%s actually needs map\n", window->desc);
|
2001-06-09 23:17:15 -04:00
|
|
|
window->mapped = TRUE;
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XMapWindow (window->display->xdisplay, window->xwindow);
|
|
|
|
meta_error_trap_pop (window->display);
|
2002-02-08 01:01:58 -05:00
|
|
|
did_show = TRUE;
|
|
|
|
}
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
if (window->iconic)
|
|
|
|
{
|
|
|
|
window->iconic = FALSE;
|
|
|
|
set_wm_state (window, NormalState);
|
|
|
|
}
|
2001-06-06 00:47:37 -04:00
|
|
|
}
|
2001-10-29 21:00:53 -05:00
|
|
|
|
|
|
|
if (did_placement)
|
|
|
|
{
|
|
|
|
if (window->xtransient_for != None)
|
|
|
|
{
|
|
|
|
MetaWindow *parent;
|
|
|
|
|
|
|
|
parent =
|
|
|
|
meta_display_lookup_x_window (window->display,
|
|
|
|
window->xtransient_for);
|
|
|
|
|
2002-06-04 18:26:52 -04:00
|
|
|
if (parent && parent->has_focus &&
|
|
|
|
(window->input || window->take_focus))
|
2001-10-29 21:00:53 -05:00
|
|
|
{
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing transient window '%s' since parent had focus\n",
|
|
|
|
window->desc);
|
|
|
|
meta_window_focus (window,
|
|
|
|
meta_display_get_current_time (window->display));
|
2001-10-29 21:00:53 -05:00
|
|
|
}
|
|
|
|
}
|
2002-01-04 17:18:10 -05:00
|
|
|
|
|
|
|
/* Always focus new windows in click-to-focus */
|
2002-06-04 18:26:52 -04:00
|
|
|
if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK &&
|
|
|
|
(window->input || window->take_focus))
|
2002-05-16 15:08:20 -04:00
|
|
|
{
|
|
|
|
switch (window->type)
|
|
|
|
{
|
|
|
|
case META_WINDOW_DOCK:
|
|
|
|
case META_WINDOW_DESKTOP:
|
|
|
|
case META_WINDOW_UTILITY:
|
|
|
|
case META_WINDOW_SPLASHSCREEN:
|
2002-05-16 16:47:29 -04:00
|
|
|
case META_WINDOW_TOOLBAR:
|
|
|
|
case META_WINDOW_MENU:
|
2002-05-16 15:08:20 -04:00
|
|
|
/* don't focus these */
|
|
|
|
break;
|
|
|
|
case META_WINDOW_NORMAL:
|
2002-05-24 22:11:33 -04:00
|
|
|
/* Focus only if the current focus is on a desktop element
|
|
|
|
* or nonexistent.
|
|
|
|
*
|
|
|
|
* (using display->focus_window is a bit of a race condition,
|
|
|
|
* but I have no idea how to avoid it)
|
|
|
|
*/
|
2002-05-24 22:12:24 -04:00
|
|
|
if (window->display->focus_window == NULL ||
|
|
|
|
(window->display->focus_window &&
|
|
|
|
(window->display->focus_window->type == META_WINDOW_DOCK ||
|
|
|
|
window->display->focus_window->type == META_WINDOW_DESKTOP)))
|
2002-05-24 22:11:33 -04:00
|
|
|
meta_window_focus (window,
|
|
|
|
meta_display_get_current_time (window->display));
|
|
|
|
break;
|
2002-05-16 15:08:20 -04:00
|
|
|
case META_WINDOW_DIALOG:
|
|
|
|
case META_WINDOW_MODAL_DIALOG:
|
2002-05-24 22:11:33 -04:00
|
|
|
/* Focus only if the transient parent has focus */
|
|
|
|
/* (using display->focus_window is a bit of a race condition,
|
|
|
|
* but I have no idea how to avoid it)
|
|
|
|
*/
|
2002-05-24 22:12:24 -04:00
|
|
|
if (window->display->focus_window == NULL ||
|
|
|
|
(window->display->focus_window &&
|
|
|
|
meta_window_is_ancestor_of_transient (window->display->focus_window,
|
2002-06-11 18:30:30 -04:00
|
|
|
window)) ||
|
|
|
|
(window->display->focus_window->type == META_WINDOW_DOCK ||
|
|
|
|
window->display->focus_window->type == META_WINDOW_DESKTOP))
|
2002-05-24 22:11:33 -04:00
|
|
|
meta_window_focus (window,
|
|
|
|
meta_display_get_current_time (window->display));
|
2002-05-16 15:08:20 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-10-29 21:00:53 -05:00
|
|
|
}
|
2002-02-08 01:01:58 -05:00
|
|
|
|
|
|
|
if (did_show)
|
|
|
|
{
|
2002-02-08 23:50:58 -05:00
|
|
|
set_net_wm_state (window);
|
|
|
|
|
2002-02-08 01:01:58 -05:00
|
|
|
if (window->has_struts)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Mapped window %s with struts, so invalidating work areas\n",
|
|
|
|
window->desc);
|
|
|
|
invalidate_work_areas (window);
|
|
|
|
}
|
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_hide (MetaWindow *window)
|
|
|
|
{
|
2002-01-10 22:31:14 -05:00
|
|
|
gboolean did_hide;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Hiding window %s\n", window->desc);
|
2002-01-10 22:31:14 -05:00
|
|
|
|
|
|
|
did_hide = FALSE;
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
if (window->frame && window->frame->mapped)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE, "Frame actually needs unmap\n");
|
2001-06-09 23:17:15 -04:00
|
|
|
window->frame->mapped = FALSE;
|
2001-06-19 23:01:26 -04:00
|
|
|
meta_ui_unmap_frame (window->screen->ui, window->frame->xwindow);
|
2002-01-10 22:31:14 -05:00
|
|
|
did_hide = TRUE;
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
if (window->mapped)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"%s actually needs unmap\n", window->desc);
|
|
|
|
meta_topic (META_DEBUG_WINDOW_STATE,
|
|
|
|
"Incrementing unmaps_pending on %s for hide\n",
|
|
|
|
window->desc);
|
2001-06-09 23:17:15 -04:00
|
|
|
window->mapped = FALSE;
|
2001-06-10 23:24:20 -04:00
|
|
|
window->unmaps_pending += 1;
|
2002-01-10 22:31:14 -05:00
|
|
|
meta_error_trap_push (window->display);
|
2001-06-09 23:17:15 -04:00
|
|
|
XUnmapWindow (window->display->xdisplay, window->xwindow);
|
2001-06-20 01:47:44 -04:00
|
|
|
meta_error_trap_pop (window->display);
|
2002-01-10 22:31:14 -05:00
|
|
|
did_hide = TRUE;
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
2001-06-04 02:17:52 -04:00
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
if (!window->iconic)
|
|
|
|
{
|
|
|
|
window->iconic = TRUE;
|
|
|
|
set_wm_state (window, IconicState);
|
|
|
|
}
|
2002-02-08 23:50:58 -05:00
|
|
|
|
2002-01-10 22:31:14 -05:00
|
|
|
if (did_hide)
|
|
|
|
{
|
2002-02-08 23:50:58 -05:00
|
|
|
set_net_wm_state (window);
|
|
|
|
|
2002-01-10 22:31:14 -05:00
|
|
|
if (window->has_struts)
|
2002-02-07 22:34:26 -05:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Unmapped window %s with struts, so invalidating work areas\n",
|
|
|
|
window->desc);
|
|
|
|
invalidate_work_areas (window);
|
|
|
|
}
|
2002-01-10 22:31:14 -05:00
|
|
|
}
|
2001-06-04 02:17:52 -04:00
|
|
|
}
|
|
|
|
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
static void
|
|
|
|
queue_calc_showing_func (MetaWindow *window,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
meta_window_queue_calc_showing (window);
|
|
|
|
}
|
|
|
|
|
2001-06-04 02:17:52 -04:00
|
|
|
void
|
|
|
|
meta_window_minimize (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (!window->minimized)
|
|
|
|
{
|
|
|
|
window->minimized = TRUE;
|
2001-06-07 01:18:10 -04:00
|
|
|
meta_window_queue_calc_showing (window);
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
|
|
|
|
meta_window_foreach_transient (window,
|
|
|
|
queue_calc_showing_func,
|
|
|
|
NULL);
|
|
|
|
|
2002-01-03 18:28:19 -05:00
|
|
|
if (window->has_focus)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing top window due to minimization of focus window %s\n",
|
|
|
|
window->desc);
|
|
|
|
meta_screen_focus_top_window (window->screen, window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Minimizing window %s which doesn't have the focus\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
2001-06-04 02:17:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_unminimize (MetaWindow *window)
|
|
|
|
{
|
2001-12-07 01:33:30 -05:00
|
|
|
if (window->display->showing_desktop)
|
|
|
|
meta_display_unshow_desktop (window->display);
|
|
|
|
|
2001-06-04 02:17:52 -04:00
|
|
|
if (window->minimized)
|
|
|
|
{
|
|
|
|
window->minimized = FALSE;
|
2001-06-07 01:18:10 -04:00
|
|
|
meta_window_queue_calc_showing (window);
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
|
|
|
|
meta_window_foreach_transient (window,
|
|
|
|
queue_calc_showing_func,
|
|
|
|
NULL);
|
2001-06-07 01:18:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_maximize (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (!window->maximized)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Maximizing %s\n", window->desc);
|
2002-01-10 01:31:31 -05:00
|
|
|
|
2001-06-07 01:18:10 -04:00
|
|
|
window->maximized = TRUE;
|
2001-10-14 18:13:53 -04:00
|
|
|
|
2002-02-23 17:58:02 -05:00
|
|
|
/* FIXME why did I put this here? */
|
2001-10-14 18:13:53 -04:00
|
|
|
meta_window_raise (window);
|
2001-06-07 01:18:10 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* save size/pos as appropriate args for move_resize */
|
2001-06-07 01:18:10 -04:00
|
|
|
window->saved_rect = window->rect;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
window->saved_rect.x += window->frame->rect.x;
|
|
|
|
window->saved_rect.y += window->frame->rect.y;
|
|
|
|
}
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* move_resize with new maximization constraints
|
2001-06-07 22:17:48 -04:00
|
|
|
*/
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
|
|
|
set_net_wm_state (window);
|
2001-06-07 01:18:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_unmaximize (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->maximized)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Unmaximizing %s\n", window->desc);
|
2002-01-10 01:31:31 -05:00
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
window->maximized = FALSE;
|
2001-06-07 01:18:10 -04:00
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
meta_window_move_resize (window,
|
2001-08-28 23:37:03 -04:00
|
|
|
TRUE,
|
2001-06-07 22:17:48 -04:00
|
|
|
window->saved_rect.x,
|
|
|
|
window->saved_rect.y,
|
|
|
|
window->saved_rect.width,
|
|
|
|
window->saved_rect.height);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
|
|
|
set_net_wm_state (window);
|
2001-06-04 02:17:52 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
}
|
|
|
|
|
2002-02-23 17:58:02 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_make_fullscreen (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (!window->fullscreen)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Fullscreening %s\n", window->desc);
|
|
|
|
|
|
|
|
window->fullscreen = TRUE;
|
|
|
|
|
|
|
|
/* FIXME why did I put this here? */
|
|
|
|
meta_window_raise (window);
|
|
|
|
|
|
|
|
/* save size/pos as appropriate args for move_resize */
|
|
|
|
window->saved_rect = window->rect;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
window->saved_rect.x += window->frame->rect.x;
|
|
|
|
window->saved_rect.y += window->frame->rect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* move_resize with new constraints
|
|
|
|
*/
|
|
|
|
meta_window_queue_move_resize (window);
|
|
|
|
|
|
|
|
set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_unmake_fullscreen (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->fullscreen)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Unfullscreening %s\n", window->desc);
|
|
|
|
|
|
|
|
window->fullscreen = FALSE;
|
|
|
|
|
|
|
|
meta_window_move_resize (window,
|
|
|
|
TRUE,
|
|
|
|
window->saved_rect.x,
|
|
|
|
window->saved_rect.y,
|
|
|
|
window->saved_rect.width,
|
|
|
|
window->saved_rect.height);
|
|
|
|
|
|
|
|
set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-02 21:33:27 -04:00
|
|
|
void
|
2001-06-07 22:17:48 -04:00
|
|
|
meta_window_shade (MetaWindow *window)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Shading %s\n", window->desc);
|
2001-06-07 22:17:48 -04:00
|
|
|
if (!window->shaded)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2001-08-06 03:58:49 -04:00
|
|
|
if (window->mapped)
|
|
|
|
{
|
|
|
|
/* Animation */
|
|
|
|
MetaRectangle starting_size;
|
|
|
|
MetaRectangle titlebar_size;
|
|
|
|
|
|
|
|
meta_window_get_outer_rect (window, &starting_size);
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
starting_size.y += window->frame->child_y;
|
|
|
|
starting_size.height -= window->frame->child_y;
|
|
|
|
}
|
|
|
|
titlebar_size = starting_size;
|
|
|
|
titlebar_size.height = 0;
|
|
|
|
|
|
|
|
meta_effects_draw_box_animation (window->screen,
|
|
|
|
&starting_size,
|
|
|
|
&titlebar_size,
|
2002-03-05 00:05:00 -05:00
|
|
|
META_SHADE_ANIMATION_LENGTH,
|
|
|
|
META_BOX_ANIM_SLIDE_UP);
|
2001-08-06 03:58:49 -04:00
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
|
2001-08-06 00:43:31 -04:00
|
|
|
window->shaded = TRUE;
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-07 22:17:48 -04:00
|
|
|
meta_window_queue_calc_showing (window);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2002-01-03 18:28:19 -05:00
|
|
|
/* After queuing the calc showing, since _focus flushes it,
|
|
|
|
* and we need to focus the frame
|
|
|
|
*/
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Re-focusing window %s after shading it\n",
|
|
|
|
window->desc);
|
|
|
|
meta_window_focus (window,
|
|
|
|
meta_display_get_current_time (window->display));
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
set_net_wm_state (window);
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
void
|
2001-06-07 22:17:48 -04:00
|
|
|
meta_window_unshade (MetaWindow *window)
|
2001-06-06 00:47:37 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Unshading %s\n", window->desc);
|
2001-06-07 22:17:48 -04:00
|
|
|
if (window->shaded)
|
|
|
|
{
|
|
|
|
window->shaded = FALSE;
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-07 22:17:48 -04:00
|
|
|
meta_window_queue_calc_showing (window);
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* focus the window */
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing window %s after unshading it\n",
|
|
|
|
window->desc);
|
|
|
|
meta_window_focus (window, meta_display_get_current_time (window->display));
|
2001-06-10 23:24:20 -04:00
|
|
|
|
|
|
|
set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
static void
|
|
|
|
unminimize_window_and_all_transient_parents (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindow *w;
|
|
|
|
|
|
|
|
w = window;
|
|
|
|
while (w != NULL)
|
|
|
|
{
|
|
|
|
meta_window_unminimize (w);
|
|
|
|
|
|
|
|
if (w->xtransient_for == None)
|
|
|
|
break;
|
|
|
|
|
|
|
|
w = meta_display_lookup_x_window (w->display, w->xtransient_for);
|
|
|
|
|
|
|
|
if (w == window)
|
|
|
|
break; /* Cute, someone thought they'd make a transient_for cycle */
|
|
|
|
|
|
|
|
/* w may be null... */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-29 02:00:46 -05:00
|
|
|
void
|
|
|
|
meta_window_activate (MetaWindow *window,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
2002-04-28 00:52:26 -04:00
|
|
|
/* disable show desktop mode unless we're a desktop component */
|
|
|
|
if (window->display->showing_desktop &&
|
|
|
|
window->type != META_WINDOW_DESKTOP &&
|
|
|
|
window->type != META_WINDOW_DOCK)
|
|
|
|
meta_display_unshow_desktop (window->display);
|
|
|
|
|
2001-10-29 02:00:46 -05:00
|
|
|
/* Get window on current workspace */
|
|
|
|
if (!meta_window_visible_on_workspace (window,
|
|
|
|
window->screen->active_workspace))
|
|
|
|
meta_window_change_workspace (window,
|
|
|
|
window->screen->active_workspace);
|
2002-02-08 01:50:09 -05:00
|
|
|
|
|
|
|
if (window->shaded)
|
|
|
|
meta_window_unshade (window);
|
2001-10-29 02:00:46 -05:00
|
|
|
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
unminimize_window_and_all_transient_parents (window);
|
2001-10-29 02:00:46 -05:00
|
|
|
|
|
|
|
meta_window_raise (window);
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing window %s due to activation\n",
|
|
|
|
window->desc);
|
2001-10-29 02:00:46 -05:00
|
|
|
meta_window_focus (window, timestamp);
|
|
|
|
}
|
2001-06-10 23:24:20 -04:00
|
|
|
|
|
|
|
/* returns values suitable for meta_window_move */
|
2001-07-28 02:35:19 -04:00
|
|
|
static void
|
2001-06-10 23:24:20 -04:00
|
|
|
adjust_for_gravity (MetaWindow *window,
|
|
|
|
MetaFrameGeometry *fgeom,
|
|
|
|
gboolean coords_assume_border,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *xp,
|
|
|
|
int *yp)
|
|
|
|
{
|
|
|
|
int ref_x, ref_y;
|
|
|
|
int bw;
|
|
|
|
int child_x, child_y;
|
|
|
|
int frame_width, frame_height;
|
|
|
|
|
|
|
|
if (coords_assume_border)
|
|
|
|
bw = window->border_width;
|
|
|
|
else
|
|
|
|
bw = 0;
|
|
|
|
|
|
|
|
if (fgeom)
|
|
|
|
{
|
|
|
|
child_x = fgeom->left_width;
|
|
|
|
child_y = fgeom->top_height;
|
|
|
|
frame_width = child_x + window->rect.width + fgeom->right_width;
|
|
|
|
frame_height = child_y + window->rect.height + fgeom->bottom_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child_x = 0;
|
|
|
|
child_y = 0;
|
|
|
|
frame_width = window->rect.width;
|
|
|
|
frame_height = window->rect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We're computing position to pass to window_move, which is
|
|
|
|
* the position of the client window (StaticGravity basically)
|
|
|
|
*
|
|
|
|
* (see WM spec description of gravity computation, but note that
|
|
|
|
* their formulas assume we're honoring the border width, rather
|
|
|
|
* than compensating for having turned it off)
|
|
|
|
*/
|
|
|
|
switch (window->size_hints.win_gravity)
|
|
|
|
{
|
|
|
|
case NorthWestGravity:
|
|
|
|
ref_x = x;
|
|
|
|
ref_y = y;
|
|
|
|
break;
|
|
|
|
case NorthGravity:
|
|
|
|
ref_x = x + window->rect.width / 2 + bw;
|
|
|
|
ref_y = y;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
ref_x = x + window->rect.width + bw * 2;
|
|
|
|
ref_y = y;
|
|
|
|
break;
|
|
|
|
case WestGravity:
|
|
|
|
ref_x = x;
|
|
|
|
ref_y = y + window->rect.height / 2 + bw;
|
|
|
|
break;
|
|
|
|
case CenterGravity:
|
|
|
|
ref_x = x + window->rect.width / 2 + bw;
|
|
|
|
ref_y = y + window->rect.height / 2 + bw;
|
|
|
|
break;
|
|
|
|
case EastGravity:
|
|
|
|
ref_x = x + window->rect.width + bw * 2;
|
|
|
|
ref_y = y + window->rect.height / 2 + bw;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
ref_x = x;
|
|
|
|
ref_y = y + window->rect.height + bw * 2;
|
|
|
|
break;
|
|
|
|
case SouthGravity:
|
|
|
|
ref_x = x + window->rect.width / 2 + bw;
|
|
|
|
ref_y = y + window->rect.height + bw * 2;
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
ref_x = x + window->rect.width + bw * 2;
|
|
|
|
ref_y = y + window->rect.height + bw * 2;
|
|
|
|
break;
|
|
|
|
case StaticGravity:
|
|
|
|
default:
|
|
|
|
ref_x = x;
|
|
|
|
ref_y = y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (window->size_hints.win_gravity)
|
|
|
|
{
|
|
|
|
case NorthWestGravity:
|
|
|
|
*xp = ref_x + child_x;
|
|
|
|
*yp = ref_y + child_y;
|
|
|
|
break;
|
|
|
|
case NorthGravity:
|
|
|
|
*xp = ref_x - frame_width / 2 + child_x;
|
|
|
|
*yp = ref_y + child_y;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
*xp = ref_x - frame_width + child_x;
|
|
|
|
*yp = ref_y + child_y;
|
|
|
|
break;
|
|
|
|
case WestGravity:
|
|
|
|
*xp = ref_x + child_x;
|
|
|
|
*yp = ref_y - frame_height / 2 + child_y;
|
|
|
|
break;
|
|
|
|
case CenterGravity:
|
|
|
|
*xp = ref_x - frame_width / 2 + child_x;
|
|
|
|
*yp = ref_y - frame_height / 2 + child_y;
|
|
|
|
break;
|
|
|
|
case EastGravity:
|
|
|
|
*xp = ref_x - frame_width + child_x;
|
|
|
|
*yp = ref_y - frame_height / 2 + child_y;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
*xp = ref_x + child_x;
|
|
|
|
*yp = ref_y - frame_height + child_y;
|
|
|
|
break;
|
|
|
|
case SouthGravity:
|
|
|
|
*xp = ref_x - frame_width / 2 + child_x;
|
|
|
|
*yp = ref_y - frame_height + child_y;
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
*xp = ref_x - frame_width + child_x;
|
|
|
|
*yp = ref_y - frame_height + child_y;
|
|
|
|
break;
|
|
|
|
case StaticGravity:
|
|
|
|
default:
|
|
|
|
*xp = ref_x;
|
|
|
|
*yp = ref_y;
|
|
|
|
break;
|
2001-06-07 22:17:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
static gboolean
|
|
|
|
static_gravity_works (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
return display->static_gravity_works;
|
|
|
|
}
|
|
|
|
|
2001-06-07 22:17:48 -04:00
|
|
|
static void
|
|
|
|
meta_window_move_resize_internal (MetaWindow *window,
|
2001-08-28 23:37:03 -04:00
|
|
|
MetaMoveResizeFlags flags,
|
2001-06-30 19:17:52 -04:00
|
|
|
int resize_gravity,
|
2001-06-07 22:17:48 -04:00
|
|
|
int root_x_nw,
|
|
|
|
int root_y_nw,
|
|
|
|
int w,
|
|
|
|
int h)
|
2001-06-09 17:58:30 -04:00
|
|
|
{
|
|
|
|
XWindowChanges values;
|
|
|
|
unsigned int mask;
|
|
|
|
gboolean need_configure_notify;
|
|
|
|
MetaFrameGeometry fgeom;
|
2001-06-09 23:17:15 -04:00
|
|
|
gboolean need_move_client = FALSE;
|
|
|
|
gboolean need_move_frame = FALSE;
|
|
|
|
gboolean need_resize_client = FALSE;
|
|
|
|
gboolean need_resize_frame = FALSE;
|
2001-06-30 19:17:52 -04:00
|
|
|
int size_dx;
|
|
|
|
int size_dy;
|
|
|
|
int frame_size_dx;
|
2001-08-28 23:37:03 -04:00
|
|
|
int frame_size_dy;
|
|
|
|
gboolean is_configure_request;
|
|
|
|
gboolean do_gravity_adjust;
|
2001-09-10 22:57:05 -04:00
|
|
|
gboolean is_user_action;
|
2002-01-19 18:59:11 -05:00
|
|
|
gboolean configure_frame_first;
|
|
|
|
gboolean use_static_gravity;
|
|
|
|
/* used for the configure request, but may not be final
|
|
|
|
* destination due to StaticGravity etc.
|
|
|
|
*/
|
|
|
|
int client_move_x;
|
|
|
|
int client_move_y;
|
2001-08-28 23:37:03 -04:00
|
|
|
|
|
|
|
is_configure_request = (flags & META_IS_CONFIGURE_REQUEST) != 0;
|
|
|
|
do_gravity_adjust = (flags & META_DO_GRAVITY_ADJUST) != 0;
|
2001-09-10 22:57:05 -04:00
|
|
|
is_user_action = (flags & META_USER_MOVE_RESIZE) != 0;
|
2002-05-29 00:14:15 -04:00
|
|
|
|
|
|
|
/* We don't need it in the idle queue anymore. */
|
|
|
|
meta_window_unqueue_move_resize (window);
|
2001-06-30 19:17:52 -04:00
|
|
|
|
2001-06-12 20:56:08 -04:00
|
|
|
{
|
|
|
|
int oldx, oldy;
|
|
|
|
meta_window_get_position (window, &oldx, &oldy);
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Move/resize %s to %d,%d %dx%d%s%s from %d,%d %dx%d\n",
|
|
|
|
window->desc, root_x_nw, root_y_nw, w, h,
|
|
|
|
is_configure_request ? " (configure request)" : "",
|
|
|
|
is_user_action ? " (user move/resize)" : "",
|
|
|
|
oldx, oldy, window->rect.width, window->rect.height);
|
2001-08-28 23:37:03 -04:00
|
|
|
}
|
2001-08-19 23:17:40 -04:00
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
if (window->frame)
|
|
|
|
meta_frame_calc_geometry (window->frame,
|
|
|
|
&fgeom);
|
|
|
|
|
|
|
|
constrain_size (window, &fgeom, w, h, &w, &h);
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Constrained resize of %s to %d x %d\n", window->desc, w, h);
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
if (w != window->rect.width ||
|
|
|
|
h != window->rect.height)
|
|
|
|
need_resize_client = TRUE;
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
size_dx = w - window->rect.width;
|
|
|
|
size_dy = h - window->rect.height;
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
window->rect.width = w;
|
|
|
|
window->rect.height = h;
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
int new_w, new_h;
|
|
|
|
|
|
|
|
new_w = window->rect.width + fgeom.left_width + fgeom.right_width;
|
|
|
|
|
|
|
|
if (window->shaded)
|
|
|
|
new_h = fgeom.top_height;
|
|
|
|
else
|
|
|
|
new_h = window->rect.height + fgeom.top_height + fgeom.bottom_height;
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
frame_size_dx = new_w - window->frame->rect.width;
|
|
|
|
frame_size_dy = new_h - window->frame->rect.height;
|
2002-01-19 18:59:11 -05:00
|
|
|
|
|
|
|
need_resize_frame = (frame_size_dx != 0 || frame_size_dy != 0);
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
window->frame->rect.width = new_w;
|
|
|
|
window->frame->rect.height = new_h;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Calculated frame size %dx%d\n",
|
|
|
|
window->frame->rect.width,
|
|
|
|
window->frame->rect.height);
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
2001-06-30 19:17:52 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
frame_size_dx = 0;
|
|
|
|
frame_size_dy = 0;
|
|
|
|
}
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-07-28 02:35:19 -04:00
|
|
|
if (is_configure_request || do_gravity_adjust)
|
2001-06-10 23:24:20 -04:00
|
|
|
{
|
|
|
|
adjust_for_gravity (window,
|
|
|
|
window->frame ? &fgeom : NULL,
|
|
|
|
/* configure request coords assume
|
|
|
|
* the border width existed
|
|
|
|
*/
|
|
|
|
is_configure_request,
|
|
|
|
root_x_nw,
|
|
|
|
root_y_nw,
|
|
|
|
&root_x_nw,
|
|
|
|
&root_y_nw);
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Compensated position for gravity, new pos %d,%d\n",
|
|
|
|
root_x_nw, root_y_nw);
|
2001-06-10 23:24:20 -04:00
|
|
|
}
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
/* There can be somewhat bogus interactions between gravity
|
|
|
|
* and the position constraints (with position contraints
|
|
|
|
* basically breaking gravity). Not sure how to fix this.
|
2001-08-18 22:45:55 -04:00
|
|
|
*/
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
switch (resize_gravity)
|
|
|
|
{
|
2001-08-18 22:45:55 -04:00
|
|
|
/* If client is staying fixed on the east during resize, then we
|
|
|
|
* have to move the west edge.
|
|
|
|
*/
|
2001-06-30 19:17:52 -04:00
|
|
|
case NorthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
root_x_nw -= size_dx;
|
|
|
|
break;
|
2001-08-18 22:45:55 -04:00
|
|
|
|
|
|
|
/* centered horizontally */
|
|
|
|
case NorthGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
root_x_nw -= size_dx / 2;
|
|
|
|
break;
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (resize_gravity)
|
|
|
|
{
|
2001-08-18 22:45:55 -04:00
|
|
|
/* If client is staying fixed on the south during resize,
|
|
|
|
* we have to move the north edge
|
|
|
|
*/
|
2001-06-30 19:17:52 -04:00
|
|
|
case SouthGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
case SouthWestGravity:
|
|
|
|
root_y_nw -= size_dy;
|
|
|
|
break;
|
2001-08-18 22:45:55 -04:00
|
|
|
|
|
|
|
/* centered vertically */
|
|
|
|
case EastGravity:
|
|
|
|
case WestGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
root_y_nw -= size_dy / 2;
|
|
|
|
break;
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
default:
|
|
|
|
break;
|
2001-08-18 22:45:55 -04:00
|
|
|
}
|
2002-01-19 18:59:11 -05:00
|
|
|
|
|
|
|
/* For nice effect, when growing the window we want to move/resize
|
|
|
|
* the frame first, when shrinking the window we want to move/resize
|
|
|
|
* the client first. If we grow one way and shrink the other,
|
|
|
|
* see which way we're moving "more"
|
|
|
|
*
|
|
|
|
* Mail from Owen subject "Suggestion: Gravity and resizing from the left"
|
|
|
|
* http://mail.gnome.org/archives/wm-spec-list/1999-November/msg00088.html
|
|
|
|
*
|
|
|
|
* An annoying fact you need to know in this code is that StaticGravity
|
|
|
|
* does nothing if you _only_ resize or _only_ move the frame;
|
|
|
|
* it must move _and_ resize, otherwise you get NorthWestGravity
|
|
|
|
* behavior. The move and resize must actually occur, it is not
|
|
|
|
* enough to set CWX | CWWidth but pass in the current size/pos.
|
|
|
|
*/
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
constrain_position (window,
|
|
|
|
window->frame ? &fgeom : NULL,
|
|
|
|
root_x_nw, root_y_nw,
|
|
|
|
&root_x_nw, &root_y_nw);
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Constrained position to %d,%d\n",
|
|
|
|
root_x_nw, root_y_nw);
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
int new_x, new_y;
|
2002-01-19 18:59:11 -05:00
|
|
|
int frame_pos_dx, frame_pos_dy;
|
2001-06-07 22:17:48 -04:00
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
/* Compute new frame coords */
|
2001-06-09 23:17:15 -04:00
|
|
|
new_x = root_x_nw - fgeom.left_width;
|
|
|
|
new_y = root_y_nw - fgeom.top_height;
|
2001-06-07 22:17:48 -04:00
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
frame_pos_dx = new_x - window->frame->rect.x;
|
|
|
|
frame_pos_dy = new_y - window->frame->rect.y;
|
2001-06-09 23:17:15 -04:00
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
need_move_frame = (frame_pos_dx != 0 || frame_pos_dy != 0);
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
window->frame->rect.x = new_x;
|
2002-01-19 18:59:11 -05:00
|
|
|
window->frame->rect.y = new_y;
|
|
|
|
|
|
|
|
/* If frame will both move and resize, then StaticGravity
|
|
|
|
* on the child window will kick in and implicitly move
|
|
|
|
* the child with respect to the frame. The implicit
|
|
|
|
* move will keep the child in the same place with
|
|
|
|
* respect to the root window. If frame only moves
|
|
|
|
* or only resizes, then the child will just move along
|
|
|
|
* with the frame.
|
|
|
|
*/
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
/* window->rect.x, window->rect.y are relative to frame,
|
|
|
|
* remember they are the server coords
|
|
|
|
*/
|
2002-01-19 18:59:11 -05:00
|
|
|
|
|
|
|
new_x = fgeom.left_width;
|
|
|
|
new_y = fgeom.top_height;
|
|
|
|
|
|
|
|
if (need_resize_frame && need_move_frame &&
|
|
|
|
static_gravity_works (window->display))
|
|
|
|
{
|
|
|
|
/* static gravity kicks in because frame
|
|
|
|
* is both moved and resized
|
|
|
|
*/
|
|
|
|
/* when we move the frame by frame_pos_dx, frame_pos_dy the
|
|
|
|
* client will implicitly move relative to frame by the
|
|
|
|
* inverse delta.
|
|
|
|
*
|
|
|
|
* When moving client then frame, we move the client by the
|
|
|
|
* frame delta, to be canceled out by the implicit move by
|
|
|
|
* the inverse frame delta, resulting in a client at new_x,
|
|
|
|
* new_y.
|
|
|
|
*
|
|
|
|
* When moving frame then client, we move the client
|
|
|
|
* by the same delta as the frame, because the client
|
|
|
|
* was "left behind" by the frame - resulting in a client
|
|
|
|
* at new_x, new_y.
|
|
|
|
*
|
|
|
|
* In both cases we need to move the client window
|
|
|
|
* in all cases where we had to move the frame window.
|
|
|
|
*/
|
|
|
|
|
|
|
|
client_move_x = new_x + frame_pos_dx;
|
|
|
|
client_move_y = new_y + frame_pos_dy;
|
|
|
|
|
|
|
|
if (need_move_frame)
|
|
|
|
need_move_client = TRUE;
|
|
|
|
|
|
|
|
use_static_gravity = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client_move_x = new_x;
|
|
|
|
client_move_y = new_y;
|
|
|
|
|
|
|
|
if (client_move_x != window->rect.x ||
|
|
|
|
client_move_y != window->rect.y)
|
|
|
|
need_move_client = TRUE;
|
|
|
|
|
|
|
|
use_static_gravity = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the final target position, but not necessarily what
|
|
|
|
* we pass to XConfigureWindow, due to StaticGravity implicit
|
|
|
|
* movement.
|
|
|
|
*/
|
|
|
|
window->rect.x = new_x;
|
|
|
|
window->rect.y = new_y;
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (root_x_nw != window->rect.x ||
|
|
|
|
root_y_nw != window->rect.y)
|
|
|
|
need_move_client = TRUE;
|
|
|
|
|
|
|
|
window->rect.x = root_x_nw;
|
|
|
|
window->rect.y = root_y_nw;
|
2002-01-19 18:59:11 -05:00
|
|
|
|
|
|
|
client_move_x = window->rect.x;
|
|
|
|
client_move_y = window->rect.y;
|
|
|
|
|
|
|
|
use_static_gravity = FALSE;
|
2001-06-06 00:47:37 -04:00
|
|
|
}
|
2001-06-07 22:17:48 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* Fill in other frame member variables */
|
|
|
|
if (window->frame)
|
2001-06-07 22:17:48 -04:00
|
|
|
{
|
2001-06-09 17:58:30 -04:00
|
|
|
window->frame->child_x = fgeom.left_width;
|
|
|
|
window->frame->child_y = fgeom.top_height;
|
|
|
|
window->frame->right_width = fgeom.right_width;
|
|
|
|
window->frame->bottom_height = fgeom.bottom_height;
|
2001-06-07 22:17:48 -04:00
|
|
|
}
|
2002-01-10 01:31:31 -05:00
|
|
|
|
2001-06-12 20:56:08 -04:00
|
|
|
/* See ICCCM 4.1.5 for when to send ConfigureNotify */
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2001-06-12 20:56:08 -04:00
|
|
|
need_configure_notify = FALSE;
|
2002-01-19 18:59:11 -05:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* If this is a configure request and we change nothing, then we
|
2001-06-12 20:56:08 -04:00
|
|
|
* must send configure notify.
|
2001-06-09 17:58:30 -04:00
|
|
|
*/
|
2001-06-12 20:56:08 -04:00
|
|
|
if (is_configure_request &&
|
|
|
|
!(need_move_client || need_move_frame ||
|
|
|
|
need_resize_client || need_resize_frame ||
|
|
|
|
window->border_width != 0))
|
|
|
|
need_configure_notify = TRUE;
|
|
|
|
|
|
|
|
/* We must send configure notify if we move but don't resize, since
|
|
|
|
* the client window may not get a real event
|
|
|
|
*/
|
|
|
|
if ((need_move_client || need_move_frame) &&
|
|
|
|
!(need_resize_client || need_resize_frame))
|
|
|
|
need_configure_notify = TRUE;
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
/* The rest of this function syncs our new size/pos with X as
|
|
|
|
* efficiently as possible
|
|
|
|
*/
|
2002-01-19 18:59:11 -05:00
|
|
|
if (use_static_gravity)
|
|
|
|
{
|
|
|
|
if ((size_dx + size_dy) >= 0)
|
|
|
|
configure_frame_first = FALSE;
|
|
|
|
else
|
|
|
|
configure_frame_first = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
configure_frame_first = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (use_static_gravity)
|
|
|
|
meta_window_set_gravity (window, StaticGravity);
|
2001-06-30 19:17:52 -04:00
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
if (configure_frame_first && window->frame)
|
|
|
|
meta_frame_sync_to_window (window->frame,
|
|
|
|
resize_gravity,
|
|
|
|
need_move_frame, need_resize_frame);
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
values.border_width = 0;
|
2002-01-19 18:59:11 -05:00
|
|
|
values.x = client_move_x;
|
|
|
|
values.y = client_move_y;
|
2001-06-09 17:58:30 -04:00
|
|
|
values.width = window->rect.width;
|
|
|
|
values.height = window->rect.height;
|
|
|
|
|
|
|
|
mask = 0;
|
|
|
|
if (is_configure_request && window->border_width != 0)
|
|
|
|
mask |= CWBorderWidth; /* must force to 0 */
|
2001-06-09 23:17:15 -04:00
|
|
|
if (need_move_client)
|
2001-06-09 17:58:30 -04:00
|
|
|
mask |= (CWX | CWY);
|
2001-06-09 23:17:15 -04:00
|
|
|
if (need_resize_client)
|
2001-06-09 17:58:30 -04:00
|
|
|
mask |= (CWWidth | CWHeight);
|
|
|
|
|
|
|
|
if (mask != 0)
|
2001-06-07 22:17:48 -04:00
|
|
|
{
|
2001-06-12 20:56:08 -04:00
|
|
|
{
|
|
|
|
int newx, newy;
|
|
|
|
meta_window_get_position (window, &newx, &newy);
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Syncing new client geometry %d,%d %dx%d, border: %s pos: %s size: %s\n",
|
|
|
|
newx, newy,
|
|
|
|
window->rect.width, window->rect.height,
|
|
|
|
mask & CWBorderWidth ? "true" : "false",
|
|
|
|
need_move_client ? "true" : "false",
|
|
|
|
need_resize_client ? "true" : "false");
|
2001-06-12 20:56:08 -04:00
|
|
|
}
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XConfigureWindow (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
mask,
|
|
|
|
&values);
|
|
|
|
meta_error_trap_pop (window->display);
|
2001-06-07 22:17:48 -04:00
|
|
|
}
|
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
if (!configure_frame_first && window->frame)
|
|
|
|
meta_frame_sync_to_window (window->frame,
|
|
|
|
resize_gravity,
|
|
|
|
need_move_frame, need_resize_frame);
|
2001-09-10 22:57:05 -04:00
|
|
|
|
2002-01-19 18:59:11 -05:00
|
|
|
/* Put gravity back to be nice to lesser window managers */
|
|
|
|
if (use_static_gravity)
|
|
|
|
meta_window_set_gravity (window, NorthWestGravity);
|
2001-06-30 19:17:52 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
if (need_configure_notify)
|
|
|
|
send_configure_notify (window);
|
2001-06-09 23:17:15 -04:00
|
|
|
|
2001-09-10 22:57:05 -04:00
|
|
|
if (is_user_action)
|
2001-08-28 23:37:03 -04:00
|
|
|
{
|
2001-09-10 22:57:05 -04:00
|
|
|
window->user_has_move_resized = TRUE;
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
window->user_rect.width = window->rect.width;
|
|
|
|
window->user_rect.height = window->rect.height;
|
|
|
|
|
|
|
|
meta_window_get_position (window,
|
|
|
|
&window->user_rect.x,
|
|
|
|
&window->user_rect.y);
|
|
|
|
}
|
2001-09-10 22:57:05 -04:00
|
|
|
|
|
|
|
if (need_move_frame || need_resize_frame ||
|
|
|
|
need_move_client || need_resize_client)
|
|
|
|
{
|
|
|
|
int newx, newy;
|
|
|
|
meta_window_get_position (window, &newx, &newy);
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"New size/position %d,%d %dx%d (user %d,%d %dx%d)\n",
|
|
|
|
newx, newy, window->rect.width, window->rect.height,
|
|
|
|
window->user_rect.x, window->user_rect.y,
|
|
|
|
window->user_rect.width, window->user_rect.height);
|
2001-09-10 22:57:05 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Size/position not modified\n");
|
2001-09-10 22:57:05 -04:00
|
|
|
}
|
2002-01-18 22:50:03 -05:00
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
/* Update struts for new window size */
|
|
|
|
if (window->do_not_cover && (need_resize_client || need_move_client))
|
|
|
|
{
|
|
|
|
recalc_do_not_cover_struts (window);
|
|
|
|
|
|
|
|
/* Does a resize on all windows on entire current workspace,
|
|
|
|
* would be an infinite loop except for need_resize_client
|
2002-01-18 22:50:03 -05:00
|
|
|
* above. We rely on reaching an equilibrium state, which
|
|
|
|
* is somewhat fragile, though.
|
2002-01-10 01:31:31 -05:00
|
|
|
*/
|
2002-02-07 22:34:26 -05:00
|
|
|
|
|
|
|
meta_topic (META_DEBUG_WORKAREA, "Window %s resized so invalidating its work areas\n",
|
|
|
|
window->desc);
|
2002-01-10 01:31:31 -05:00
|
|
|
invalidate_work_areas (window);
|
|
|
|
}
|
2002-03-17 12:22:23 -05:00
|
|
|
|
|
|
|
meta_window_refresh_resize_popup (window);
|
2001-08-28 23:37:03 -04:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
/* Invariants leaving this function are:
|
|
|
|
* a) window->rect and frame->rect reflect the actual
|
|
|
|
* server-side size/pos of window->xwindow and frame->xwindow
|
|
|
|
* b) all constraints are obeyed by window->rect and frame->rect
|
|
|
|
*/
|
2001-06-07 22:17:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_resize (MetaWindow *window,
|
2001-08-28 23:37:03 -04:00
|
|
|
gboolean user_op,
|
2001-06-07 22:17:48 -04:00
|
|
|
int w,
|
|
|
|
int h)
|
|
|
|
{
|
2001-06-09 23:17:15 -04:00
|
|
|
int x, y;
|
|
|
|
|
|
|
|
meta_window_get_position (window, &x, &y);
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize_internal (window,
|
2001-09-10 22:57:05 -04:00
|
|
|
user_op ? META_USER_MOVE_RESIZE : 0,
|
2001-06-30 19:17:52 -04:00
|
|
|
NorthWestGravity,
|
|
|
|
x, y, w, h);
|
2001-06-07 22:17:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_move (MetaWindow *window,
|
2001-08-28 23:37:03 -04:00
|
|
|
gboolean user_op,
|
2001-06-07 22:17:48 -04:00
|
|
|
int root_x_nw,
|
|
|
|
int root_y_nw)
|
|
|
|
{
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize_internal (window,
|
2001-09-10 22:57:05 -04:00
|
|
|
user_op ? META_USER_MOVE_RESIZE : 0,
|
2001-06-30 19:17:52 -04:00
|
|
|
NorthWestGravity,
|
2001-06-09 23:17:15 -04:00
|
|
|
root_x_nw, root_y_nw,
|
|
|
|
window->rect.width,
|
|
|
|
window->rect.height);
|
2001-06-07 22:17:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_move_resize (MetaWindow *window,
|
2001-08-28 23:37:03 -04:00
|
|
|
gboolean user_op,
|
2001-06-07 22:17:48 -04:00
|
|
|
int root_x_nw,
|
|
|
|
int root_y_nw,
|
|
|
|
int w,
|
|
|
|
int h)
|
|
|
|
{
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize_internal (window,
|
2001-09-10 22:57:05 -04:00
|
|
|
user_op ? META_USER_MOVE_RESIZE : 0,
|
2001-06-30 19:17:52 -04:00
|
|
|
NorthWestGravity,
|
2001-06-07 22:17:48 -04:00
|
|
|
root_x_nw, root_y_nw,
|
|
|
|
w, h);
|
2001-06-06 00:47:37 -04:00
|
|
|
}
|
|
|
|
|
2001-06-30 19:17:52 -04:00
|
|
|
void
|
|
|
|
meta_window_resize_with_gravity (MetaWindow *window,
|
2001-08-28 23:37:03 -04:00
|
|
|
gboolean user_op,
|
2001-06-30 19:17:52 -04:00
|
|
|
int w,
|
|
|
|
int h,
|
|
|
|
int gravity)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
meta_window_get_position (window, &x, &y);
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize_internal (window,
|
2001-09-10 22:57:05 -04:00
|
|
|
user_op ? META_USER_MOVE_RESIZE : 0,
|
2001-06-30 19:17:52 -04:00
|
|
|
gravity,
|
|
|
|
x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
void
|
2001-06-24 04:09:10 -04:00
|
|
|
meta_window_move_resize_now (MetaWindow *window)
|
2001-06-09 17:58:30 -04:00
|
|
|
{
|
|
|
|
int x, y;
|
2001-08-28 23:37:03 -04:00
|
|
|
|
|
|
|
/* If constraints have changed then we'll snap back to wherever
|
|
|
|
* the user had the window
|
|
|
|
*/
|
|
|
|
meta_window_get_user_position (window, &x, &y);
|
2002-04-21 23:10:53 -04:00
|
|
|
|
|
|
|
/* This used to use the user width/height if the user hadn't resized,
|
|
|
|
* but it turns out that breaks things pretty often, because configure
|
|
|
|
* requests from the app or size hints changes from the app frequently
|
|
|
|
* reflect user actions such as changing terminal font size
|
|
|
|
* or expanding a disclosure triangle.
|
|
|
|
*/
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize (window, FALSE, x, y,
|
2002-04-21 23:10:53 -04:00
|
|
|
window->rect.width,
|
|
|
|
window->rect.height);
|
2001-06-09 17:58:30 -04:00
|
|
|
}
|
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
static guint move_resize_idle = 0;
|
|
|
|
static GSList *move_resize_pending = NULL;
|
|
|
|
|
|
|
|
/* We want to put windows whose size/pos affects other
|
|
|
|
* windows earlier in the queue, for efficiency.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
move_resize_cmp (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
MetaWindow *aw = (gpointer) a;
|
|
|
|
MetaWindow *bw = (gpointer) b;
|
|
|
|
|
|
|
|
if (aw->do_not_cover && !bw->do_not_cover)
|
|
|
|
return -1; /* aw before bw */
|
|
|
|
else if (!aw->do_not_cover && bw->do_not_cover)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
idle_move_resize (gpointer data)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
GSList *copy;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Clearing the move_resize queue\n");
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
/* Work with a copy, for reentrancy. The allowed reentrancy isn't
|
|
|
|
* complete; destroying a window while we're in here would result in
|
|
|
|
* badness. But it's OK to queue/unqueue move_resizes.
|
|
|
|
*/
|
|
|
|
copy = g_slist_copy (move_resize_pending);
|
|
|
|
g_slist_free (move_resize_pending);
|
|
|
|
move_resize_pending = NULL;
|
|
|
|
move_resize_idle = 0;
|
|
|
|
|
|
|
|
destroying_windows_disallowed += 1;
|
|
|
|
|
|
|
|
copy = g_slist_sort (copy, move_resize_cmp);
|
|
|
|
|
|
|
|
tmp = copy;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *window;
|
|
|
|
|
|
|
|
window = tmp->data;
|
|
|
|
|
|
|
|
/* As a side effect, sets window->move_resize_queued = FALSE */
|
|
|
|
meta_window_move_resize_now (window);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (copy);
|
|
|
|
|
|
|
|
destroying_windows_disallowed -= 1;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_unqueue_move_resize (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (!window->move_resize_queued)
|
|
|
|
return;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Removing %s from the move_resize queue\n",
|
|
|
|
window->desc);
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
/* Note that window may not actually be in move_resize_pending
|
|
|
|
* because it may have been in "copy" inside the idle handler
|
|
|
|
*/
|
|
|
|
move_resize_pending = g_slist_remove (move_resize_pending, window);
|
|
|
|
window->move_resize_queued = FALSE;
|
|
|
|
|
|
|
|
if (move_resize_pending == NULL &&
|
|
|
|
move_resize_idle != 0)
|
|
|
|
{
|
|
|
|
g_source_remove (move_resize_idle);
|
|
|
|
move_resize_idle = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_flush_move_resize (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->move_resize_queued)
|
|
|
|
{
|
|
|
|
meta_window_unqueue_move_resize (window);
|
|
|
|
meta_window_move_resize_now (window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The move/resize queue is only used when we need to
|
|
|
|
* recheck the constraints on the window, e.g. when
|
|
|
|
* maximizing or when changing struts. Configure requests
|
|
|
|
* and such always have to be handled synchronously,
|
|
|
|
* they can't be done via a queue.
|
|
|
|
*/
|
2001-06-24 04:09:10 -04:00
|
|
|
void
|
|
|
|
meta_window_queue_move_resize (MetaWindow *window)
|
|
|
|
{
|
2002-01-18 22:50:03 -05:00
|
|
|
if (window->unmanaging)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (window->move_resize_queued)
|
|
|
|
return;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Putting %s in the move_resize queue\n",
|
|
|
|
window->desc);
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
window->move_resize_queued = TRUE;
|
|
|
|
|
|
|
|
if (move_resize_idle == 0)
|
|
|
|
move_resize_idle = g_idle_add (idle_move_resize, NULL);
|
|
|
|
|
|
|
|
move_resize_pending = g_slist_prepend (move_resize_pending, window);
|
2001-06-24 04:09:10 -04:00
|
|
|
}
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
void
|
|
|
|
meta_window_get_position (MetaWindow *window,
|
|
|
|
int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
|
|
|
if (window->frame)
|
|
|
|
{
|
2001-07-12 01:53:56 -04:00
|
|
|
if (x)
|
|
|
|
*x = window->frame->rect.x + window->frame->child_x;
|
|
|
|
if (y)
|
|
|
|
*y = window->frame->rect.y + window->frame->child_y;
|
2001-06-09 17:58:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-12 01:53:56 -04:00
|
|
|
if (x)
|
|
|
|
*x = window->rect.x;
|
|
|
|
if (y)
|
|
|
|
*y = window->rect.y;
|
2001-06-09 17:58:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
void
|
|
|
|
meta_window_get_user_position (MetaWindow *window,
|
|
|
|
int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
2001-09-10 22:57:05 -04:00
|
|
|
if (window->user_has_move_resized)
|
2001-08-28 23:37:03 -04:00
|
|
|
{
|
|
|
|
if (x)
|
|
|
|
*x = window->user_rect.x;
|
|
|
|
if (y)
|
|
|
|
*y = window->user_rect.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_window_get_position (window, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-07 14:36:50 -04:00
|
|
|
void
|
|
|
|
meta_window_get_gravity_position (MetaWindow *window,
|
|
|
|
int *root_x,
|
|
|
|
int *root_y)
|
|
|
|
{
|
|
|
|
MetaRectangle frame_extents;
|
|
|
|
int w, h;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
w = window->rect.width;
|
|
|
|
h = window->rect.height;
|
|
|
|
|
2001-08-18 22:29:38 -04:00
|
|
|
if (window->size_hints.win_gravity == StaticGravity)
|
|
|
|
{
|
|
|
|
frame_extents = window->rect;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
frame_extents.x = window->frame->rect.x + window->frame->child_x;
|
|
|
|
frame_extents.y = window->frame->rect.y + window->frame->child_y;
|
|
|
|
}
|
|
|
|
}
|
2001-07-07 14:36:50 -04:00
|
|
|
else
|
2001-08-18 22:29:38 -04:00
|
|
|
{
|
|
|
|
if (window->frame == NULL)
|
|
|
|
frame_extents = window->rect;
|
|
|
|
else
|
|
|
|
frame_extents = window->frame->rect;
|
|
|
|
}
|
2001-07-07 14:36:50 -04:00
|
|
|
|
|
|
|
x = frame_extents.x;
|
|
|
|
y = frame_extents.y;
|
|
|
|
|
|
|
|
switch (window->size_hints.win_gravity)
|
|
|
|
{
|
|
|
|
case NorthGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
/* Find center of frame. */
|
|
|
|
x += frame_extents.width / 2;
|
|
|
|
/* Center client window on that point. */
|
|
|
|
x -= w / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SouthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
case NorthEastGravity:
|
|
|
|
/* Find right edge of frame */
|
|
|
|
x += frame_extents.width;
|
|
|
|
/* Align left edge of client at that point. */
|
|
|
|
x -= w;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (window->size_hints.win_gravity)
|
|
|
|
{
|
|
|
|
case WestGravity:
|
|
|
|
case CenterGravity:
|
|
|
|
case EastGravity:
|
|
|
|
/* Find center of frame. */
|
|
|
|
y += frame_extents.height / 2;
|
|
|
|
/* Center client window there. */
|
|
|
|
y -= h / 2;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
case SouthEastGravity:
|
|
|
|
/* Find south edge of frame */
|
|
|
|
y += frame_extents.height;
|
|
|
|
/* Place bottom edge of client there */
|
|
|
|
y -= h;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (root_x)
|
|
|
|
*root_x = x;
|
|
|
|
if (root_y)
|
|
|
|
*root_y = y;
|
|
|
|
}
|
|
|
|
|
2001-07-28 02:35:19 -04:00
|
|
|
void
|
|
|
|
meta_window_get_geometry (MetaWindow *window,
|
|
|
|
int *x,
|
|
|
|
int *y,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
|
|
|
meta_window_get_gravity_position (window, x, y);
|
|
|
|
|
|
|
|
*width = (window->rect.width - window->size_hints.base_width) /
|
|
|
|
window->size_hints.width_inc;
|
|
|
|
*height = (window->rect.height - window->size_hints.base_height) /
|
|
|
|
window->size_hints.height_inc;
|
|
|
|
}
|
|
|
|
|
2001-07-12 01:53:56 -04:00
|
|
|
void
|
|
|
|
meta_window_get_outer_rect (MetaWindow *window,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
|
|
|
if (window->frame)
|
|
|
|
*rect = window->frame->rect;
|
|
|
|
else
|
|
|
|
*rect = window->rect;
|
|
|
|
}
|
|
|
|
|
2001-06-04 00:58:22 -04:00
|
|
|
void
|
|
|
|
meta_window_focus (MetaWindow *window,
|
|
|
|
Time timestamp)
|
2001-07-11 02:22:00 -04:00
|
|
|
{
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Setting input focus to window %s, input: %d take_focus: %d\n",
|
|
|
|
window->desc, window->input, window->take_focus);
|
|
|
|
|
2001-07-11 02:22:00 -04:00
|
|
|
if (window->display->grab_window &&
|
|
|
|
window->display->grab_window->all_keys_grabbed)
|
|
|
|
{
|
2002-01-05 22:15:49 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Current focus window %s has global keygrab, not focusing window %s after all\n",
|
|
|
|
window->display->grab_window->desc, window->desc);
|
2001-07-11 02:22:00 -04:00
|
|
|
return;
|
|
|
|
}
|
2001-10-29 02:00:46 -05:00
|
|
|
|
|
|
|
meta_window_flush_calc_showing (window);
|
2002-05-10 22:25:11 -04:00
|
|
|
|
|
|
|
if (!window->mapped && !window->shaded)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Window %s is not showing, not focusing after all\n",
|
|
|
|
window->desc);
|
|
|
|
return;
|
|
|
|
}
|
2001-07-11 02:22:00 -04:00
|
|
|
|
2001-06-24 12:37:18 -04:00
|
|
|
/* For output-only or shaded windows, focus the frame.
|
|
|
|
* This seems to result in the client window getting key events
|
|
|
|
* though, so I don't know if it's icccm-compliant.
|
|
|
|
*
|
|
|
|
* Still, we have to do this or keynav breaks for these windows.
|
|
|
|
*/
|
|
|
|
if (window->frame &&
|
|
|
|
(window->shaded ||
|
|
|
|
!(window->input || window->take_focus)))
|
2001-06-04 00:58:22 -04:00
|
|
|
{
|
2001-06-23 01:49:35 -04:00
|
|
|
if (window->frame)
|
|
|
|
{
|
2002-01-05 22:15:49 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Focusing frame of %s\n", window->desc);
|
2001-06-23 01:49:35 -04:00
|
|
|
XSetInputFocus (window->display->xdisplay,
|
|
|
|
window->frame->xwindow,
|
|
|
|
RevertToPointerRoot,
|
|
|
|
CurrentTime);
|
|
|
|
}
|
2001-06-10 15:23:28 -04:00
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
else
|
2001-06-10 15:23:28 -04:00
|
|
|
{
|
2001-06-23 01:49:35 -04:00
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
if (window->input)
|
|
|
|
{
|
2002-01-05 22:15:49 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Calling XSetInputFocus() on client window %s since input = true\n",
|
|
|
|
window->desc);
|
2001-06-23 01:49:35 -04:00
|
|
|
XSetInputFocus (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
RevertToPointerRoot,
|
|
|
|
timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->take_focus)
|
|
|
|
{
|
2002-01-05 22:15:49 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Sending WM_TAKE_FOCUS to %s since take_focus = true\n",
|
|
|
|
window->desc);
|
2001-06-23 01:49:35 -04:00
|
|
|
meta_window_send_icccm_message (window,
|
|
|
|
window->display->atom_wm_take_focus,
|
|
|
|
timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_error_trap_pop (window->display);
|
2001-06-04 00:58:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-09 01:14:43 -04:00
|
|
|
void
|
|
|
|
meta_window_change_workspace (MetaWindow *window,
|
|
|
|
MetaWorkspace *workspace)
|
2002-05-26 11:54:38 -04:00
|
|
|
{
|
2001-06-09 01:14:43 -04:00
|
|
|
meta_verbose ("Changing window %s to workspace %d\n",
|
|
|
|
window->desc, meta_workspace_index (workspace));
|
|
|
|
|
|
|
|
/* See if we're already on this space */
|
|
|
|
if (g_list_find (window->workspaces, workspace) != NULL)
|
|
|
|
{
|
2001-07-03 22:10:54 -04:00
|
|
|
meta_verbose ("%s already on this workspace\n", window->desc);
|
2001-06-09 01:14:43 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add first, to maintain invariant that we're always
|
|
|
|
* on some workspace.
|
|
|
|
*/
|
|
|
|
meta_workspace_add_window (workspace, window);
|
|
|
|
|
2001-06-21 01:23:24 -04:00
|
|
|
/* unstick if stuck */
|
|
|
|
if (window->on_all_workspaces)
|
|
|
|
window->on_all_workspaces = FALSE;
|
|
|
|
|
2001-06-09 01:14:43 -04:00
|
|
|
/* Lamely rely on prepend */
|
|
|
|
g_assert (window->workspaces->data == workspace);
|
|
|
|
|
|
|
|
/* Remove from all other spaces */
|
|
|
|
while (window->workspaces->next) /* while list size > 1 */
|
|
|
|
meta_workspace_remove_window (window->workspaces->next->data, window);
|
|
|
|
}
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
void
|
|
|
|
meta_window_stick (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->on_all_workspaces)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* We don't change window->workspaces, because we revert
|
|
|
|
* to that original workspace list if on_all_workspaces is
|
|
|
|
* toggled back off.
|
|
|
|
*/
|
|
|
|
window->on_all_workspaces = TRUE;
|
|
|
|
|
|
|
|
meta_window_set_current_workspace_hint (window);
|
|
|
|
|
|
|
|
meta_window_queue_calc_showing (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_unstick (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (!window->on_all_workspaces)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Revert to window->workspaces */
|
|
|
|
|
|
|
|
window->on_all_workspaces = FALSE;
|
|
|
|
|
|
|
|
/* We change ourselves to the active workspace, since otherwise you'd get
|
|
|
|
* a weird window-vaporization effect. Once we have UI for being
|
|
|
|
* on more than one workspace this should probably be add_workspace
|
|
|
|
* not change_workspace.
|
|
|
|
*/
|
|
|
|
if (!meta_workspace_contains_window (window->screen->active_workspace,
|
|
|
|
window))
|
|
|
|
meta_window_change_workspace (window, window->screen->active_workspace);
|
|
|
|
|
|
|
|
meta_window_set_current_workspace_hint (window);
|
|
|
|
|
|
|
|
meta_window_queue_calc_showing (window);
|
|
|
|
}
|
|
|
|
|
2001-06-21 01:23:24 -04:00
|
|
|
unsigned long
|
|
|
|
meta_window_get_net_wm_desktop (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->on_all_workspaces ||
|
|
|
|
g_list_length (window->workspaces) > 1)
|
|
|
|
return 0xFFFFFFFF;
|
|
|
|
else
|
|
|
|
return meta_workspace_screen_index (window->workspaces->data);
|
|
|
|
}
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
int
|
|
|
|
meta_window_set_current_workspace_hint (MetaWindow *window)
|
|
|
|
{
|
|
|
|
/* FIXME if on more than one workspace, we claim to be "sticky",
|
|
|
|
* the WM spec doesn't say what to do here.
|
|
|
|
*/
|
|
|
|
unsigned long data[1];
|
|
|
|
|
|
|
|
if (window->workspaces == NULL)
|
2002-03-10 10:48:38 -05:00
|
|
|
{
|
|
|
|
/* this happens when unmanaging windows */
|
|
|
|
return Success;
|
|
|
|
}
|
2001-06-09 23:17:15 -04:00
|
|
|
|
2001-06-21 01:23:24 -04:00
|
|
|
data[0] = meta_window_get_net_wm_desktop (window);
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
meta_verbose ("Setting _NET_WM_DESKTOP of %s to %ld\n",
|
|
|
|
window->desc, data[0]);
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XChangeProperty (window->display->xdisplay, window->xwindow,
|
|
|
|
window->display->atom_net_wm_desktop,
|
|
|
|
XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (guchar*) data, 1);
|
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-06-06 00:47:37 -04:00
|
|
|
void
|
|
|
|
meta_window_raise (MetaWindow *window)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Raising window %s\n", window->desc);
|
2001-06-06 00:47:37 -04:00
|
|
|
|
2001-06-10 14:46:46 -04:00
|
|
|
meta_stack_raise (window->screen->stack, window);
|
2001-06-06 00:47:37 -04:00
|
|
|
}
|
|
|
|
|
2001-09-16 17:50:27 -04:00
|
|
|
void
|
|
|
|
meta_window_lower (MetaWindow *window)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Lowering window %s\n", window->desc);
|
2001-09-16 17:50:27 -04:00
|
|
|
|
|
|
|
meta_stack_lower (window->screen->stack, window);
|
|
|
|
}
|
|
|
|
|
2001-06-04 00:58:22 -04:00
|
|
|
void
|
|
|
|
meta_window_send_icccm_message (MetaWindow *window,
|
|
|
|
Atom atom,
|
|
|
|
Time timestamp)
|
|
|
|
{
|
|
|
|
/* This comment and code are from twm, copyright
|
|
|
|
* Open Group, Evans & Sutherland, etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ICCCM Client Messages - Section 4.2.8 of the ICCCM dictates that all
|
|
|
|
* client messages will have the following form:
|
|
|
|
*
|
|
|
|
* event type ClientMessage
|
|
|
|
* message type _XA_WM_PROTOCOLS
|
|
|
|
* window tmp->w
|
|
|
|
* format 32
|
|
|
|
* data[0] message atom
|
|
|
|
* data[1] time stamp
|
|
|
|
*/
|
|
|
|
|
|
|
|
XClientMessageEvent ev;
|
|
|
|
|
|
|
|
ev.type = ClientMessage;
|
|
|
|
ev.window = window->xwindow;
|
|
|
|
ev.message_type = window->display->atom_wm_protocols;
|
|
|
|
ev.format = 32;
|
|
|
|
ev.data.l[0] = atom;
|
|
|
|
ev.data.l[1] = timestamp;
|
2002-04-21 23:23:29 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
2001-06-04 00:58:22 -04:00
|
|
|
XSendEvent (window->display->xdisplay,
|
|
|
|
window->xwindow, False, 0, (XEvent*) &ev);
|
2002-04-21 23:23:29 -04:00
|
|
|
meta_error_trap_pop (window->display);
|
2001-06-04 00:58:22 -04:00
|
|
|
}
|
|
|
|
|
2001-06-02 21:33:27 -04:00
|
|
|
gboolean
|
|
|
|
meta_window_configure_request (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
2001-07-07 14:36:50 -04:00
|
|
|
int x, y, width, height;
|
2001-08-18 22:45:55 -04:00
|
|
|
gboolean only_resize;
|
2002-04-30 23:23:46 -04:00
|
|
|
gboolean allow_position_change;
|
2001-08-18 22:45:55 -04:00
|
|
|
|
2001-07-07 12:50:01 -04:00
|
|
|
/* it's essential to use only the explicitly-set fields,
|
|
|
|
* and otherwise use our current up-to-date position.
|
|
|
|
*
|
|
|
|
* Otherwise you get spurious position changes when the app changes
|
|
|
|
* size, for example, if window->rect is not in sync with the
|
|
|
|
* server-side position in effect when the configure request was
|
|
|
|
* generated.
|
|
|
|
*/
|
|
|
|
|
2001-07-07 14:36:50 -04:00
|
|
|
meta_window_get_gravity_position (window, &x, &y);
|
2001-07-07 12:50:01 -04:00
|
|
|
|
2001-08-18 22:45:55 -04:00
|
|
|
only_resize = TRUE;
|
2002-04-30 23:23:46 -04:00
|
|
|
|
|
|
|
allow_position_change = FALSE;
|
2001-08-18 22:45:55 -04:00
|
|
|
|
2002-04-30 23:23:46 -04:00
|
|
|
if (meta_prefs_get_disable_workarounds ())
|
|
|
|
{
|
|
|
|
if (window->type == META_WINDOW_DIALOG ||
|
|
|
|
window->type == META_WINDOW_MODAL_DIALOG ||
|
|
|
|
window->type == META_WINDOW_SPLASHSCREEN)
|
|
|
|
; /* No position change for these */
|
|
|
|
else if ((window->size_hints.flags & PPosition) ||
|
|
|
|
/* USPosition is just stale if window is placed;
|
|
|
|
* no --geometry involved here.
|
|
|
|
*/
|
|
|
|
((window->size_hints.flags & USPosition) &&
|
|
|
|
!window->placed))
|
|
|
|
allow_position_change = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-24 22:03:09 -04:00
|
|
|
allow_position_change = TRUE;
|
2002-04-30 23:23:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (allow_position_change)
|
2001-08-17 18:44:36 -04:00
|
|
|
{
|
2001-07-07 14:43:19 -04:00
|
|
|
if (event->xconfigurerequest.value_mask & CWX)
|
|
|
|
x = event->xconfigurerequest.x;
|
|
|
|
|
|
|
|
if (event->xconfigurerequest.value_mask & CWY)
|
|
|
|
y = event->xconfigurerequest.y;
|
2001-08-18 22:45:55 -04:00
|
|
|
|
|
|
|
if (event->xconfigurerequest.value_mask & (CWX | CWY))
|
2002-04-30 23:23:46 -04:00
|
|
|
{
|
|
|
|
only_resize = FALSE;
|
|
|
|
|
|
|
|
/* Once manually positioned, windows shouldn't be placed
|
|
|
|
* by the window manager.
|
|
|
|
*/
|
|
|
|
window->placed = TRUE;
|
|
|
|
}
|
2001-07-07 12:50:01 -04:00
|
|
|
}
|
2002-05-24 22:03:09 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Not allowing position change for window %s PPosition 0x%lx USPosition 0x%lx type %d\n",
|
|
|
|
window->desc, window->size_hints.flags & PPosition,
|
|
|
|
window->size_hints.flags & USPosition,
|
|
|
|
window->type);
|
|
|
|
}
|
2001-07-07 12:50:01 -04:00
|
|
|
|
|
|
|
width = window->rect.width;
|
|
|
|
height = window->rect.height;
|
|
|
|
|
2002-04-30 23:23:46 -04:00
|
|
|
if (event->xconfigurerequest.value_mask & CWWidth)
|
|
|
|
width = event->xconfigurerequest.width;
|
2001-08-29 00:16:30 -04:00
|
|
|
|
2002-04-30 23:23:46 -04:00
|
|
|
if (event->xconfigurerequest.value_mask & CWHeight)
|
|
|
|
height = event->xconfigurerequest.height;
|
2001-07-07 12:50:01 -04:00
|
|
|
|
|
|
|
/* ICCCM 4.1.5 */
|
|
|
|
|
|
|
|
/* Note that x, y is the corner of the window border,
|
|
|
|
* and width, height is the size of the window inside
|
|
|
|
* its border, but that we always deny border requests
|
|
|
|
* and give windows a border of 0. But we save the
|
|
|
|
* requested border here.
|
|
|
|
*/
|
|
|
|
window->border_width = event->xconfigurerequest.border_width;
|
|
|
|
|
|
|
|
/* We're ignoring the value_mask here, since sizes
|
|
|
|
* not in the mask will be the current window geometry.
|
|
|
|
*/
|
|
|
|
|
|
|
|
window->size_hints.x = x;
|
|
|
|
window->size_hints.y = y;
|
|
|
|
window->size_hints.width = width;
|
|
|
|
window->size_hints.height = height;
|
|
|
|
|
2001-08-18 22:45:55 -04:00
|
|
|
/* FIXME passing the gravity on only_resize thing is kind of crack-rock.
|
|
|
|
* Basically I now have several ways of handling gravity, and things
|
|
|
|
* don't make too much sense. I think I am doing the math in a couple
|
|
|
|
* places and could do it in only one function, and remove some of the
|
|
|
|
* move_resize_internal arguments.
|
|
|
|
*/
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move_resize_internal (window, META_IS_CONFIGURE_REQUEST,
|
2001-08-18 22:45:55 -04:00
|
|
|
only_resize ?
|
|
|
|
window->size_hints.win_gravity : NorthWestGravity,
|
2001-07-07 12:50:01 -04:00
|
|
|
window->size_hints.x,
|
|
|
|
window->size_hints.y,
|
|
|
|
window->size_hints.width,
|
|
|
|
window->size_hints.height);
|
2001-07-07 13:08:42 -04:00
|
|
|
|
2002-05-28 22:22:04 -04:00
|
|
|
/* Handle stacking. We only handle raises/lowers, mostly because
|
|
|
|
* stack.c really can't deal with anything else. I guess we'll fix
|
|
|
|
* that if a client turns up that really requires it. Only a very
|
|
|
|
* few clients even require the raise/lower (and in fact all client
|
|
|
|
* attempts to deal with stacking order are essentially broken,
|
|
|
|
* since they have no idea what other clients are involved or how
|
|
|
|
* the stack looks).
|
|
|
|
*
|
|
|
|
* I'm pretty sure no interesting client uses TopIf, BottomIf, or
|
|
|
|
* Opposite anyway, so the only possible missing thing is
|
|
|
|
* Above/Below with a sibling set. For now we just pretend there's
|
|
|
|
* never a sibling set and always do the full raise/lower instead of
|
|
|
|
* the raise-just-above/below-sibling.
|
|
|
|
*/
|
|
|
|
if (event->xconfigurerequest.value_mask & CWStackMode)
|
|
|
|
{
|
|
|
|
switch (event->xconfigurerequest.detail)
|
|
|
|
{
|
|
|
|
case Above:
|
|
|
|
meta_window_raise (window);
|
|
|
|
break;
|
|
|
|
case Below:
|
|
|
|
meta_window_lower (window);
|
|
|
|
break;
|
|
|
|
case TopIf:
|
|
|
|
case BottomIf:
|
|
|
|
case Opposite:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-07 12:50:01 -04:00
|
|
|
return TRUE;
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_window_property_notify (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
|
|
|
return process_property_notify (window, &event->xproperty);
|
|
|
|
}
|
|
|
|
|
2001-08-29 00:16:30 -04:00
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOP 1
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
|
|
|
|
#define _NET_WM_MOVERESIZE_MOVE 8
|
|
|
|
|
2001-06-09 02:08:44 -04:00
|
|
|
gboolean
|
|
|
|
meta_window_client_message (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
|
|
|
MetaDisplay *display;
|
|
|
|
|
|
|
|
display = window->display;
|
|
|
|
|
|
|
|
if (event->xclient.message_type ==
|
|
|
|
display->atom_net_close_window)
|
|
|
|
{
|
|
|
|
/* I think the wm spec should maybe put a time
|
|
|
|
* in this message, CurrentTime here is sort of
|
|
|
|
* bogus. But it rarely matters most likely.
|
|
|
|
*/
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_window_delete (window, meta_display_get_current_time (window->display));
|
2001-06-09 02:08:44 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
|
|
|
display->atom_net_wm_desktop)
|
|
|
|
{
|
|
|
|
int space;
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
|
|
|
|
space = event->xclient.data.l[0];
|
|
|
|
|
|
|
|
meta_verbose ("Request to move %s to screen workspace %d\n",
|
|
|
|
window->desc, space);
|
|
|
|
|
|
|
|
workspace =
|
|
|
|
meta_display_get_workspace_by_screen_index (display,
|
|
|
|
window->screen,
|
|
|
|
space);
|
|
|
|
|
|
|
|
if (workspace)
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
|
|
|
if (window->on_all_workspaces)
|
|
|
|
meta_window_unstick (window);
|
|
|
|
meta_window_change_workspace (window, workspace);
|
|
|
|
}
|
2002-02-06 22:07:56 -05:00
|
|
|
else if (space == (int) 0xFFFFFFFF)
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
|
|
|
meta_window_stick (window);
|
|
|
|
}
|
2001-06-09 02:08:44 -04:00
|
|
|
else
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("No such workspace %d for screen\n", space);
|
|
|
|
}
|
2001-06-09 02:08:44 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->xclient.message_type ==
|
|
|
|
display->atom_net_wm_state)
|
|
|
|
{
|
|
|
|
gulong action;
|
|
|
|
Atom first;
|
|
|
|
Atom second;
|
|
|
|
|
|
|
|
action = event->xclient.data.l[0];
|
|
|
|
first = event->xclient.data.l[1];
|
|
|
|
second = event->xclient.data.l[2];
|
|
|
|
|
|
|
|
if (meta_is_verbose ())
|
|
|
|
{
|
|
|
|
char *str1;
|
|
|
|
char *str2;
|
|
|
|
|
|
|
|
meta_error_trap_push (display);
|
|
|
|
str1 = XGetAtomName (display->xdisplay, first);
|
|
|
|
if (meta_error_trap_pop (display))
|
|
|
|
str1 = NULL;
|
|
|
|
|
|
|
|
meta_error_trap_push (display);
|
|
|
|
str2 = XGetAtomName (display->xdisplay, second);
|
|
|
|
if (meta_error_trap_pop (display))
|
|
|
|
str2 = NULL;
|
|
|
|
|
|
|
|
meta_verbose ("Request to change _NET_WM_STATE action %ld atom1: %s atom2: %s\n",
|
|
|
|
action,
|
|
|
|
str1 ? str1 : "(unknown)",
|
|
|
|
str2 ? str2 : "(unknown)");
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (str1);
|
|
|
|
meta_XFree (str2);
|
2001-06-09 02:08:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (first == display->atom_net_wm_state_shaded ||
|
|
|
|
second == display->atom_net_wm_state_shaded)
|
|
|
|
{
|
|
|
|
gboolean shade;
|
|
|
|
|
|
|
|
shade = (action == _NET_WM_STATE_ADD ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->shaded));
|
2001-10-07 18:11:13 -04:00
|
|
|
if (shade && window->has_shade_func)
|
2001-06-09 02:08:44 -04:00
|
|
|
meta_window_shade (window);
|
|
|
|
else
|
|
|
|
meta_window_unshade (window);
|
|
|
|
}
|
|
|
|
|
2002-02-23 17:58:02 -05:00
|
|
|
if (first == display->atom_net_wm_state_fullscreen ||
|
|
|
|
second == display->atom_net_wm_state_fullscreen)
|
|
|
|
{
|
|
|
|
gboolean make_fullscreen;
|
|
|
|
|
|
|
|
make_fullscreen = (action == _NET_WM_STATE_ADD ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->fullscreen));
|
|
|
|
if (make_fullscreen && window->has_fullscreen_func)
|
|
|
|
meta_window_make_fullscreen (window);
|
|
|
|
else
|
|
|
|
meta_window_unmake_fullscreen (window);
|
|
|
|
}
|
|
|
|
|
2001-06-09 02:08:44 -04:00
|
|
|
if (first == display->atom_net_wm_state_maximized_horz ||
|
|
|
|
second == display->atom_net_wm_state_maximized_horz ||
|
|
|
|
first == display->atom_net_wm_state_maximized_vert ||
|
|
|
|
second == display->atom_net_wm_state_maximized_vert)
|
|
|
|
{
|
|
|
|
gboolean max;
|
|
|
|
|
|
|
|
max = (action == _NET_WM_STATE_ADD ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->maximized));
|
2001-10-07 18:11:13 -04:00
|
|
|
if (max && window->has_maximize_func)
|
2001-06-09 02:08:44 -04:00
|
|
|
meta_window_maximize (window);
|
|
|
|
else
|
|
|
|
meta_window_unmaximize (window);
|
|
|
|
}
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
if (first == display->atom_net_wm_state_modal ||
|
|
|
|
second == display->atom_net_wm_state_modal)
|
|
|
|
{
|
|
|
|
window->wm_state_modal =
|
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_modal);
|
|
|
|
|
|
|
|
recalc_window_type (window);
|
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-11 01:47:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (first == display->atom_net_wm_state_skip_pager ||
|
|
|
|
second == display->atom_net_wm_state_skip_pager)
|
|
|
|
{
|
|
|
|
window->wm_state_skip_pager =
|
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_skip_pager);
|
|
|
|
|
2001-06-10 23:24:20 -04:00
|
|
|
set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
|
2001-06-11 01:47:51 -04:00
|
|
|
if (first == display->atom_net_wm_state_skip_taskbar ||
|
|
|
|
second == display->atom_net_wm_state_skip_taskbar)
|
|
|
|
{
|
|
|
|
window->wm_state_skip_taskbar =
|
|
|
|
(action == _NET_WM_STATE_ADD) ||
|
|
|
|
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_skip_taskbar);
|
|
|
|
|
|
|
|
set_net_wm_state (window);
|
|
|
|
}
|
|
|
|
|
2001-06-09 02:08:44 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-06-09 17:58:30 -04:00
|
|
|
else if (event->xclient.message_type ==
|
|
|
|
display->atom_wm_change_state)
|
|
|
|
{
|
|
|
|
meta_verbose ("WM_CHANGE_STATE client message, state: %ld\n",
|
|
|
|
event->xclient.data.l[0]);
|
2001-10-07 18:11:13 -04:00
|
|
|
if (event->xclient.data.l[0] == IconicState &&
|
|
|
|
window->has_minimize_func)
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_minimize (window);
|
2001-06-09 02:08:44 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-08-29 00:16:30 -04:00
|
|
|
else if (event->xclient.message_type ==
|
|
|
|
display->atom_net_wm_moveresize)
|
|
|
|
{
|
|
|
|
int x_root;
|
|
|
|
int y_root;
|
|
|
|
int action;
|
|
|
|
MetaGrabOp op;
|
|
|
|
|
|
|
|
x_root = event->xclient.data.l[0];
|
|
|
|
y_root = event->xclient.data.l[1];
|
|
|
|
action = event->xclient.data.l[2];
|
|
|
|
|
2002-02-24 14:58:27 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d\n",
|
|
|
|
window->desc,
|
|
|
|
x_root, y_root, action);
|
2001-08-29 00:16:30 -04:00
|
|
|
|
|
|
|
op = META_GRAB_OP_NONE;
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOPLEFT:
|
|
|
|
op = META_GRAB_OP_RESIZING_NW;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOP:
|
|
|
|
op = META_GRAB_OP_RESIZING_N;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_TOPRIGHT:
|
|
|
|
op = META_GRAB_OP_RESIZING_NE;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_RIGHT:
|
|
|
|
op = META_GRAB_OP_RESIZING_E;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT:
|
|
|
|
op = META_GRAB_OP_RESIZING_SE;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOM:
|
|
|
|
op = META_GRAB_OP_RESIZING_S;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT:
|
|
|
|
op = META_GRAB_OP_RESIZING_SW;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_SIZE_LEFT:
|
|
|
|
op = META_GRAB_OP_RESIZING_W;
|
|
|
|
break;
|
|
|
|
case _NET_WM_MOVERESIZE_MOVE:
|
|
|
|
op = META_GRAB_OP_MOVING;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op != META_GRAB_OP_NONE &&
|
|
|
|
((window->has_move_func && op == META_GRAB_OP_MOVING) ||
|
|
|
|
(window->has_resize_func && op != META_GRAB_OP_MOVING)))
|
|
|
|
{
|
|
|
|
int x, y, query_root_x, query_root_y;
|
|
|
|
Window root, child;
|
|
|
|
guint mask;
|
|
|
|
int button;
|
|
|
|
|
|
|
|
/* The race conditions in this _NET_WM_MOVERESIZE thing
|
|
|
|
* are mind-boggling
|
|
|
|
*/
|
|
|
|
mask = 0;
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XQueryPointer (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
&root, &child,
|
|
|
|
&query_root_x, &query_root_y,
|
|
|
|
&x, &y,
|
|
|
|
&mask);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
|
|
|
|
if (mask & Button1Mask)
|
|
|
|
button = 1;
|
|
|
|
else if (mask & Button2Mask)
|
|
|
|
button = 2;
|
|
|
|
else if (mask & Button3Mask)
|
|
|
|
button = 3;
|
|
|
|
else
|
|
|
|
button = 0;
|
|
|
|
|
|
|
|
if (button != 0)
|
|
|
|
{
|
2002-02-24 14:58:27 -05:00
|
|
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
|
|
"Beginning move/resize with button = %d\n", button);
|
2001-08-29 00:16:30 -04:00
|
|
|
meta_display_begin_grab_op (window->display,
|
|
|
|
window,
|
|
|
|
op,
|
|
|
|
FALSE,
|
|
|
|
button, 0,
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_display_get_current_time (window->display),
|
2001-08-29 00:16:30 -04:00
|
|
|
x_root,
|
|
|
|
y_root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-10-07 19:06:19 -04:00
|
|
|
else if (event->xclient.message_type ==
|
|
|
|
display->atom_net_active_window)
|
|
|
|
{
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_verbose ("_NET_ACTIVE_WINDOW request for window '%s', activating",
|
|
|
|
window->desc);
|
2001-10-07 19:06:19 -04:00
|
|
|
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_window_activate (window, meta_display_get_current_time (window->display));
|
2001-10-07 19:06:19 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-01-10 01:31:31 -05:00
|
|
|
else if (event->xclient.message_type ==
|
|
|
|
display->atom_win_hints)
|
|
|
|
{
|
|
|
|
/* gnome-winhints.c seems to indicate that the hints are
|
|
|
|
* in l[1], though god knows why it's like that
|
|
|
|
*/
|
|
|
|
gulong data[1];
|
|
|
|
|
|
|
|
meta_verbose ("_WIN_HINTS client message, hints: %ld\n",
|
|
|
|
event->xclient.data.l[1]);
|
|
|
|
|
|
|
|
if (event->xclient.data.l[1] & WIN_HINTS_DO_NOT_COVER)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Setting WIN_HINTS_DO_NOT_COVER\n");
|
2002-01-10 01:31:31 -05:00
|
|
|
|
|
|
|
data[0] = WIN_HINTS_DO_NOT_COVER;
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XChangeProperty (window->display->xdisplay,
|
|
|
|
window->xwindow, window->display->atom_win_hints,
|
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)data, 1);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Unsetting WIN_HINTS_DO_NOT_COVER\n");
|
2002-01-10 01:31:31 -05:00
|
|
|
|
|
|
|
data[0] = 0;
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XDeleteProperty (window->display->xdisplay,
|
|
|
|
window->xwindow, window->display->atom_win_hints);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2001-06-09 02:08:44 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
gboolean
|
|
|
|
meta_window_notify_focus (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
|
|
|
/* note the event can be on either the window or the frame,
|
|
|
|
* we focus the frame for shaded windows
|
|
|
|
*/
|
2001-07-25 22:55:35 -04:00
|
|
|
|
|
|
|
/* The event can be FocusIn, FocusOut, or UnmapNotify.
|
|
|
|
* On UnmapNotify we have to pretend it's focus out,
|
|
|
|
* because we won't get a focus out if it occurs, apparently.
|
|
|
|
*/
|
2001-06-23 01:49:35 -04:00
|
|
|
|
2001-06-23 23:18:10 -04:00
|
|
|
/* We ignore grabs, though this is questionable.
|
|
|
|
* It may be better to increase the intelligence of
|
|
|
|
* the focus window tracking.
|
|
|
|
*
|
2002-03-11 23:34:17 -05:00
|
|
|
* The problem is that keybindings for windows are done with
|
|
|
|
* XGrabKey, which means focus_window disappears and the front of
|
|
|
|
* the MRU list gets confused from what the user expects once a
|
|
|
|
* keybinding is used.
|
|
|
|
*/
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
2002-01-05 22:15:49 -05:00
|
|
|
"Focus %s event received on %s 0x%lx (%s) "
|
|
|
|
"mode %s detail %s\n",
|
2002-01-03 18:28:19 -05:00
|
|
|
event->type == FocusIn ? "in" :
|
|
|
|
event->type == FocusOut ? "out" :
|
|
|
|
event->type == UnmapNotify ? "unmap" :
|
2002-01-05 22:15:49 -05:00
|
|
|
"???",
|
|
|
|
window->desc, event->xany.window,
|
|
|
|
event->xany.window == window->xwindow ?
|
|
|
|
"client window" :
|
|
|
|
(window->frame && event->xany.window == window->frame->xwindow) ?
|
|
|
|
"frame window" :
|
|
|
|
"unknown window",
|
|
|
|
event->type != UnmapNotify ?
|
2002-03-02 10:26:07 -05:00
|
|
|
meta_event_mode_to_string (event->xfocus.mode) : "n/a",
|
2002-01-05 22:15:49 -05:00
|
|
|
event->type != UnmapNotify ?
|
2002-03-02 10:26:07 -05:00
|
|
|
meta_event_detail_to_string (event->xfocus.detail) : "n/a");
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2001-07-25 22:55:35 -04:00
|
|
|
if ((event->type == FocusIn ||
|
|
|
|
event->type == FocusOut) &&
|
|
|
|
(event->xfocus.mode == NotifyGrab ||
|
2002-01-05 22:15:49 -05:00
|
|
|
event->xfocus.mode == NotifyUngrab ||
|
2002-01-06 22:26:09 -05:00
|
|
|
/* From WindowMaker, ignore all funky pointer root events */
|
2002-01-05 22:15:49 -05:00
|
|
|
event->xfocus.detail > NotifyNonlinearVirtual))
|
2001-06-23 23:41:44 -04:00
|
|
|
{
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
2002-03-11 23:34:17 -05:00
|
|
|
"Ignoring focus event generated by a grab or other weirdness\n");
|
2001-06-23 23:41:44 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-06-23 23:18:10 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
if (event->type == FocusIn)
|
|
|
|
{
|
|
|
|
if (window != window->display->focus_window)
|
2001-06-23 23:18:10 -04:00
|
|
|
{
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
2002-01-10 22:31:14 -05:00
|
|
|
"* Focus --> %s\n", window->desc);
|
2001-06-23 23:18:10 -04:00
|
|
|
window->display->focus_window = window;
|
2002-01-08 02:23:35 -05:00
|
|
|
window->has_focus = TRUE;
|
2002-03-11 23:34:17 -05:00
|
|
|
/* Move to the front of the MRU list */
|
|
|
|
window->display->mru_list =
|
|
|
|
g_list_remove (window->display->mru_list, window);
|
|
|
|
window->display->mru_list =
|
|
|
|
g_list_prepend (window->display->mru_list, window);
|
2002-01-08 02:23:35 -05:00
|
|
|
if (window->frame)
|
|
|
|
meta_frame_queue_draw (window->frame);
|
2002-05-09 18:34:00 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XInstallColormap (window->display->xdisplay,
|
|
|
|
window->colormap);
|
|
|
|
meta_error_trap_pop (window->display);
|
2001-06-23 23:18:10 -04:00
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
}
|
2001-07-25 22:55:35 -04:00
|
|
|
else if (event->type == FocusOut ||
|
|
|
|
event->type == UnmapNotify)
|
2001-06-23 01:49:35 -04:00
|
|
|
{
|
2002-01-06 22:26:09 -05:00
|
|
|
if (event->type == FocusOut &&
|
|
|
|
event->xfocus.detail == NotifyInferior)
|
|
|
|
{
|
|
|
|
/* This event means the client moved focus to a subwindow */
|
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"Ignoring focus out on %s with NotifyInferior\n",
|
|
|
|
window->desc);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
if (window == window->display->focus_window)
|
2001-06-23 23:18:10 -04:00
|
|
|
{
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
|
|
|
"%s is now the previous focus window due to being focused out or unmapped\n",
|
|
|
|
window->desc);
|
2001-06-23 23:18:10 -04:00
|
|
|
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_topic (META_DEBUG_FOCUS,
|
2002-01-10 22:31:14 -05:00
|
|
|
"* Focus --> NULL (was %s)\n", window->desc);
|
2002-01-03 18:28:19 -05:00
|
|
|
|
2001-06-23 23:18:10 -04:00
|
|
|
window->display->focus_window = NULL;
|
2002-01-08 02:23:35 -05:00
|
|
|
window->has_focus = FALSE;
|
|
|
|
if (window->frame)
|
|
|
|
meta_frame_queue_draw (window->frame);
|
2002-05-09 18:34:00 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
XUninstallColormap (window->display->xdisplay,
|
|
|
|
window->colormap);
|
|
|
|
meta_error_trap_pop (window->display);
|
2001-06-23 23:18:10 -04:00
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
}
|
|
|
|
|
2001-10-07 19:06:19 -04:00
|
|
|
/* Now set _NET_ACTIVE_WINDOW hint */
|
|
|
|
meta_display_update_active_window_hint (window->display);
|
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
static gboolean
|
|
|
|
process_property_notify (MetaWindow *window,
|
|
|
|
XPropertyEvent *event)
|
|
|
|
{
|
|
|
|
if (event->atom == XA_WM_NAME ||
|
|
|
|
event->atom == window->display->atom_net_wm_name)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_NAME or NET_WM_NAME\n", window->desc);
|
2001-06-02 00:14:18 -04:00
|
|
|
update_title (window);
|
|
|
|
}
|
|
|
|
else if (event->atom == XA_WM_NORMAL_HINTS)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_NORMAL_HINTS\n", window->desc);
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
update_size_hints (window);
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2001-06-02 21:33:27 -04:00
|
|
|
/* See if we need to constrain current size */
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-02 00:14:18 -04:00
|
|
|
}
|
2001-06-02 21:33:27 -04:00
|
|
|
else if (event->atom == window->display->atom_wm_protocols)
|
2001-06-02 00:14:18 -04:00
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_PROTOCOLS\n", window->desc);
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
update_protocols (window);
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-04 02:17:52 -04:00
|
|
|
}
|
|
|
|
else if (event->atom == XA_WM_HINTS)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_HINTS\n", window->desc);
|
2002-02-09 18:03:52 -05:00
|
|
|
|
|
|
|
meta_icon_cache_property_changed (&window->icon_cache,
|
|
|
|
window->display,
|
|
|
|
event->atom);
|
2001-07-30 23:59:55 -04:00
|
|
|
|
2001-06-04 02:17:52 -04:00
|
|
|
update_wm_hints (window);
|
2002-02-09 18:03:52 -05:00
|
|
|
update_icon (window);
|
2002-05-24 04:16:59 -04:00
|
|
|
redraw_icon (window);
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
2001-06-02 00:14:18 -04:00
|
|
|
}
|
2001-06-08 02:39:38 -04:00
|
|
|
else if (event->atom == window->display->atom_motif_wm_hints)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for MOTIF_WM_HINTS\n", window->desc);
|
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
update_mwm_hints (window);
|
|
|
|
|
|
|
|
if (window->decorated)
|
|
|
|
meta_window_ensure_frame (window);
|
|
|
|
else
|
|
|
|
meta_window_destroy_frame (window);
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
|
|
|
}
|
|
|
|
else if (event->atom == XA_WM_CLASS)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_CLASS\n", window->desc);
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
update_wm_class (window);
|
|
|
|
}
|
|
|
|
else if (event->atom == XA_WM_TRANSIENT_FOR)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_TRANSIENT_FOR\n", window->desc);
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
update_transient_for (window);
|
2001-06-10 14:46:46 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
meta_window_queue_move_resize (window);
|
|
|
|
}
|
|
|
|
else if (event->atom ==
|
|
|
|
window->display->atom_wm_window_role)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for WM_WINDOW_ROLE\n", window->desc);
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
update_role (window);
|
|
|
|
}
|
|
|
|
else if (event->atom ==
|
|
|
|
window->display->atom_wm_client_leader ||
|
|
|
|
event->atom ==
|
|
|
|
window->display->atom_sm_client_id)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_warning ("Broken client! Window %s changed client leader window or SM client ID\n", window->desc);
|
2001-06-08 02:39:38 -04:00
|
|
|
}
|
2001-06-09 23:17:15 -04:00
|
|
|
else if (event->atom ==
|
2001-06-21 02:08:35 -04:00
|
|
|
window->display->atom_net_wm_window_type ||
|
|
|
|
/* update_net_wm_type falls back to this */
|
|
|
|
event->atom == window->display->atom_win_layer)
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for NET_WM_WINDOW_TYPE or WIN_LAYER\n", window->desc);
|
2001-06-09 23:17:15 -04:00
|
|
|
update_net_wm_type (window);
|
|
|
|
}
|
2001-06-23 22:22:10 -04:00
|
|
|
else if (event->atom ==
|
|
|
|
window->display->atom_net_wm_icon_name ||
|
|
|
|
event->atom == XA_WM_ICON_NAME)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for NET_WM_ICON_NAME or WM_ICON_NAME\n", window->desc);
|
|
|
|
|
2001-06-23 22:22:10 -04:00
|
|
|
update_icon_name (window);
|
|
|
|
}
|
|
|
|
else if (event->atom == window->display->atom_net_wm_icon)
|
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Property notify on %s for NET_WM_ICON\n", window->desc);
|
2002-02-09 18:03:52 -05:00
|
|
|
meta_icon_cache_property_changed (&window->icon_cache,
|
|
|
|
window->display,
|
|
|
|
event->atom);
|
|
|
|
update_icon (window);
|
2002-05-24 04:16:59 -04:00
|
|
|
redraw_icon (window);
|
2001-06-23 22:22:10 -04:00
|
|
|
}
|
2001-08-22 02:01:01 -04:00
|
|
|
else if (event->atom == window->display->atom_kwm_win_icon)
|
|
|
|
{
|
|
|
|
meta_verbose ("Property notify on %s for KWM_WIN_ICON\n", window->desc);
|
2002-02-09 18:03:52 -05:00
|
|
|
|
|
|
|
meta_icon_cache_property_changed (&window->icon_cache,
|
|
|
|
window->display,
|
|
|
|
event->atom);
|
|
|
|
update_icon (window);
|
2002-05-24 04:16:59 -04:00
|
|
|
redraw_icon (window);
|
2001-08-22 02:01:01 -04:00
|
|
|
}
|
2002-01-10 01:31:31 -05:00
|
|
|
else if (event->atom == window->display->atom_net_wm_strut)
|
|
|
|
{
|
|
|
|
meta_verbose ("Property notify on %s for _NET_WM_STRUT\n", window->desc);
|
|
|
|
update_struts (window);
|
|
|
|
}
|
|
|
|
else if (event->atom == window->display->atom_win_hints)
|
|
|
|
{
|
|
|
|
meta_verbose ("Property notify on %s for _WIN_HINTS\n", window->desc);
|
|
|
|
update_struts (window);
|
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-06-02 21:33:27 -04:00
|
|
|
static void
|
|
|
|
send_configure_notify (MetaWindow *window)
|
|
|
|
{
|
|
|
|
XEvent event;
|
|
|
|
|
|
|
|
/* from twm */
|
|
|
|
|
|
|
|
event.type = ConfigureNotify;
|
|
|
|
event.xconfigure.display = window->display->xdisplay;
|
|
|
|
event.xconfigure.event = window->xwindow;
|
|
|
|
event.xconfigure.window = window->xwindow;
|
|
|
|
event.xconfigure.x = window->rect.x - window->border_width;
|
|
|
|
event.xconfigure.y = window->rect.y - window->border_width;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
/* Need to be in root window coordinates */
|
|
|
|
event.xconfigure.x += window->frame->rect.x;
|
|
|
|
event.xconfigure.y += window->frame->rect.y;
|
|
|
|
}
|
|
|
|
event.xconfigure.width = window->rect.width;
|
|
|
|
event.xconfigure.height = window->rect.height;
|
|
|
|
event.xconfigure.border_width = window->border_width; /* requested not actual */
|
|
|
|
event.xconfigure.above = None; /* FIXME */
|
|
|
|
event.xconfigure.override_redirect = False;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Sending synthetic configure notify to %s with x: %d y: %d w: %d h: %d\n",
|
|
|
|
window->desc,
|
|
|
|
event.xconfigure.x, event.xconfigure.y,
|
|
|
|
event.xconfigure.width, event.xconfigure.height);
|
2001-06-02 21:33:27 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
2001-06-12 20:56:08 -04:00
|
|
|
XSendEvent (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
False, StructureNotifyMask, &event);
|
2001-06-02 21:33:27 -04:00
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-09-10 22:57:05 -04:00
|
|
|
#define FLAG_TOGGLED_ON(old,new,flag) \
|
|
|
|
(((old)->flags & (flag)) == 0 && \
|
|
|
|
((new)->flags & (flag)) != 0)
|
|
|
|
|
|
|
|
#define FLAG_TOGGLED_OFF(old,new,flag) \
|
|
|
|
(((old)->flags & (flag)) != 0 && \
|
|
|
|
((new)->flags & (flag)) == 0)
|
|
|
|
|
|
|
|
#define FLAG_CHANGED(old,new,flag) \
|
|
|
|
(FLAG_TOGGLED_ON(old,new,flag) || FLAG_TOGGLED_OFF(old,new,flag))
|
|
|
|
|
|
|
|
static void
|
|
|
|
spew_size_hints_differences (const XSizeHints *old,
|
|
|
|
const XSizeHints *new)
|
|
|
|
{
|
|
|
|
if (FLAG_CHANGED (old, new, USPosition))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: USPosition now %s\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, USPosition) ? "set" : "unset");
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, USSize))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: USSize now %s\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, USSize) ? "set" : "unset");
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PPosition))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PPosition now %s\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PPosition) ? "set" : "unset");
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PSize))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PSize now %s\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PSize) ? "set" : "unset");
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PMinSize))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PMinSize now %s (%d x %d -> %d x %d)\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PMinSize) ? "set" : "unset",
|
|
|
|
old->min_width, old->min_height,
|
|
|
|
new->min_width, new->min_height);
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PMaxSize))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PMaxSize now %s (%d x %d -> %d x %d)\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PMaxSize) ? "set" : "unset",
|
|
|
|
old->max_width, old->max_height,
|
|
|
|
new->max_width, new->max_height);
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PResizeInc))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PResizeInc now %s (width_inc %d -> %d height_inc %d -> %d)\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PResizeInc) ? "set" : "unset",
|
|
|
|
old->width_inc, new->width_inc,
|
|
|
|
old->height_inc, new->height_inc);
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PAspect))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PAspect now %s (min %d/%d -> %d/%d max %d/%d -> %d/%d)\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PAspect) ? "set" : "unset",
|
|
|
|
old->min_aspect.x, old->min_aspect.y,
|
|
|
|
new->min_aspect.x, new->min_aspect.y,
|
|
|
|
old->max_aspect.x, old->max_aspect.y,
|
|
|
|
new->max_aspect.x, new->max_aspect.y);
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PBaseSize))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PBaseSize now %s (%d x %d -> %d x %d)\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PBaseSize) ? "set" : "unset",
|
|
|
|
old->base_width, old->base_height,
|
|
|
|
new->base_width, new->base_height);
|
2001-09-10 22:57:05 -04:00
|
|
|
if (FLAG_CHANGED (old, new, PWinGravity))
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "XSizeHints: PWinGravity now %s (%d -> %d)\n",
|
|
|
|
FLAG_TOGGLED_ON (old, new, PWinGravity) ? "set" : "unset",
|
|
|
|
old->win_gravity, new->win_gravity);
|
2001-09-10 22:57:05 -04:00
|
|
|
}
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
static int
|
|
|
|
update_size_hints (MetaWindow *window)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
2001-06-10 23:24:20 -04:00
|
|
|
gulong supplied;
|
2001-09-10 22:57:05 -04:00
|
|
|
XSizeHints old_hints;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Updating WM_NORMAL_HINTS for %s\n", window->desc);
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-09-10 22:57:05 -04:00
|
|
|
old_hints = window->size_hints;
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
/* Save the last ConfigureRequest, which we put here.
|
|
|
|
* Values here set in the hints are supposed to
|
|
|
|
* be ignored.
|
|
|
|
*/
|
|
|
|
x = window->size_hints.x;
|
|
|
|
y = window->size_hints.y;
|
|
|
|
w = window->size_hints.width;
|
|
|
|
h = window->size_hints.height;
|
|
|
|
|
|
|
|
window->size_hints.flags = 0;
|
2001-06-10 23:24:20 -04:00
|
|
|
supplied = 0;
|
2001-06-02 00:14:18 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
2001-06-10 23:24:20 -04:00
|
|
|
XGetWMNormalHints (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
&window->size_hints,
|
|
|
|
&supplied);
|
|
|
|
|
|
|
|
/* as far as I can tell, "supplied" is just
|
|
|
|
* to check whether we had old-style normal hints
|
|
|
|
* without gravity, base size as returned by
|
|
|
|
* XGetNormalHints()
|
|
|
|
*/
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
/* Put it back. */
|
|
|
|
window->size_hints.x = x;
|
|
|
|
window->size_hints.y = y;
|
|
|
|
window->size_hints.width = w;
|
|
|
|
window->size_hints.height = h;
|
|
|
|
|
|
|
|
if (window->size_hints.flags & PBaseSize)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets base size %d x %d\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.base_width,
|
|
|
|
window->size_hints.base_height);
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
else if (window->size_hints.flags & PMinSize)
|
|
|
|
{
|
|
|
|
window->size_hints.base_width = window->size_hints.min_width;
|
|
|
|
window->size_hints.base_height = window->size_hints.min_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->size_hints.base_width = 0;
|
|
|
|
window->size_hints.base_height = 0;
|
|
|
|
}
|
|
|
|
window->size_hints.flags |= PBaseSize;
|
|
|
|
|
|
|
|
if (window->size_hints.flags & PMinSize)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets min size %d x %d\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.min_width,
|
|
|
|
window->size_hints.min_height);
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
else if (window->size_hints.flags & PBaseSize)
|
|
|
|
{
|
|
|
|
window->size_hints.min_width = window->size_hints.base_width;
|
|
|
|
window->size_hints.min_height = window->size_hints.base_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->size_hints.min_width = 0;
|
|
|
|
window->size_hints.min_height = 0;
|
|
|
|
}
|
|
|
|
window->size_hints.flags |= PMinSize;
|
|
|
|
|
|
|
|
if (window->size_hints.flags & PMaxSize)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets max size %d x %d\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.max_width,
|
|
|
|
window->size_hints.max_height);
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
window->size_hints.max_width = G_MAXINT;
|
|
|
|
window->size_hints.max_height = G_MAXINT;
|
|
|
|
window->size_hints.flags |= PMaxSize;
|
|
|
|
}
|
2001-07-02 21:45:43 -04:00
|
|
|
|
|
|
|
if (window->size_hints.max_width < window->size_hints.min_width)
|
|
|
|
{
|
|
|
|
/* someone is on crack */
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Window %s sets max width %d less than min width %d, disabling resize\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.max_width,
|
|
|
|
window->size_hints.min_width);
|
2001-07-02 21:45:43 -04:00
|
|
|
window->size_hints.max_width = window->size_hints.min_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->size_hints.max_height < window->size_hints.min_height)
|
|
|
|
{
|
|
|
|
/* another cracksmoker */
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY,
|
|
|
|
"Window %s sets max height %d less than min height %d, disabling resize\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.max_height,
|
|
|
|
window->size_hints.min_height);
|
2001-07-02 21:45:43 -04:00
|
|
|
window->size_hints.max_height = window->size_hints.min_height;
|
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
|
|
|
|
if (window->size_hints.flags & PResizeInc)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets resize width inc: %d height inc: %d\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.width_inc,
|
|
|
|
window->size_hints.height_inc);
|
2001-06-02 21:33:27 -04:00
|
|
|
if (window->size_hints.width_inc == 0)
|
|
|
|
{
|
|
|
|
window->size_hints.width_inc = 1;
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Corrected 0 width_inc to 1\n");
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
|
|
|
if (window->size_hints.height_inc == 0)
|
|
|
|
{
|
|
|
|
window->size_hints.height_inc = 1;
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Corrected 0 height_inc to 1\n");
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
window->size_hints.width_inc = 1;
|
|
|
|
window->size_hints.height_inc = 1;
|
|
|
|
window->size_hints.flags |= PResizeInc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->size_hints.flags & PAspect)
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets min_aspect: %d/%d max_aspect: %d/%d\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.min_aspect.x,
|
|
|
|
window->size_hints.min_aspect.y,
|
|
|
|
window->size_hints.max_aspect.x,
|
|
|
|
window->size_hints.max_aspect.y);
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
/* don't divide by 0 */
|
|
|
|
if (window->size_hints.min_aspect.y < 1)
|
|
|
|
window->size_hints.min_aspect.y = 1;
|
|
|
|
if (window->size_hints.max_aspect.y < 1)
|
|
|
|
window->size_hints.max_aspect.y = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->size_hints.min_aspect.x = 1;
|
|
|
|
window->size_hints.min_aspect.y = G_MAXINT;
|
|
|
|
window->size_hints.max_aspect.x = G_MAXINT;
|
|
|
|
window->size_hints.max_aspect.y = 1;
|
|
|
|
window->size_hints.flags |= PAspect;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->size_hints.flags & PWinGravity)
|
2001-06-02 21:33:27 -04:00
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets gravity %d\n",
|
|
|
|
window->desc,
|
|
|
|
window->size_hints.win_gravity);
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
else
|
|
|
|
{
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s doesn't set gravity, using NW\n",
|
|
|
|
window->desc);
|
2001-06-02 00:14:18 -04:00
|
|
|
window->size_hints.win_gravity = NorthWestGravity;
|
|
|
|
window->size_hints.flags |= PWinGravity;
|
|
|
|
}
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2001-08-03 00:20:27 -04:00
|
|
|
recalc_window_features (window);
|
2001-09-10 22:57:05 -04:00
|
|
|
|
|
|
|
spew_size_hints_differences (&old_hints, &window->size_hints);
|
2001-08-03 00:20:27 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
update_title (MetaWindow *window)
|
|
|
|
{
|
2002-01-03 22:25:53 -05:00
|
|
|
char *str;
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
if (window->title)
|
|
|
|
{
|
|
|
|
g_free (window->title);
|
|
|
|
window->title = NULL;
|
2001-06-03 14:33:59 -04:00
|
|
|
}
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
str = NULL;
|
|
|
|
meta_prop_get_utf8_string (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_net_wm_name,
|
|
|
|
&str);
|
|
|
|
window->title = g_strdup (str);
|
|
|
|
meta_XFree (str);
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
if (window->title)
|
2001-06-02 00:14:18 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("Using _NET_WM_NAME for new title of %s: '%s'\n",
|
2001-09-11 00:37:10 -04:00
|
|
|
window->desc, window->title);
|
2001-06-02 00:14:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (window->title == NULL)
|
|
|
|
{
|
2001-09-11 00:37:10 -04:00
|
|
|
window->title = get_text_property (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
XA_WM_NAME);
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
if (window->title)
|
2001-06-02 00:14:18 -04:00
|
|
|
{
|
2001-09-11 00:37:10 -04:00
|
|
|
meta_verbose ("Using WM_NAME for new title of %s: '%s'\n",
|
|
|
|
window->desc, window->title);
|
2001-06-02 00:14:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->title == NULL)
|
|
|
|
window->title = g_strdup ("");
|
2001-06-03 14:33:59 -04:00
|
|
|
|
2002-04-15 23:23:21 -04:00
|
|
|
/* strndup is a hack since GNU libc has broken %.10s */
|
|
|
|
str = g_strndup (window->title, 10);
|
2001-06-03 14:33:59 -04:00
|
|
|
g_free (window->desc);
|
2002-04-15 23:23:21 -04:00
|
|
|
window->desc = g_strdup_printf ("0x%lx (%s)", window->xwindow, str);
|
|
|
|
g_free (str);
|
2001-06-19 23:01:26 -04:00
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
meta_ui_set_frame_title (window->screen->ui,
|
|
|
|
window->frame->xwindow,
|
|
|
|
window->title);
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
update_protocols (MetaWindow *window)
|
|
|
|
{
|
2001-06-02 21:33:27 -04:00
|
|
|
Atom *protocols = NULL;
|
|
|
|
int n_protocols = 0;
|
2001-06-02 00:14:18 -04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
window->take_focus = FALSE;
|
|
|
|
window->delete_window = FALSE;
|
2002-04-15 18:14:06 -04:00
|
|
|
window->net_wm_ping = FALSE;
|
2001-06-02 21:33:27 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
if (XGetWMProtocols (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
&protocols,
|
2001-06-04 02:17:52 -04:00
|
|
|
&n_protocols))
|
2001-06-02 00:14:18 -04:00
|
|
|
{
|
2001-06-02 21:33:27 -04:00
|
|
|
i = 0;
|
|
|
|
while (i < n_protocols)
|
|
|
|
{
|
|
|
|
if (protocols[i] == window->display->atom_wm_take_focus)
|
|
|
|
window->take_focus = TRUE;
|
|
|
|
else if (protocols[i] == window->display->atom_wm_delete_window)
|
|
|
|
window->delete_window = TRUE;
|
2002-04-15 18:14:06 -04:00
|
|
|
else if (protocols[i] == window->display->atom_net_wm_ping)
|
|
|
|
window->net_wm_ping = TRUE;
|
2001-06-02 21:33:27 -04:00
|
|
|
++i;
|
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (protocols);
|
2001-06-02 21:33:27 -04:00
|
|
|
}
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2002-04-15 18:14:06 -04:00
|
|
|
meta_verbose ("Window %s has take_focus = %d delete_window = %d net_wm_ping = %d\n",
|
|
|
|
window->desc, window->take_focus, window->delete_window,
|
|
|
|
window->net_wm_ping);
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-06-04 00:58:22 -04:00
|
|
|
static int
|
|
|
|
update_wm_hints (MetaWindow *window)
|
|
|
|
{
|
|
|
|
XWMHints *hints;
|
2001-08-19 21:42:44 -04:00
|
|
|
|
2001-06-04 00:58:22 -04:00
|
|
|
/* Fill in defaults */
|
|
|
|
window->input = FALSE;
|
2001-06-04 02:17:52 -04:00
|
|
|
window->initially_iconic = FALSE;
|
2001-06-23 22:22:10 -04:00
|
|
|
window->xgroup_leader = None;
|
2002-02-09 18:03:52 -05:00
|
|
|
window->wm_hints_pixmap = None;
|
|
|
|
window->wm_hints_mask = None;
|
2001-06-04 00:58:22 -04:00
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
hints = XGetWMHints (window->display->xdisplay,
|
|
|
|
window->xwindow);
|
|
|
|
if (hints)
|
|
|
|
{
|
2002-06-04 18:26:52 -04:00
|
|
|
window->input = ((hints->flags & InputHint) != 0) && hints->input;
|
2001-06-04 02:17:52 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
if (hints->flags & StateHint)
|
|
|
|
window->initially_iconic = (hints->initial_state == IconicState);
|
|
|
|
|
|
|
|
if (hints->flags & WindowGroupHint)
|
|
|
|
window->xgroup_leader = hints->window_group;
|
2001-06-04 00:58:22 -04:00
|
|
|
|
2001-06-23 22:22:10 -04:00
|
|
|
if (hints->flags & IconPixmapHint)
|
2002-02-09 18:03:52 -05:00
|
|
|
window->wm_hints_pixmap = hints->icon_pixmap;
|
2001-06-23 22:22:10 -04:00
|
|
|
|
|
|
|
if (hints->flags & IconMaskHint)
|
2002-02-09 18:03:52 -05:00
|
|
|
window->wm_hints_mask = hints->icon_mask;
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2002-02-09 18:03:52 -05:00
|
|
|
meta_verbose ("Read WM_HINTS input: %d iconic: %d group leader: 0x%lx pixmap: 0x%lx mask: 0x%lx\n",
|
2001-06-09 17:58:30 -04:00
|
|
|
window->input, window->initially_iconic,
|
2002-02-09 18:03:52 -05:00
|
|
|
window->xgroup_leader,
|
|
|
|
window->wm_hints_pixmap,
|
|
|
|
window->wm_hints_mask);
|
2001-06-04 02:17:52 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (hints);
|
2001-06-04 00:58:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
static void
|
2001-06-08 02:39:38 -04:00
|
|
|
update_net_wm_state (MetaWindow *window)
|
|
|
|
{
|
|
|
|
/* We know this is only on initial window creation,
|
|
|
|
* clients don't change the property.
|
|
|
|
*/
|
2002-01-03 19:58:39 -05:00
|
|
|
|
|
|
|
int n_atoms;
|
2001-06-08 02:39:38 -04:00
|
|
|
Atom *atoms;
|
|
|
|
|
|
|
|
window->shaded = FALSE;
|
|
|
|
window->maximized = FALSE;
|
2001-06-09 23:17:15 -04:00
|
|
|
window->wm_state_modal = FALSE;
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
if (meta_prop_get_atom_list (window->display, window->xwindow,
|
|
|
|
window->display->atom_net_wm_state,
|
|
|
|
&atoms, &n_atoms))
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
2002-01-03 19:58:39 -05:00
|
|
|
int i;
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
i = 0;
|
|
|
|
while (i < n_atoms)
|
|
|
|
{
|
|
|
|
if (atoms[i] == window->display->atom_net_wm_state_shaded)
|
|
|
|
window->shaded = TRUE;
|
|
|
|
else if (atoms[i] == window->display->atom_net_wm_state_maximized_horz)
|
|
|
|
window->maximized = TRUE;
|
|
|
|
else if (atoms[i] == window->display->atom_net_wm_state_maximized_vert)
|
|
|
|
window->maximized = TRUE;
|
|
|
|
else if (atoms[i] == window->display->atom_net_wm_state_modal)
|
|
|
|
window->wm_state_modal = TRUE;
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (atoms);
|
2001-06-08 02:39:38 -04:00
|
|
|
}
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
recalc_window_type (window);
|
2001-06-08 02:39:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
static void
|
2001-06-08 02:39:38 -04:00
|
|
|
update_mwm_hints (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MotifWmHints *hints;
|
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
window->mwm_decorated = TRUE;
|
|
|
|
window->mwm_has_close_func = TRUE;
|
|
|
|
window->mwm_has_minimize_func = TRUE;
|
|
|
|
window->mwm_has_maximize_func = TRUE;
|
|
|
|
window->mwm_has_move_func = TRUE;
|
|
|
|
window->mwm_has_resize_func = TRUE;
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
if (!meta_prop_get_motif_hints (window->display, window->xwindow,
|
|
|
|
window->display->atom_motif_wm_hints,
|
|
|
|
&hints))
|
2001-06-21 02:08:35 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("Window %s has no MWM hints\n", window->desc);
|
2002-01-03 19:58:39 -05:00
|
|
|
return;
|
2001-06-21 02:08:35 -04:00
|
|
|
}
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
/* We support those MWM hints deemed non-stupid */
|
2001-06-11 02:39:12 -04:00
|
|
|
|
|
|
|
meta_verbose ("Window %s has MWM hints\n",
|
|
|
|
window->desc);
|
2001-06-08 02:39:38 -04:00
|
|
|
|
|
|
|
if (hints->flags & MWM_HINTS_DECORATIONS)
|
|
|
|
{
|
2001-06-21 02:08:35 -04:00
|
|
|
meta_verbose ("Window %s sets MWM_HINTS_DECORATIONS 0x%lx\n",
|
2001-06-11 02:39:12 -04:00
|
|
|
window->desc, hints->decorations);
|
2001-06-21 02:08:35 -04:00
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
if (hints->decorations == 0)
|
2001-06-23 14:30:27 -04:00
|
|
|
window->mwm_decorated = FALSE;
|
2001-06-08 02:39:38 -04:00
|
|
|
}
|
2001-06-21 02:08:35 -04:00
|
|
|
else
|
|
|
|
meta_verbose ("Decorations flag unset\n");
|
2001-06-23 14:30:27 -04:00
|
|
|
|
2001-06-08 02:39:38 -04:00
|
|
|
if (hints->flags & MWM_HINTS_FUNCTIONS)
|
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
gboolean toggle_value;
|
|
|
|
|
2001-06-21 02:08:35 -04:00
|
|
|
meta_verbose ("Window %s sets MWM_HINTS_FUNCTIONS 0x%lx\n",
|
|
|
|
window->desc, hints->functions);
|
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
/* If _ALL is specified, then other flags indicate what to turn off;
|
|
|
|
* if ALL is not specified, flags are what to turn on.
|
|
|
|
* at least, I think so
|
|
|
|
*/
|
|
|
|
|
2002-02-11 20:02:42 -05:00
|
|
|
if ((hints->functions & MWM_FUNC_ALL) == 0)
|
2001-06-23 14:30:27 -04:00
|
|
|
{
|
|
|
|
toggle_value = TRUE;
|
|
|
|
|
|
|
|
meta_verbose ("Window %s disables all funcs then reenables some\n",
|
|
|
|
window->desc);
|
|
|
|
window->mwm_has_close_func = FALSE;
|
|
|
|
window->mwm_has_minimize_func = FALSE;
|
|
|
|
window->mwm_has_maximize_func = FALSE;
|
|
|
|
window->mwm_has_move_func = FALSE;
|
|
|
|
window->mwm_has_resize_func = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("Window %s enables all funcs then disables some\n",
|
|
|
|
window->desc);
|
|
|
|
toggle_value = FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-22 02:53:33 -04:00
|
|
|
if ((hints->functions & MWM_FUNC_CLOSE) != 0)
|
2001-06-11 02:39:12 -04:00
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
meta_verbose ("Window %s toggles close via MWM hints\n",
|
2001-06-11 02:39:12 -04:00
|
|
|
window->desc);
|
2001-06-23 14:30:27 -04:00
|
|
|
window->mwm_has_close_func = toggle_value;
|
2001-06-11 02:39:12 -04:00
|
|
|
}
|
2001-08-22 02:53:33 -04:00
|
|
|
if ((hints->functions & MWM_FUNC_MINIMIZE) != 0)
|
2001-06-11 02:39:12 -04:00
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
meta_verbose ("Window %s toggles minimize via MWM hints\n",
|
2001-06-11 02:39:12 -04:00
|
|
|
window->desc);
|
2001-06-23 14:30:27 -04:00
|
|
|
window->mwm_has_minimize_func = toggle_value;
|
2001-06-11 02:39:12 -04:00
|
|
|
}
|
2001-08-22 02:53:33 -04:00
|
|
|
if ((hints->functions & MWM_FUNC_MAXIMIZE) != 0)
|
2001-06-11 02:39:12 -04:00
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
meta_verbose ("Window %s toggles maximize via MWM hints\n",
|
|
|
|
window->desc);
|
|
|
|
window->mwm_has_maximize_func = toggle_value;
|
|
|
|
}
|
2001-08-22 02:53:33 -04:00
|
|
|
if ((hints->functions & MWM_FUNC_MOVE) != 0)
|
2001-06-23 14:30:27 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("Window %s toggles move via MWM hints\n",
|
2001-06-11 02:39:12 -04:00
|
|
|
window->desc);
|
2001-06-23 14:30:27 -04:00
|
|
|
window->mwm_has_move_func = toggle_value;
|
|
|
|
}
|
2001-08-22 02:53:33 -04:00
|
|
|
if ((hints->functions & MWM_FUNC_RESIZE) != 0)
|
2001-06-23 14:30:27 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("Window %s toggles resize via MWM hints\n",
|
|
|
|
window->desc);
|
|
|
|
window->mwm_has_resize_func = toggle_value;
|
2001-06-11 02:39:12 -04:00
|
|
|
}
|
2001-06-08 02:39:38 -04:00
|
|
|
}
|
2001-06-21 02:08:35 -04:00
|
|
|
else
|
|
|
|
meta_verbose ("Functions flag unset\n");
|
2001-06-08 02:39:38 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (hints);
|
2001-06-23 14:30:27 -04:00
|
|
|
|
|
|
|
recalc_window_features (window);
|
2001-06-08 02:39:38 -04:00
|
|
|
}
|
|
|
|
|
2001-08-05 12:04:52 -04:00
|
|
|
static gboolean
|
|
|
|
meta_window_get_icon_geometry (MetaWindow *window,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
2002-01-03 19:58:39 -05:00
|
|
|
gulong *geometry = NULL;
|
|
|
|
int nitems;
|
2001-08-19 21:42:44 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
if (meta_prop_get_cardinal_list (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_net_wm_icon_geometry,
|
|
|
|
&geometry, &nitems))
|
2001-08-19 21:42:44 -04:00
|
|
|
{
|
2002-01-03 19:58:39 -05:00
|
|
|
if (nitems != 4)
|
|
|
|
{
|
|
|
|
meta_verbose ("_NET_WM_ICON_GEOMETRY on %s has %d values instead of 4\n",
|
|
|
|
window->desc, nitems);
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (geometry);
|
2002-01-03 19:58:39 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-05 12:04:52 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
if (rect)
|
|
|
|
{
|
|
|
|
rect->x = geometry[0];
|
|
|
|
rect->y = geometry[1];
|
|
|
|
rect->width = geometry[2];
|
|
|
|
rect->height = geometry[3];
|
|
|
|
}
|
2001-08-05 12:04:52 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (geometry);
|
2001-08-05 12:04:52 -04:00
|
|
|
|
2002-01-03 19:58:39 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2001-08-05 12:04:52 -04:00
|
|
|
}
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
static int
|
|
|
|
update_wm_class (MetaWindow *window)
|
|
|
|
{
|
|
|
|
XClassHint ch;
|
|
|
|
|
|
|
|
if (window->res_class)
|
|
|
|
g_free (window->res_class);
|
|
|
|
if (window->res_name)
|
|
|
|
g_free (window->res_name);
|
|
|
|
|
|
|
|
window->res_class = NULL;
|
|
|
|
window->res_name = NULL;
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
ch.res_name = NULL;
|
|
|
|
ch.res_class = NULL;
|
|
|
|
|
|
|
|
XGetClassHint (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
&ch);
|
|
|
|
|
|
|
|
if (ch.res_name)
|
|
|
|
{
|
|
|
|
window->res_name = g_strdup (ch.res_name);
|
|
|
|
XFree (ch.res_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch.res_class)
|
|
|
|
{
|
|
|
|
window->res_class = g_strdup (ch.res_class);
|
|
|
|
XFree (ch.res_class);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_verbose ("Window %s class: '%s' name: '%s'\n",
|
|
|
|
window->desc,
|
|
|
|
window->res_class ? window->res_class : "(null)",
|
|
|
|
window->res_name ? window->res_name : "(null)");
|
|
|
|
|
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Window
|
|
|
|
read_client_leader (MetaDisplay *display,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
2002-01-03 22:25:53 -05:00
|
|
|
Window retval = None;
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_prop_get_window (display, xwindow,
|
|
|
|
display->atom_wm_client_leader,
|
|
|
|
&retval);
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_sm_hints (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindow *w;
|
|
|
|
Window leader;
|
|
|
|
|
|
|
|
window->xclient_leader = None;
|
|
|
|
window->sm_client_id = NULL;
|
|
|
|
|
|
|
|
/* If not on the current window, we can get the client
|
|
|
|
* leader from transient parents. If we find a client
|
|
|
|
* leader, we read the SM_CLIENT_ID from it.
|
|
|
|
*/
|
|
|
|
leader = None;
|
|
|
|
w = window;
|
|
|
|
while (w != NULL)
|
|
|
|
{
|
|
|
|
leader = read_client_leader (window->display, w->xwindow);
|
|
|
|
|
|
|
|
if (leader != None)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (w->xtransient_for == None)
|
|
|
|
break;
|
|
|
|
|
|
|
|
w = meta_display_lookup_x_window (w->display, w->xtransient_for);
|
|
|
|
|
|
|
|
if (w == window)
|
|
|
|
break; /* Cute, someone thought they'd make a transient_for cycle */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (leader)
|
|
|
|
{
|
2002-01-03 22:25:53 -05:00
|
|
|
char *str;
|
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
window->xclient_leader = leader;
|
2002-01-03 22:25:53 -05:00
|
|
|
|
|
|
|
if (meta_prop_get_latin1_string (window->display, leader,
|
|
|
|
window->display->atom_sm_client_id,
|
|
|
|
&str))
|
|
|
|
{
|
|
|
|
window->sm_client_id = g_strdup (str);
|
|
|
|
meta_XFree (str);
|
|
|
|
}
|
2001-06-09 17:58:30 -04:00
|
|
|
|
2001-07-25 23:14:45 -04:00
|
|
|
meta_verbose ("Window %s client leader: 0x%lx SM_CLIENT_ID: '%s'\n",
|
2001-11-02 09:55:00 -05:00
|
|
|
window->desc, window->xclient_leader,
|
2002-01-03 22:25:53 -05:00
|
|
|
window->sm_client_id ? window->sm_client_id : "(null)");
|
2001-06-09 17:58:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
meta_verbose ("Didn't find a client leader for %s\n", window->desc);
|
|
|
|
}
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
static void
|
2001-06-09 17:58:30 -04:00
|
|
|
update_role (MetaWindow *window)
|
|
|
|
{
|
2002-01-03 22:25:53 -05:00
|
|
|
char *str;
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
if (window->role)
|
|
|
|
g_free (window->role);
|
|
|
|
window->role = NULL;
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
if (meta_prop_get_latin1_string (window->display, window->xwindow,
|
|
|
|
window->display->atom_wm_window_role,
|
|
|
|
&str))
|
|
|
|
{
|
|
|
|
window->role = g_strdup (str);
|
|
|
|
meta_XFree (str);
|
|
|
|
}
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
meta_verbose ("Updated role of %s to '%s'\n",
|
2002-05-04 18:53:13 -04:00
|
|
|
window->desc, window->role ? window->role : "null");
|
2001-06-09 17:58:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
update_transient_for (MetaWindow *window)
|
|
|
|
{
|
|
|
|
Window w;
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
w = None;
|
|
|
|
XGetTransientForHint (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
&w);
|
|
|
|
window->xtransient_for = w;
|
|
|
|
|
|
|
|
if (window->xtransient_for != None)
|
2001-07-25 23:14:45 -04:00
|
|
|
meta_verbose ("Window %s transient for 0x%lx\n", window->desc,
|
2001-06-09 17:58:30 -04:00
|
|
|
window->xtransient_for);
|
|
|
|
else
|
|
|
|
meta_verbose ("Window %s is not transient\n", window->desc);
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
/* may now be a dialog */
|
|
|
|
recalc_window_type (window);
|
2001-06-10 14:46:46 -04:00
|
|
|
|
|
|
|
/* update stacking constraints */
|
|
|
|
meta_stack_update_transient (window->screen->stack, window);
|
2001-06-09 17:58:30 -04:00
|
|
|
|
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
static char*
|
|
|
|
get_text_property (MetaDisplay *display,
|
|
|
|
Window xwindow,
|
|
|
|
Atom atom)
|
|
|
|
{
|
|
|
|
XTextProperty text;
|
|
|
|
char *retval;
|
|
|
|
|
|
|
|
meta_error_trap_push (display);
|
|
|
|
|
2001-09-17 01:50:02 -04:00
|
|
|
text.nitems = 0;
|
|
|
|
if (XGetTextProperty (display->xdisplay,
|
|
|
|
xwindow,
|
|
|
|
&text,
|
|
|
|
atom))
|
|
|
|
{
|
|
|
|
retval = meta_text_property_to_utf8 (display->xdisplay, &text);
|
2001-09-11 00:37:10 -04:00
|
|
|
|
2001-09-17 01:50:02 -04:00
|
|
|
if (text.nitems > 0)
|
|
|
|
XFree (text.value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = NULL;
|
|
|
|
meta_verbose ("XGetTextProperty() failed\n");
|
|
|
|
}
|
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
meta_error_trap_pop (display);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2001-06-21 02:08:35 -04:00
|
|
|
/* some legacy cruft */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
WIN_LAYER_DESKTOP = 0,
|
|
|
|
WIN_LAYER_BELOW = 2,
|
|
|
|
WIN_LAYER_NORMAL = 4,
|
|
|
|
WIN_LAYER_ONTOP = 6,
|
|
|
|
WIN_LAYER_DOCK = 8,
|
|
|
|
WIN_LAYER_ABOVE_DOCK = 10
|
|
|
|
} GnomeWinLayer;
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
static void
|
2001-06-09 23:17:15 -04:00
|
|
|
update_net_wm_type (MetaWindow *window)
|
|
|
|
{
|
2002-01-03 22:25:53 -05:00
|
|
|
int n_atoms;
|
2001-06-09 23:17:15 -04:00
|
|
|
Atom *atoms;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
window->type_atom = None;
|
2002-01-03 22:25:53 -05:00
|
|
|
n_atoms = 0;
|
|
|
|
atoms = NULL;
|
2001-06-09 23:17:15 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
if (!meta_prop_get_atom_list (window->display, window->xwindow,
|
|
|
|
window->display->atom_net_wm_window_type,
|
|
|
|
&atoms, &n_atoms))
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
2001-06-21 02:08:35 -04:00
|
|
|
/* Fall back to WIN_LAYER */
|
|
|
|
gulong layer = WIN_LAYER_NORMAL;
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
if (meta_prop_get_cardinal (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_win_layer,
|
|
|
|
&layer))
|
2001-06-21 02:08:35 -04:00
|
|
|
{
|
|
|
|
meta_verbose ("%s falling back to _WIN_LAYER hint, layer %ld\n",
|
|
|
|
window->desc, layer);
|
|
|
|
switch (layer)
|
|
|
|
{
|
|
|
|
case WIN_LAYER_DESKTOP:
|
|
|
|
window->type_atom =
|
|
|
|
window->display->atom_net_wm_window_type_desktop;
|
|
|
|
break;
|
|
|
|
case WIN_LAYER_NORMAL:
|
|
|
|
window->type_atom =
|
|
|
|
window->display->atom_net_wm_window_type_normal;
|
|
|
|
break;
|
|
|
|
case WIN_LAYER_DOCK:
|
|
|
|
window->type_atom =
|
|
|
|
window->display->atom_net_wm_window_type_dock;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
recalc_window_type (window);
|
|
|
|
}
|
2002-01-03 22:25:53 -05:00
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
i = 0;
|
|
|
|
while (i < n_atoms)
|
|
|
|
{
|
|
|
|
/* We break as soon as we find one we recognize,
|
|
|
|
* supposed to prefer those near the front of the list
|
|
|
|
*/
|
|
|
|
if (atoms[i] == window->display->atom_net_wm_window_type_desktop ||
|
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_dock ||
|
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_toolbar ||
|
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_menu ||
|
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_dialog ||
|
2002-02-09 01:54:44 -05:00
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_normal ||
|
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_utility ||
|
|
|
|
atoms[i] == window->display->atom_net_wm_window_type_splashscreen)
|
2001-06-09 23:17:15 -04:00
|
|
|
{
|
|
|
|
window->type_atom = atoms[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (atoms);
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
if (meta_is_verbose ())
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
2002-05-04 18:53:13 -04:00
|
|
|
str = NULL;
|
|
|
|
if (window->type_atom != None)
|
|
|
|
{
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
str = XGetAtomName (window->display->xdisplay, window->type_atom);
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
2001-06-09 23:17:15 -04:00
|
|
|
|
|
|
|
meta_verbose ("Window %s type atom %s\n", window->desc,
|
|
|
|
str ? str : "(none)");
|
|
|
|
|
|
|
|
if (str)
|
2002-01-03 22:25:53 -05:00
|
|
|
meta_XFree (str);
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
recalc_window_type (window);
|
|
|
|
}
|
|
|
|
|
2001-06-12 20:56:08 -04:00
|
|
|
static int
|
|
|
|
update_initial_workspace (MetaWindow *window)
|
|
|
|
{
|
|
|
|
gulong val = 0;
|
|
|
|
|
2001-06-24 02:47:54 -04:00
|
|
|
window->initial_workspace_set = FALSE;
|
|
|
|
|
2001-06-12 20:56:08 -04:00
|
|
|
/* Fall back to old WM spec hint if net_wm_desktop is missing, this
|
|
|
|
* is just to be nice when restarting from old Sawfish basically,
|
|
|
|
* should nuke it eventually
|
|
|
|
*/
|
2002-01-03 22:25:53 -05:00
|
|
|
if (meta_prop_get_cardinal (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_net_wm_desktop,
|
|
|
|
&val))
|
2001-06-24 02:47:54 -04:00
|
|
|
{
|
|
|
|
window->initial_workspace_set = TRUE;
|
|
|
|
window->initial_workspace = val;
|
2002-03-03 23:54:46 -05:00
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Read initial workspace prop %d for %s\n",
|
|
|
|
window->initial_workspace, window->desc);
|
2001-06-24 02:47:54 -04:00
|
|
|
}
|
2002-01-03 22:25:53 -05:00
|
|
|
else if (meta_prop_get_cardinal (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_win_workspace,
|
|
|
|
&val))
|
2001-06-24 02:47:54 -04:00
|
|
|
{
|
|
|
|
window->initial_workspace_set = TRUE;
|
|
|
|
window->initial_workspace = val;
|
2002-03-03 23:54:46 -05:00
|
|
|
|
|
|
|
meta_topic (META_DEBUG_PLACEMENT,
|
|
|
|
"Read legacy GNOME workspace prop %d for %s\n",
|
|
|
|
window->initial_workspace, window->desc);
|
2001-06-24 02:47:54 -04:00
|
|
|
}
|
2001-06-12 20:56:08 -04:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2001-06-23 22:22:10 -04:00
|
|
|
static int
|
|
|
|
update_icon_name (MetaWindow *window)
|
|
|
|
{
|
2002-01-03 22:25:53 -05:00
|
|
|
char *str;
|
|
|
|
|
2001-06-23 22:22:10 -04:00
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
if (window->icon_name)
|
|
|
|
{
|
|
|
|
g_free (window->icon_name);
|
|
|
|
window->icon_name = NULL;
|
|
|
|
}
|
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
str = NULL;
|
|
|
|
meta_prop_get_utf8_string (window->display, window->xwindow,
|
|
|
|
window->display->atom_net_wm_icon_name,
|
|
|
|
&str);
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2002-01-03 22:25:53 -05:00
|
|
|
window->icon_name = g_strdup (str);
|
|
|
|
if (str)
|
|
|
|
meta_XFree (str);
|
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
if (window->icon_name)
|
2001-06-23 22:22:10 -04:00
|
|
|
{
|
2001-08-19 21:42:44 -04:00
|
|
|
meta_verbose ("Using _NET_WM_ICON_NAME for new icon name of %s: '%s'\n",
|
2001-09-11 00:37:10 -04:00
|
|
|
window->desc, window->icon_name);
|
|
|
|
}
|
2001-06-23 22:22:10 -04:00
|
|
|
|
|
|
|
if (window->icon_name == NULL)
|
|
|
|
{
|
2001-09-11 00:37:10 -04:00
|
|
|
window->icon_name = get_text_property (window->display, window->xwindow,
|
|
|
|
XA_WM_ICON_NAME);
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2001-09-11 00:37:10 -04:00
|
|
|
if (window->icon_name)
|
2001-06-23 22:22:10 -04:00
|
|
|
{
|
2001-09-11 00:37:10 -04:00
|
|
|
meta_verbose ("Using WM_ICON_NAME for new title of %s: '%s'\n",
|
|
|
|
window->desc, window->icon_name);
|
2001-06-23 22:22:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->icon_name == NULL)
|
|
|
|
window->icon_name = g_strdup ("");
|
|
|
|
|
|
|
|
return meta_error_trap_pop (window->display);
|
|
|
|
}
|
|
|
|
|
2001-08-19 21:42:44 -04:00
|
|
|
static int
|
2002-02-09 18:03:52 -05:00
|
|
|
update_icon (MetaWindow *window)
|
2001-08-19 21:42:44 -04:00
|
|
|
{
|
2002-02-09 18:03:52 -05:00
|
|
|
GdkPixbuf *icon;
|
|
|
|
GdkPixbuf *mini_icon;
|
2001-08-19 21:42:44 -04:00
|
|
|
|
2002-02-09 18:03:52 -05:00
|
|
|
icon = NULL;
|
|
|
|
mini_icon = NULL;
|
|
|
|
|
|
|
|
if (meta_read_icons (window->screen,
|
|
|
|
window->xwindow,
|
|
|
|
&window->icon_cache,
|
|
|
|
window->wm_hints_pixmap,
|
|
|
|
window->wm_hints_mask,
|
|
|
|
&icon,
|
|
|
|
META_ICON_WIDTH, META_ICON_HEIGHT,
|
|
|
|
&mini_icon,
|
|
|
|
META_MINI_ICON_WIDTH,
|
|
|
|
META_MINI_ICON_HEIGHT))
|
|
|
|
{
|
|
|
|
if (window->icon)
|
|
|
|
g_object_unref (G_OBJECT (window->icon));
|
2001-08-19 21:42:44 -04:00
|
|
|
|
2002-02-09 18:03:52 -05:00
|
|
|
if (window->mini_icon)
|
|
|
|
g_object_unref (G_OBJECT (window->mini_icon));
|
2001-08-19 21:42:44 -04:00
|
|
|
|
2002-02-09 18:03:52 -05:00
|
|
|
window->icon = icon;
|
|
|
|
window->mini_icon = mini_icon;
|
2001-08-23 20:32:17 -04:00
|
|
|
}
|
|
|
|
|
2001-09-17 01:50:02 -04:00
|
|
|
g_assert (window->icon);
|
|
|
|
g_assert (window->mini_icon);
|
2001-06-23 22:22:10 -04:00
|
|
|
|
2001-08-19 21:42:44 -04:00
|
|
|
return Success;
|
2001-06-23 22:22:10 -04:00
|
|
|
}
|
|
|
|
|
2002-05-24 04:16:59 -04:00
|
|
|
static void
|
|
|
|
redraw_icon (MetaWindow *window)
|
|
|
|
{
|
|
|
|
/* We could probably be smart and just redraw the icon here. */
|
2002-05-28 23:54:00 -04:00
|
|
|
if (window->frame)
|
|
|
|
meta_ui_queue_frame_draw (window->screen->ui, window->frame->xwindow);
|
2002-05-24 04:16:59 -04:00
|
|
|
}
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
static GList*
|
|
|
|
meta_window_get_workspaces (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->on_all_workspaces)
|
|
|
|
return window->display->workspaces;
|
|
|
|
else
|
|
|
|
return window->workspaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
invalidate_work_areas (MetaWindow *window)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
tmp = meta_window_get_workspaces (window);
|
|
|
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
meta_workspace_invalidate_work_area (tmp->data);
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_struts (MetaWindow *window)
|
|
|
|
{
|
|
|
|
gulong *struts = NULL;
|
|
|
|
int nitems;
|
2002-06-08 01:13:55 -04:00
|
|
|
gboolean old_has_struts;
|
|
|
|
gboolean old_do_not_cover;
|
|
|
|
int old_left;
|
|
|
|
int old_right;
|
|
|
|
int old_top;
|
|
|
|
int old_bottom;
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
meta_verbose ("Updating struts for %s\n", window->desc);
|
|
|
|
|
2002-06-08 01:13:55 -04:00
|
|
|
old_has_struts = window->has_struts;
|
|
|
|
old_do_not_cover = window->do_not_cover;
|
|
|
|
old_left = window->left_strut;
|
|
|
|
old_right = window->right_strut;
|
|
|
|
old_top = window->top_strut;
|
|
|
|
old_bottom = window->bottom_strut;
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
window->has_struts = FALSE;
|
|
|
|
window->do_not_cover = FALSE;
|
|
|
|
window->left_strut = 0;
|
|
|
|
window->right_strut = 0;
|
|
|
|
window->top_strut = 0;
|
|
|
|
window->bottom_strut = 0;
|
|
|
|
|
|
|
|
if (meta_prop_get_cardinal_list (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_net_wm_strut,
|
|
|
|
&struts, &nitems))
|
|
|
|
{
|
|
|
|
if (nitems != 4)
|
|
|
|
{
|
|
|
|
meta_verbose ("_NET_WM_STRUT on %s has %d values instead of 4\n",
|
|
|
|
window->desc, nitems);
|
|
|
|
meta_XFree (struts);
|
|
|
|
}
|
|
|
|
|
|
|
|
window->has_struts = TRUE;
|
|
|
|
window->left_strut = struts[0];
|
|
|
|
window->right_strut = struts[1];
|
|
|
|
window->top_strut = struts[2];
|
|
|
|
window->bottom_strut = struts[3];
|
|
|
|
|
|
|
|
meta_verbose ("Using _NET_WM_STRUT struts %d %d %d %d for window %s\n",
|
|
|
|
window->left_strut, window->right_strut,
|
|
|
|
window->top_strut, window->bottom_strut,
|
|
|
|
window->desc);
|
|
|
|
|
|
|
|
meta_XFree (struts);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("No _NET_WM_STRUT property for %s\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!window->has_struts)
|
|
|
|
{
|
|
|
|
/* Try _WIN_HINTS */
|
|
|
|
gulong hints;
|
|
|
|
|
|
|
|
if (meta_prop_get_cardinal (window->display,
|
|
|
|
window->xwindow,
|
|
|
|
window->display->atom_win_hints,
|
|
|
|
&hints))
|
|
|
|
{
|
|
|
|
if (hints & WIN_HINTS_DO_NOT_COVER)
|
|
|
|
{
|
|
|
|
window->has_struts = TRUE;
|
|
|
|
window->do_not_cover = TRUE;
|
|
|
|
recalc_do_not_cover_struts (window);
|
|
|
|
|
|
|
|
meta_verbose ("Using _WIN_HINTS struts %d %d %d %d for window %s\n",
|
|
|
|
window->left_strut, window->right_strut,
|
|
|
|
window->top_strut, window->bottom_strut,
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("DO_NOT_COVER hint not set in _WIN_HINTS\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("No _WIN_HINTS property on %s\n",
|
|
|
|
window->desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-08 01:13:55 -04:00
|
|
|
if (old_has_struts != window->has_struts ||
|
|
|
|
old_do_not_cover != window->do_not_cover ||
|
|
|
|
old_left != window->left_strut ||
|
|
|
|
old_right != window->right_strut ||
|
|
|
|
old_top != window->top_strut ||
|
|
|
|
old_bottom != window->bottom_strut)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Invalidating work areas of window %s due to struts update\n",
|
|
|
|
window->desc);
|
|
|
|
invalidate_work_areas (window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Struts on %s were unchanged\n", window->desc);
|
|
|
|
}
|
2002-01-10 01:31:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
recalc_do_not_cover_struts (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->do_not_cover)
|
|
|
|
{
|
|
|
|
/* We only understand windows that are aligned to
|
|
|
|
* a screen edge
|
|
|
|
*/
|
|
|
|
gboolean horizontal;
|
|
|
|
gboolean on_left_edge;
|
|
|
|
gboolean on_right_edge;
|
|
|
|
gboolean on_bottom_edge;
|
|
|
|
gboolean on_top_edge;
|
|
|
|
|
|
|
|
window->left_strut = 0;
|
|
|
|
window->right_strut = 0;
|
|
|
|
window->top_strut = 0;
|
|
|
|
window->bottom_strut = 0;
|
|
|
|
|
|
|
|
on_left_edge = window->rect.x == 0;
|
|
|
|
on_right_edge = (window->rect.x + window->rect.width) ==
|
|
|
|
window->screen->width;
|
|
|
|
on_top_edge = window->rect.y == 0;
|
|
|
|
on_bottom_edge = (window->rect.y + window->rect.height) ==
|
|
|
|
window->screen->height;
|
|
|
|
|
|
|
|
/* cheesy heuristic to decide where the strut goes */
|
|
|
|
if (on_left_edge && on_right_edge && on_bottom_edge)
|
|
|
|
horizontal = TRUE;
|
|
|
|
else if (on_left_edge && on_right_edge && on_top_edge)
|
|
|
|
horizontal = TRUE;
|
|
|
|
else if (on_top_edge && on_bottom_edge && on_left_edge)
|
|
|
|
horizontal = FALSE;
|
|
|
|
else if (on_top_edge && on_bottom_edge && on_right_edge)
|
|
|
|
horizontal = FALSE;
|
|
|
|
else
|
|
|
|
horizontal = window->rect.width > window->rect.height;
|
|
|
|
|
|
|
|
if (horizontal)
|
|
|
|
{
|
|
|
|
if (on_top_edge)
|
|
|
|
window->top_strut = window->rect.height;
|
|
|
|
else if (on_bottom_edge)
|
|
|
|
window->bottom_strut = window->rect.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (on_left_edge)
|
|
|
|
window->left_strut = window->rect.width;
|
|
|
|
else if (on_right_edge)
|
|
|
|
window->right_strut = window->rect.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
static void
|
|
|
|
recalc_window_type (MetaWindow *window)
|
|
|
|
{
|
2002-02-06 22:07:56 -05:00
|
|
|
MetaWindowType old_type;
|
2001-06-11 01:47:51 -04:00
|
|
|
|
|
|
|
old_type = window->type;
|
|
|
|
|
2001-06-09 23:17:15 -04:00
|
|
|
if (window->type_atom != None)
|
|
|
|
{
|
|
|
|
if (window->type_atom == window->display->atom_net_wm_window_type_desktop)
|
|
|
|
window->type = META_WINDOW_DESKTOP;
|
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_dock)
|
|
|
|
window->type = META_WINDOW_DOCK;
|
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_toolbar)
|
|
|
|
window->type = META_WINDOW_TOOLBAR;
|
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_menu)
|
|
|
|
window->type = META_WINDOW_MENU;
|
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_dialog)
|
|
|
|
window->type = META_WINDOW_DIALOG;
|
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_normal)
|
|
|
|
window->type = META_WINDOW_NORMAL;
|
2002-02-09 01:54:44 -05:00
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_utility)
|
|
|
|
window->type = META_WINDOW_UTILITY;
|
|
|
|
else if (window->type_atom == window->display->atom_net_wm_window_type_splashscreen)
|
|
|
|
window->type = META_WINDOW_SPLASHSCREEN;
|
2002-02-08 23:15:41 -05:00
|
|
|
else
|
2002-02-09 01:54:44 -05:00
|
|
|
meta_bug ("Set a type atom for %s that wasn't handled in recalc_window_type\n",
|
|
|
|
window->desc);
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
|
|
|
else if (window->xtransient_for != None)
|
|
|
|
{
|
|
|
|
window->type = META_WINDOW_DIALOG;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->type = META_WINDOW_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->type == META_WINDOW_DIALOG &&
|
|
|
|
window->wm_state_modal)
|
|
|
|
window->type = META_WINDOW_MODAL_DIALOG;
|
2001-08-19 23:17:40 -04:00
|
|
|
|
2001-07-30 23:59:55 -04:00
|
|
|
meta_verbose ("Calculated type %d for %s, old type %d\n",
|
|
|
|
window->type, window->desc, old_type);
|
2001-06-10 14:46:46 -04:00
|
|
|
|
2001-06-11 01:47:51 -04:00
|
|
|
if (old_type != window->type)
|
|
|
|
{
|
2001-06-23 14:30:27 -04:00
|
|
|
recalc_window_features (window);
|
|
|
|
|
2001-06-11 01:47:51 -04:00
|
|
|
set_net_wm_state (window);
|
2001-07-30 23:59:55 -04:00
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
/* Update frame */
|
|
|
|
if (window->decorated)
|
|
|
|
meta_window_ensure_frame (window);
|
|
|
|
else
|
|
|
|
meta_window_destroy_frame (window);
|
|
|
|
|
2001-06-11 01:47:51 -04:00
|
|
|
/* update stacking constraints */
|
|
|
|
meta_stack_update_layer (window->screen->stack, window);
|
|
|
|
}
|
2001-06-09 23:17:15 -04:00
|
|
|
}
|
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
static void
|
|
|
|
recalc_window_features (MetaWindow *window)
|
|
|
|
{
|
|
|
|
/* Use MWM hints initially */
|
|
|
|
window->decorated = window->mwm_decorated;
|
|
|
|
window->has_close_func = window->mwm_has_close_func;
|
|
|
|
window->has_minimize_func = window->mwm_has_minimize_func;
|
|
|
|
window->has_maximize_func = window->mwm_has_maximize_func;
|
|
|
|
window->has_move_func = window->mwm_has_move_func;
|
|
|
|
window->has_resize_func = window->mwm_has_resize_func;
|
|
|
|
|
|
|
|
window->has_shade_func = TRUE;
|
2002-02-23 17:58:02 -05:00
|
|
|
window->has_fullscreen_func = TRUE;
|
2002-05-26 11:54:38 -04:00
|
|
|
|
|
|
|
window->always_sticky = FALSE;
|
2002-02-23 17:58:02 -05:00
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
/* Semantic category overrides the MWM hints */
|
2002-04-30 23:23:46 -04:00
|
|
|
if (window->type == META_WINDOW_TOOLBAR)
|
|
|
|
window->decorated = FALSE;
|
2002-05-26 11:54:38 -04:00
|
|
|
|
|
|
|
if (window->type == META_WINDOW_DESKTOP ||
|
|
|
|
window->type == META_WINDOW_DOCK)
|
|
|
|
window->always_sticky = TRUE;
|
2001-06-23 14:30:27 -04:00
|
|
|
|
|
|
|
if (window->type == META_WINDOW_DESKTOP ||
|
2002-02-09 01:54:44 -05:00
|
|
|
window->type == META_WINDOW_DOCK ||
|
|
|
|
window->type == META_WINDOW_SPLASHSCREEN)
|
2001-06-23 14:30:27 -04:00
|
|
|
{
|
2001-07-30 23:59:55 -04:00
|
|
|
window->decorated = FALSE;
|
2001-06-23 14:30:27 -04:00
|
|
|
window->has_close_func = FALSE;
|
|
|
|
window->has_shade_func = FALSE;
|
2002-04-30 23:23:46 -04:00
|
|
|
|
|
|
|
/* FIXME this keeps panels and things from using
|
|
|
|
* NET_WM_MOVERESIZE; the problem is that some
|
|
|
|
* panels (edge panels) have fixed possible locations,
|
|
|
|
* and others ("floating panels") do not.
|
|
|
|
*
|
|
|
|
* Perhaps we should require edge panels to explicitly
|
|
|
|
* disable movement?
|
|
|
|
*/
|
2001-06-23 14:30:27 -04:00
|
|
|
window->has_move_func = FALSE;
|
|
|
|
window->has_resize_func = FALSE;
|
|
|
|
}
|
2002-03-02 19:03:50 -05:00
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
if (window->type != META_WINDOW_NORMAL)
|
|
|
|
{
|
|
|
|
window->has_minimize_func = FALSE;
|
|
|
|
window->has_maximize_func = FALSE;
|
2002-02-23 17:58:02 -05:00
|
|
|
window->has_fullscreen_func = FALSE;
|
2001-06-23 14:30:27 -04:00
|
|
|
}
|
|
|
|
|
2002-03-02 19:03:50 -05:00
|
|
|
/* We leave fullscreen windows decorated, just push the frame outside
|
|
|
|
* the screen. This avoids flickering to unparent them.
|
|
|
|
*/
|
|
|
|
if (window->fullscreen)
|
|
|
|
{
|
|
|
|
window->has_shade_func = FALSE;
|
|
|
|
window->has_move_func = FALSE;
|
|
|
|
window->has_resize_func = FALSE;
|
|
|
|
window->has_maximize_func = FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-03 00:20:27 -04:00
|
|
|
/* If min_size == max_size, then don't allow resize */
|
|
|
|
if (window->size_hints.min_width == window->size_hints.max_width &&
|
|
|
|
window->size_hints.min_height == window->size_hints.max_height)
|
|
|
|
window->has_resize_func = FALSE;
|
|
|
|
|
2002-02-23 17:58:02 -05:00
|
|
|
/* don't allow fullscreen if we can't resize */
|
2001-08-03 00:20:27 -04:00
|
|
|
if (!window->has_resize_func)
|
2002-02-23 17:58:02 -05:00
|
|
|
{
|
|
|
|
window->has_maximize_func = FALSE;
|
|
|
|
window->has_fullscreen_func = FALSE;
|
|
|
|
}
|
2001-08-03 00:20:27 -04:00
|
|
|
|
|
|
|
/* no shading if not decorated */
|
|
|
|
if (!window->decorated)
|
|
|
|
window->has_shade_func = FALSE;
|
|
|
|
|
2001-06-23 14:30:27 -04:00
|
|
|
/* FIXME perhaps should ensure if we don't have a shade func,
|
|
|
|
* we aren't shaded, etc.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2001-06-02 00:14:18 -04:00
|
|
|
static void
|
|
|
|
constrain_size (MetaWindow *window,
|
2001-06-10 23:24:20 -04:00
|
|
|
MetaFrameGeometry *fgeom,
|
2001-06-02 00:14:18 -04:00
|
|
|
int width, int height,
|
|
|
|
int *new_width, int *new_height)
|
|
|
|
{
|
|
|
|
/* This is partially borrowed from GTK (LGPL), which in turn
|
|
|
|
* partially borrowed from fvwm,
|
|
|
|
*
|
|
|
|
* Copyright 1993, Robert Nation
|
|
|
|
* You may use this code for any purpose, as long as the original
|
|
|
|
* copyright remains in the source code and all documentation
|
|
|
|
*
|
|
|
|
* which in turn borrows parts of the algorithm from uwm
|
|
|
|
*/
|
|
|
|
int delta;
|
|
|
|
double min_aspect, max_aspect;
|
2001-06-07 01:18:10 -04:00
|
|
|
int minw, minh, maxw, maxh, fullw, fullh;
|
2002-01-10 01:31:31 -05:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
/* frame member variables should NEVER be used in here */
|
2001-06-02 00:14:18 -04:00
|
|
|
|
2001-08-05 12:04:52 -04:00
|
|
|
#define FLOOR(value, base) ( ((int) ((value) / (base))) * (base) )
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-06-07 01:18:10 -04:00
|
|
|
/* Get the allowed size ranges, considering maximized, etc. */
|
2002-06-06 23:18:46 -04:00
|
|
|
if (window->fullscreen)
|
|
|
|
{
|
|
|
|
const MetaXineramaScreenInfo *xinerama;
|
|
|
|
|
|
|
|
xinerama = meta_screen_get_xinerama_for_window (window->screen,
|
|
|
|
window);
|
|
|
|
|
|
|
|
|
|
|
|
fullw = xinerama->width;
|
|
|
|
fullh = xinerama->height;
|
|
|
|
}
|
|
|
|
else if (window->type == META_WINDOW_DESKTOP ||
|
|
|
|
window->type == META_WINDOW_DOCK)
|
2001-08-19 23:17:40 -04:00
|
|
|
{
|
2002-06-06 23:18:46 -04:00
|
|
|
|
2001-08-19 23:17:40 -04:00
|
|
|
fullw = window->screen->width;
|
|
|
|
fullh = window->screen->height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-06-08 02:29:19 -04:00
|
|
|
MetaRectangle work_area;
|
|
|
|
|
|
|
|
meta_window_get_work_area (window, TRUE, &work_area);
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
fullw = work_area.width;
|
|
|
|
fullh = work_area.height;
|
2001-08-19 23:17:40 -04:00
|
|
|
}
|
|
|
|
|
2002-02-23 17:58:02 -05:00
|
|
|
if (window->frame && !window->fullscreen)
|
2001-06-07 01:18:10 -04:00
|
|
|
{
|
2001-09-10 22:57:05 -04:00
|
|
|
fullw -= (fgeom->left_width + fgeom->right_width);
|
|
|
|
fullh -= (fgeom->top_height + fgeom->bottom_height);
|
2001-06-07 01:18:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
maxw = window->size_hints.max_width;
|
|
|
|
maxh = window->size_hints.max_height;
|
2001-09-08 23:44:42 -04:00
|
|
|
|
2002-03-02 19:03:50 -05:00
|
|
|
if (window->maximized || window->fullscreen)
|
2001-06-07 01:18:10 -04:00
|
|
|
{
|
|
|
|
maxw = MIN (maxw, fullw);
|
|
|
|
maxh = MIN (maxh, fullh);
|
|
|
|
}
|
|
|
|
|
|
|
|
minw = window->size_hints.min_width;
|
|
|
|
minh = window->size_hints.min_height;
|
2001-06-10 23:24:20 -04:00
|
|
|
|
|
|
|
/* Check that fullscreen doesn't go under app-specified min size, if
|
|
|
|
* so snap back to min size
|
|
|
|
*/
|
|
|
|
if (maxw < minw)
|
|
|
|
maxw = minw;
|
|
|
|
if (maxh < minh)
|
|
|
|
maxh = minh;
|
|
|
|
|
2002-03-02 19:03:50 -05:00
|
|
|
if (window->maximized || window->fullscreen)
|
2001-06-07 01:18:10 -04:00
|
|
|
{
|
|
|
|
minw = MAX (minw, fullw);
|
|
|
|
minh = MAX (minh, fullh);
|
|
|
|
}
|
2001-06-10 23:24:20 -04:00
|
|
|
|
2001-06-07 01:18:10 -04:00
|
|
|
/* Check that fullscreen doesn't exceed max width hint,
|
|
|
|
* if so then snap back to max width hint
|
|
|
|
*/
|
|
|
|
if (minw > maxw)
|
|
|
|
minw = maxw;
|
|
|
|
if (minh > maxh)
|
|
|
|
minh = maxh;
|
2001-06-02 00:14:18 -04:00
|
|
|
|
|
|
|
/* clamp width and height to min and max values
|
|
|
|
*/
|
2001-06-07 01:18:10 -04:00
|
|
|
width = CLAMP (width, minw, maxw);
|
|
|
|
|
|
|
|
height = CLAMP (height, minh, maxh);
|
2001-06-02 00:14:18 -04:00
|
|
|
|
|
|
|
/* shrink to base + N * inc
|
|
|
|
*/
|
|
|
|
width = window->size_hints.base_width +
|
|
|
|
FLOOR (width - window->size_hints.base_width, window->size_hints.width_inc);
|
|
|
|
height = window->size_hints.base_height +
|
|
|
|
FLOOR (height - window->size_hints.base_height, window->size_hints.height_inc);
|
|
|
|
|
|
|
|
/* constrain aspect ratio, according to:
|
|
|
|
*
|
|
|
|
* width
|
|
|
|
* min_aspect <= -------- <= max_aspect
|
|
|
|
* height
|
|
|
|
*/
|
|
|
|
|
|
|
|
min_aspect = window->size_hints.min_aspect.x / (double) window->size_hints.min_aspect.y;
|
|
|
|
max_aspect = window->size_hints.max_aspect.x / (double) window->size_hints.max_aspect.y;
|
|
|
|
|
|
|
|
if (min_aspect * height > width)
|
|
|
|
{
|
|
|
|
delta = FLOOR (height - width * min_aspect, window->size_hints.height_inc);
|
|
|
|
if (height - delta >= window->size_hints.min_height)
|
|
|
|
height -= delta;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delta = FLOOR (height * min_aspect - width, window->size_hints.width_inc);
|
|
|
|
if (width + delta <= window->size_hints.max_width)
|
|
|
|
width += delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (max_aspect * height < width)
|
|
|
|
{
|
|
|
|
delta = FLOOR (width - height * max_aspect, window->size_hints.width_inc);
|
|
|
|
if (width - delta >= window->size_hints.min_width)
|
|
|
|
width -= delta;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delta = FLOOR (width / max_aspect - height, window->size_hints.height_inc);
|
|
|
|
if (height + delta <= window->size_hints.max_height)
|
|
|
|
height += delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef FLOOR
|
|
|
|
|
|
|
|
*new_width = width;
|
|
|
|
*new_height = height;
|
|
|
|
}
|
2001-06-02 21:33:27 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
static void
|
2002-06-09 14:17:02 -04:00
|
|
|
constrain_position (MetaWindow *window,
|
2001-06-09 17:58:30 -04:00
|
|
|
MetaFrameGeometry *fgeom,
|
2002-06-09 14:17:02 -04:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int *new_x,
|
|
|
|
int *new_y)
|
2002-06-08 02:07:21 -04:00
|
|
|
{
|
2001-06-09 17:58:30 -04:00
|
|
|
/* frame member variables should NEVER be used in here, only
|
|
|
|
* MetaFrameGeometry
|
|
|
|
*/
|
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
if (!window->placed && window->calc_placement)
|
2001-06-24 02:47:54 -04:00
|
|
|
meta_window_place (window, fgeom, x, y, &x, &y);
|
2001-08-25 22:09:53 -04:00
|
|
|
|
2002-05-16 16:47:29 -04:00
|
|
|
if (window->type == META_WINDOW_DESKTOP)
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
else if (window->type == META_WINDOW_DOCK)
|
|
|
|
{
|
|
|
|
; /* let it do whatever */
|
|
|
|
}
|
|
|
|
else if (window->fullscreen)
|
2001-08-25 22:09:53 -04:00
|
|
|
{
|
2002-06-06 23:18:46 -04:00
|
|
|
const MetaXineramaScreenInfo *xinerama;
|
|
|
|
|
|
|
|
xinerama = meta_screen_get_xinerama_for_window (window->screen,
|
|
|
|
window);
|
|
|
|
|
|
|
|
x = xinerama->x_origin;
|
|
|
|
y = xinerama->y_origin;
|
2002-05-10 23:37:51 -04:00
|
|
|
|
|
|
|
/* If the window's geometry gridding (e.g. for a terminal)
|
|
|
|
* prevents fullscreen, center the window within
|
|
|
|
* the screen area.
|
|
|
|
*/
|
2002-06-06 23:18:46 -04:00
|
|
|
x += (xinerama->width - window->rect.width) / 2;
|
|
|
|
y += (xinerama->height - window->rect.height) / 2;
|
2002-05-10 23:37:51 -04:00
|
|
|
|
2002-06-06 23:18:46 -04:00
|
|
|
/* If the window is somehow larger than the screen be paranoid
|
|
|
|
* and fix the resulting negative coords
|
|
|
|
*/
|
|
|
|
if (x < xinerama->x_origin)
|
|
|
|
x = xinerama->x_origin;
|
|
|
|
if (y < xinerama->y_origin)
|
|
|
|
y = xinerama->y_origin;
|
2001-08-25 22:09:53 -04:00
|
|
|
}
|
2002-04-30 15:52:30 -04:00
|
|
|
else if (window->maximized)
|
|
|
|
{
|
2002-06-08 02:07:21 -04:00
|
|
|
MetaRectangle work_area;
|
|
|
|
|
|
|
|
meta_window_get_work_area (window, TRUE, &work_area);
|
|
|
|
|
2002-04-30 15:52:30 -04:00
|
|
|
x = work_area.x;
|
|
|
|
y = work_area.y;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
x += fgeom->left_width;
|
|
|
|
y += fgeom->top_height;
|
|
|
|
}
|
2002-05-10 23:37:51 -04:00
|
|
|
|
|
|
|
/* If the window's geometry gridding (e.g. for a terminal)
|
|
|
|
* prevents full maximization, center the window within
|
|
|
|
* the maximized area.
|
|
|
|
*/
|
|
|
|
x += (work_area.width - window->rect.width -
|
|
|
|
(window->frame ? (fgeom->left_width + fgeom->right_width) : 0)) / 2;
|
|
|
|
|
|
|
|
y += (work_area.height - window->rect.height -
|
|
|
|
(window->frame ? (fgeom->top_height + fgeom->bottom_height) : 0)) / 2;
|
2002-04-30 15:52:30 -04:00
|
|
|
}
|
2002-05-16 16:47:29 -04:00
|
|
|
else
|
2001-06-09 17:58:30 -04:00
|
|
|
{
|
2001-06-10 14:46:46 -04:00
|
|
|
int nw_x, nw_y;
|
|
|
|
int se_x, se_y;
|
2001-07-05 01:22:00 -04:00
|
|
|
int offscreen_w, offscreen_h;
|
2002-06-08 02:07:21 -04:00
|
|
|
MetaRectangle work_area;
|
|
|
|
|
|
|
|
meta_window_get_work_area (window, FALSE, &work_area);
|
2002-04-30 15:52:30 -04:00
|
|
|
|
2002-04-29 17:29:51 -04:00
|
|
|
/* (FIXME instead of TITLEBAR_LENGTH_ONSCREEN, get the actual
|
|
|
|
* size of the menu control?).
|
2001-07-05 01:22:00 -04:00
|
|
|
*/
|
2002-04-29 17:29:51 -04:00
|
|
|
|
|
|
|
#define TITLEBAR_LENGTH_ONSCREEN 36
|
|
|
|
|
|
|
|
/* find furthest northwest point the window can occupy */
|
2002-01-10 01:31:31 -05:00
|
|
|
nw_x = work_area.x;
|
|
|
|
nw_y = work_area.y;
|
2001-06-10 14:46:46 -04:00
|
|
|
if (window->frame)
|
|
|
|
{
|
2002-04-29 17:29:51 -04:00
|
|
|
/* Must keep TITLEBAR_LENGTH_ONSCREEN onscreen when moving left */
|
|
|
|
nw_x -= fgeom->left_width + window->rect.width + fgeom->right_width - TITLEBAR_LENGTH_ONSCREEN;
|
|
|
|
/* Can't move off the top */
|
2001-06-10 14:46:46 -04:00
|
|
|
nw_y += fgeom->top_height;
|
|
|
|
}
|
|
|
|
|
2001-07-05 01:22:00 -04:00
|
|
|
/* find bottom-right corner of workarea */
|
2002-01-10 01:31:31 -05:00
|
|
|
se_x = work_area.x + work_area.width;
|
|
|
|
se_y = work_area.y + work_area.height;
|
2001-06-10 14:46:46 -04:00
|
|
|
|
2001-07-05 01:22:00 -04:00
|
|
|
/* if the window's size exceeds the screen size,
|
|
|
|
* we allow it to go off the top/left far enough
|
|
|
|
* to get the right/bottom edges onscreen.
|
|
|
|
*/
|
|
|
|
offscreen_w = nw_x + window->rect.width;
|
|
|
|
offscreen_h = nw_y + window->rect.height;
|
|
|
|
if (window->frame)
|
|
|
|
{
|
|
|
|
offscreen_w += fgeom->right_width;
|
|
|
|
offscreen_h += fgeom->bottom_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
offscreen_w = offscreen_w - se_x;
|
|
|
|
offscreen_h = offscreen_h - se_y;
|
|
|
|
|
|
|
|
/* Now change NW limit to reflect amount offscreen in SE direction */
|
|
|
|
if (offscreen_w > 0)
|
|
|
|
nw_x -= offscreen_w;
|
|
|
|
if (offscreen_h > 0)
|
|
|
|
nw_y -= offscreen_h;
|
|
|
|
|
2002-04-29 17:29:51 -04:00
|
|
|
/* Limit movement off the right/bottom.
|
2001-11-27 00:14:57 -05:00
|
|
|
* Remember, we're constraining StaticGravity position.
|
|
|
|
*/
|
2001-06-10 14:46:46 -04:00
|
|
|
if (window->frame)
|
|
|
|
{
|
2001-11-27 00:14:57 -05:00
|
|
|
se_x -= TITLEBAR_LENGTH_ONSCREEN;
|
|
|
|
se_y -= 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* for frameless windows, just require an arbitrary little
|
|
|
|
* chunk to be onscreen
|
|
|
|
*/
|
|
|
|
se_x -= TITLEBAR_LENGTH_ONSCREEN;
|
|
|
|
se_y -= TITLEBAR_LENGTH_ONSCREEN;
|
2001-06-10 14:46:46 -04:00
|
|
|
}
|
2001-08-25 22:09:53 -04:00
|
|
|
|
2001-07-05 01:22:00 -04:00
|
|
|
/* If we have a micro-screen or huge frames maybe nw/se got
|
|
|
|
* swapped
|
|
|
|
*/
|
|
|
|
if (nw_x > se_x)
|
|
|
|
{
|
|
|
|
int tmp = nw_x;
|
|
|
|
nw_x = se_x;
|
|
|
|
se_x = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nw_y > se_y)
|
|
|
|
{
|
|
|
|
int tmp = nw_y;
|
|
|
|
nw_y = se_y;
|
|
|
|
se_y = tmp;
|
|
|
|
}
|
|
|
|
|
2002-01-18 22:50:03 -05:00
|
|
|
/* Clamp window to the given positions.
|
|
|
|
* Do the SE clamp first, so that the NW clamp has precedence
|
|
|
|
* and we don't tend to lose the titlebar for too-large
|
|
|
|
* windows.
|
|
|
|
*/
|
2001-06-10 14:46:46 -04:00
|
|
|
if (x > se_x)
|
|
|
|
x = se_x;
|
|
|
|
if (y > se_y)
|
|
|
|
y = se_y;
|
2002-01-18 22:50:03 -05:00
|
|
|
|
|
|
|
if (x < nw_x)
|
|
|
|
x = nw_x;
|
|
|
|
if (y < nw_y)
|
|
|
|
y = nw_y;
|
2002-04-29 17:29:51 -04:00
|
|
|
|
|
|
|
#undef TITLEBAR_LENGTH_ONSCREEN
|
2001-06-09 17:58:30 -04:00
|
|
|
}
|
2001-08-25 22:09:53 -04:00
|
|
|
|
2001-06-09 17:58:30 -04:00
|
|
|
*new_x = x;
|
|
|
|
*new_y = y;
|
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
menu_callback (MetaWindowMenu *menu,
|
|
|
|
Display *xdisplay,
|
|
|
|
Window client_xwindow,
|
|
|
|
MetaMenuOp op,
|
|
|
|
int workspace_index,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
MetaDisplay *display;
|
|
|
|
MetaWindow *window;
|
|
|
|
|
|
|
|
display = meta_display_for_x_display (xdisplay);
|
|
|
|
window = meta_display_lookup_x_window (display, client_xwindow);
|
|
|
|
|
|
|
|
if (window != NULL) /* window can be NULL */
|
|
|
|
{
|
|
|
|
meta_verbose ("Menu op %d on %s\n", op, window->desc);
|
|
|
|
|
|
|
|
/* op can be 0 for none */
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case META_MENU_OP_DELETE:
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_window_delete (window, meta_display_get_current_time (window->display));
|
2001-06-23 01:49:35 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_MINIMIZE:
|
|
|
|
meta_window_minimize (window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_UNMAXIMIZE:
|
|
|
|
meta_window_unmaximize (window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_MAXIMIZE:
|
|
|
|
meta_window_maximize (window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_UNSHADE:
|
|
|
|
meta_window_unshade (window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_SHADE:
|
|
|
|
meta_window_shade (window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_WORKSPACES:
|
|
|
|
{
|
|
|
|
MetaWorkspace *workspace;
|
|
|
|
|
|
|
|
workspace =
|
|
|
|
meta_display_get_workspace_by_screen_index (window->display,
|
|
|
|
window->screen,
|
|
|
|
workspace_index);
|
|
|
|
|
|
|
|
if (workspace)
|
2002-05-24 22:33:55 -04:00
|
|
|
{
|
|
|
|
meta_window_change_workspace (window,
|
|
|
|
workspace);
|
|
|
|
meta_workspace_activate (workspace);
|
|
|
|
}
|
2001-06-23 01:49:35 -04:00
|
|
|
else
|
|
|
|
meta_warning ("Workspace %d doesn't exist\n", workspace_index);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_STICK:
|
|
|
|
meta_window_stick (window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_UNSTICK:
|
|
|
|
meta_window_unstick (window);
|
|
|
|
break;
|
|
|
|
|
2001-07-11 02:22:00 -04:00
|
|
|
case META_MENU_OP_MOVE:
|
|
|
|
meta_window_raise (window);
|
|
|
|
meta_display_begin_grab_op (window->display,
|
|
|
|
window,
|
|
|
|
META_GRAB_OP_KEYBOARD_MOVING,
|
2001-07-25 22:55:35 -04:00
|
|
|
FALSE, 0, 0,
|
2002-01-03 18:28:19 -05:00
|
|
|
meta_display_get_current_time (window->display),
|
2001-07-11 02:22:00 -04:00
|
|
|
0, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_MENU_OP_RESIZE:
|
2002-04-28 00:52:26 -04:00
|
|
|
/* FIXME */
|
2001-07-11 02:22:00 -04:00
|
|
|
break;
|
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
case 0:
|
|
|
|
/* nothing */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
meta_warning (G_STRLOC": Unknown window op\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_verbose ("Menu callback on nonexistent window\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_ui_window_menu_free (menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_show_menu (MetaWindow *window,
|
|
|
|
int root_x,
|
|
|
|
int root_y,
|
|
|
|
int button,
|
|
|
|
Time timestamp)
|
|
|
|
{
|
|
|
|
MetaMenuOp ops;
|
|
|
|
MetaMenuOp insensitive;
|
|
|
|
MetaWindowMenu *menu;
|
|
|
|
|
|
|
|
ops = 0;
|
|
|
|
insensitive = 0;
|
|
|
|
|
2001-07-11 02:22:00 -04:00
|
|
|
ops |= (META_MENU_OP_DELETE | META_MENU_OP_WORKSPACES | META_MENU_OP_MINIMIZE | META_MENU_OP_MOVE | META_MENU_OP_RESIZE);
|
2001-06-23 01:49:35 -04:00
|
|
|
|
|
|
|
if (window->maximized)
|
|
|
|
ops |= META_MENU_OP_UNMAXIMIZE;
|
|
|
|
else
|
|
|
|
ops |= META_MENU_OP_MAXIMIZE;
|
|
|
|
|
|
|
|
if (window->shaded)
|
|
|
|
ops |= META_MENU_OP_UNSHADE;
|
|
|
|
else
|
|
|
|
ops |= META_MENU_OP_SHADE;
|
|
|
|
|
|
|
|
if (window->on_all_workspaces)
|
|
|
|
ops |= META_MENU_OP_UNSTICK;
|
|
|
|
else
|
|
|
|
ops |= META_MENU_OP_STICK;
|
2001-06-23 02:54:28 -04:00
|
|
|
|
|
|
|
if (!window->has_maximize_func)
|
|
|
|
insensitive |= META_MENU_OP_UNMAXIMIZE | META_MENU_OP_MAXIMIZE;
|
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
if (!window->has_minimize_func)
|
|
|
|
insensitive |= META_MENU_OP_MINIMIZE;
|
|
|
|
|
|
|
|
if (!window->has_close_func)
|
|
|
|
insensitive |= META_MENU_OP_DELETE;
|
|
|
|
|
2001-06-23 02:54:28 -04:00
|
|
|
if (!window->has_shade_func)
|
|
|
|
insensitive |= META_MENU_OP_SHADE | META_MENU_OP_UNSHADE;
|
2001-07-11 02:22:00 -04:00
|
|
|
|
|
|
|
if (!window->has_move_func)
|
|
|
|
insensitive |= META_MENU_OP_MOVE;
|
|
|
|
|
|
|
|
if (!window->has_resize_func)
|
|
|
|
insensitive |= META_MENU_OP_RESIZE;
|
2002-05-26 11:54:38 -04:00
|
|
|
|
|
|
|
if (window->always_sticky)
|
|
|
|
insensitive |= META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES;
|
2001-06-23 02:54:28 -04:00
|
|
|
|
2001-06-23 01:49:35 -04:00
|
|
|
menu =
|
|
|
|
meta_ui_window_menu_new (window->screen->ui,
|
|
|
|
window->xwindow,
|
|
|
|
ops,
|
|
|
|
insensitive,
|
|
|
|
meta_window_get_net_wm_desktop (window),
|
|
|
|
meta_screen_get_n_workspaces (window->screen),
|
|
|
|
menu_callback,
|
2001-07-11 02:22:00 -04:00
|
|
|
NULL);
|
2001-06-23 01:49:35 -04:00
|
|
|
|
|
|
|
meta_verbose ("Popping up window menu for %s\n", window->desc);
|
|
|
|
meta_ui_window_menu_popup (menu, root_x, root_y, button, timestamp);
|
|
|
|
}
|
2001-06-24 04:09:10 -04:00
|
|
|
|
2001-07-25 22:55:35 -04:00
|
|
|
static void
|
|
|
|
window_query_root_pointer (MetaWindow *window,
|
|
|
|
int *x, int *y)
|
|
|
|
{
|
|
|
|
Window root_return, child_return;
|
|
|
|
int root_x_return, root_y_return;
|
|
|
|
int win_x_return, win_y_return;
|
|
|
|
unsigned int mask_return;
|
|
|
|
|
2001-11-26 22:41:43 -05:00
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
2001-07-25 22:55:35 -04:00
|
|
|
XQueryPointer (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
&root_return,
|
|
|
|
&child_return,
|
|
|
|
&root_x_return,
|
|
|
|
&root_y_return,
|
|
|
|
&win_x_return,
|
|
|
|
&win_y_return,
|
|
|
|
&mask_return);
|
|
|
|
|
2001-11-26 22:41:43 -05:00
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
|
2001-07-25 22:55:35 -04:00
|
|
|
if (x)
|
|
|
|
*x = root_x_return;
|
|
|
|
if (y)
|
|
|
|
*y = root_y_return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_move (MetaWindow *window,
|
2001-07-25 23:58:24 -04:00
|
|
|
unsigned int mask,
|
2001-07-25 22:55:35 -04:00
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
|
|
|
int dx, dy;
|
2001-07-25 23:58:24 -04:00
|
|
|
int new_x, new_y;
|
2001-07-25 22:55:35 -04:00
|
|
|
|
|
|
|
dx = x - window->display->grab_root_x;
|
|
|
|
dy = y - window->display->grab_root_y;
|
|
|
|
|
2001-07-25 23:58:24 -04:00
|
|
|
new_x = window->display->grab_initial_window_pos.x + dx;
|
|
|
|
new_y = window->display->grab_initial_window_pos.y + dy;
|
|
|
|
|
|
|
|
if (mask & ShiftMask)
|
|
|
|
{
|
|
|
|
/* snap to edges */
|
|
|
|
new_x = meta_window_find_nearest_vertical_edge (window, new_x);
|
|
|
|
new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
|
|
|
|
}
|
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_move (window, TRUE, new_x, new_y);
|
2001-07-25 22:55:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_resize (MetaWindow *window,
|
|
|
|
int x, int y)
|
|
|
|
{
|
|
|
|
int dx, dy;
|
|
|
|
int new_w, new_h;
|
|
|
|
int gravity;
|
|
|
|
|
|
|
|
dx = x - window->display->grab_root_x;
|
|
|
|
dy = y - window->display->grab_root_y;
|
|
|
|
|
|
|
|
new_w = window->display->grab_initial_window_pos.width;
|
|
|
|
new_h = window->display->grab_initial_window_pos.height;
|
|
|
|
|
|
|
|
switch (window->display->grab_op)
|
|
|
|
{
|
|
|
|
case META_GRAB_OP_RESIZING_SE:
|
|
|
|
case META_GRAB_OP_RESIZING_NE:
|
|
|
|
case META_GRAB_OP_RESIZING_E:
|
|
|
|
new_w += dx;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_GRAB_OP_RESIZING_NW:
|
|
|
|
case META_GRAB_OP_RESIZING_SW:
|
|
|
|
case META_GRAB_OP_RESIZING_W:
|
|
|
|
new_w -= dx;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (window->display->grab_op)
|
|
|
|
{
|
|
|
|
case META_GRAB_OP_RESIZING_SE:
|
|
|
|
case META_GRAB_OP_RESIZING_S:
|
|
|
|
case META_GRAB_OP_RESIZING_SW:
|
|
|
|
new_h += dy;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_GRAB_OP_RESIZING_N:
|
|
|
|
case META_GRAB_OP_RESIZING_NE:
|
|
|
|
case META_GRAB_OP_RESIZING_NW:
|
|
|
|
new_h -= dy;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute gravity of client during operation */
|
2002-03-17 12:22:23 -05:00
|
|
|
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
|
|
|
|
g_assert (gravity >= 0);
|
2001-07-25 22:55:35 -04:00
|
|
|
|
2001-08-28 23:37:03 -04:00
|
|
|
meta_window_resize_with_gravity (window, TRUE, new_w, new_h, gravity);
|
2001-07-25 22:55:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_handle_mouse_grab_op_event (MetaWindow *window,
|
|
|
|
XEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
2002-05-11 01:09:54 -04:00
|
|
|
case ButtonRelease:
|
2001-07-25 22:55:35 -04:00
|
|
|
switch (window->display->grab_op)
|
|
|
|
{
|
|
|
|
case META_GRAB_OP_MOVING:
|
2001-07-25 23:58:24 -04:00
|
|
|
update_move (window, event->xbutton.state,
|
|
|
|
event->xbutton.x_root, event->xbutton.y_root);
|
2001-07-25 22:55:35 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case META_GRAB_OP_RESIZING_E:
|
|
|
|
case META_GRAB_OP_RESIZING_W:
|
|
|
|
case META_GRAB_OP_RESIZING_S:
|
|
|
|
case META_GRAB_OP_RESIZING_N:
|
|
|
|
case META_GRAB_OP_RESIZING_SE:
|
|
|
|
case META_GRAB_OP_RESIZING_SW:
|
|
|
|
case META_GRAB_OP_RESIZING_NE:
|
|
|
|
case META_GRAB_OP_RESIZING_NW:
|
|
|
|
update_resize (window, event->xbutton.x_root, event->xbutton.y_root);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2002-05-11 01:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
meta_display_end_grab_op (window->display, event->xbutton.time);
|
2001-07-25 22:55:35 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MotionNotify:
|
|
|
|
switch (window->display->grab_op)
|
|
|
|
{
|
|
|
|
case META_GRAB_OP_MOVING:
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
window_query_root_pointer (window, &x, &y);
|
2001-07-25 23:58:24 -04:00
|
|
|
update_move (window,
|
|
|
|
event->xbutton.state,
|
|
|
|
x, y);
|
2001-07-25 22:55:35 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case META_GRAB_OP_RESIZING_E:
|
|
|
|
case META_GRAB_OP_RESIZING_W:
|
|
|
|
case META_GRAB_OP_RESIZING_S:
|
|
|
|
case META_GRAB_OP_RESIZING_N:
|
|
|
|
case META_GRAB_OP_RESIZING_SE:
|
|
|
|
case META_GRAB_OP_RESIZING_SW:
|
|
|
|
case META_GRAB_OP_RESIZING_NE:
|
|
|
|
case META_GRAB_OP_RESIZING_NW:
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
window_query_root_pointer (window, &x, &y);
|
|
|
|
update_resize (window, x, y);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-24 04:09:10 -04:00
|
|
|
gboolean
|
|
|
|
meta_window_shares_some_workspace (MetaWindow *window,
|
|
|
|
MetaWindow *with)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
if (window->on_all_workspaces ||
|
|
|
|
with->on_all_workspaces)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
tmp = window->workspaces;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
if (g_list_find (with->workspaces, tmp->data) != NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-06-30 19:17:52 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_set_gravity (MetaWindow *window,
|
|
|
|
int gravity)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrs;
|
|
|
|
|
|
|
|
meta_verbose ("Setting gravity of %s to %d\n", window->desc, gravity);
|
|
|
|
|
|
|
|
attrs.win_gravity = gravity;
|
|
|
|
|
|
|
|
meta_error_trap_push (window->display);
|
|
|
|
|
|
|
|
XChangeWindowAttributes (window->display->xdisplay,
|
|
|
|
window->xwindow,
|
|
|
|
CWWinGravity,
|
|
|
|
&attrs);
|
|
|
|
|
|
|
|
meta_error_trap_pop (window->display);
|
|
|
|
}
|
2002-01-10 01:31:31 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_get_work_area (MetaWindow *window,
|
2002-06-08 02:07:21 -04:00
|
|
|
gboolean for_current_xinerama,
|
2002-01-10 01:31:31 -05:00
|
|
|
MetaRectangle *area)
|
|
|
|
{
|
|
|
|
MetaRectangle space_area;
|
|
|
|
GList *tmp;
|
2002-06-06 23:18:46 -04:00
|
|
|
|
|
|
|
int left_strut;
|
|
|
|
int right_strut;
|
|
|
|
int top_strut;
|
|
|
|
int bottom_strut;
|
2002-01-10 01:31:31 -05:00
|
|
|
|
2002-06-08 02:07:21 -04:00
|
|
|
if (for_current_xinerama)
|
|
|
|
{
|
|
|
|
const MetaXineramaScreenInfo *xinerama;
|
|
|
|
|
|
|
|
xinerama = meta_screen_get_xinerama_for_window (window->screen,
|
|
|
|
window);
|
|
|
|
|
|
|
|
left_strut = xinerama->x_origin;
|
|
|
|
right_strut = window->screen->width - xinerama->width - xinerama->x_origin;
|
|
|
|
top_strut = xinerama->y_origin;
|
|
|
|
bottom_strut = window->screen->height - xinerama->height - xinerama->y_origin;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
left_strut = 0;
|
|
|
|
right_strut = 0;
|
|
|
|
top_strut = 0;
|
|
|
|
bottom_strut = 0;
|
|
|
|
}
|
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
tmp = meta_window_get_workspaces (window);
|
|
|
|
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
meta_workspace_get_work_area (tmp->data, &space_area);
|
|
|
|
|
|
|
|
left_strut = MAX (left_strut, space_area.x);
|
|
|
|
right_strut = MAX (right_strut,
|
|
|
|
(window->screen->width - space_area.x - space_area.width));
|
|
|
|
top_strut = MAX (top_strut, space_area.y);
|
|
|
|
bottom_strut = MAX (bottom_strut,
|
|
|
|
(window->screen->height - space_area.y - space_area.height));
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
2002-06-06 23:18:46 -04:00
|
|
|
|
2002-01-10 01:31:31 -05:00
|
|
|
area->x = left_strut;
|
|
|
|
area->y = top_strut;
|
|
|
|
area->width = window->screen->width - left_strut - right_strut;
|
|
|
|
area->height = window->screen->height - top_strut - bottom_strut;
|
|
|
|
|
2002-02-07 22:34:26 -05:00
|
|
|
meta_topic (META_DEBUG_WORKAREA,
|
|
|
|
"Window %s has work area %d,%d %d x %d\n",
|
|
|
|
window->desc, area->x, area->y, area->width, area->height);
|
2002-01-10 01:31:31 -05:00
|
|
|
}
|
2002-01-27 00:50:34 -05:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_window_same_application (MetaWindow *window,
|
|
|
|
MetaWindow *other_window)
|
|
|
|
{
|
|
|
|
return (window->xgroup_leader != None &&
|
|
|
|
other_window->xgroup_leader != None &&
|
|
|
|
window->xgroup_leader == other_window->xgroup_leader);
|
|
|
|
}
|
2002-03-17 12:22:23 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_refresh_resize_popup (MetaWindow *window)
|
|
|
|
{
|
|
|
|
if (window->display->grab_op == META_GRAB_OP_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (window->display->grab_window != window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (window->display->grab_op)
|
|
|
|
{
|
|
|
|
case META_GRAB_OP_RESIZING_SE:
|
|
|
|
case META_GRAB_OP_RESIZING_S:
|
|
|
|
case META_GRAB_OP_RESIZING_SW:
|
|
|
|
case META_GRAB_OP_RESIZING_N:
|
|
|
|
case META_GRAB_OP_RESIZING_NE:
|
|
|
|
case META_GRAB_OP_RESIZING_NW:
|
|
|
|
case META_GRAB_OP_RESIZING_W:
|
|
|
|
case META_GRAB_OP_RESIZING_E:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_S:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_N:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_W:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_E:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_SE:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_NE:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_SW:
|
|
|
|
case META_GRAB_OP_KEYBOARD_RESIZING_NW:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Not resizing */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->display->grab_resize_popup == NULL)
|
|
|
|
{
|
|
|
|
/* FIXME only create it if width_inc > 1 or height_inc > 1 */
|
|
|
|
window->display->grab_resize_popup = meta_ui_resize_popup_new ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->display->grab_resize_popup != NULL)
|
|
|
|
{
|
|
|
|
int gravity;
|
|
|
|
int x, y;
|
|
|
|
MetaFrameGeometry fgeom;
|
|
|
|
|
|
|
|
if (window->frame)
|
|
|
|
meta_frame_calc_geometry (window->frame, &fgeom);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fgeom.left_width = 0;
|
|
|
|
fgeom.right_width = 0;
|
|
|
|
fgeom.top_height = 0;
|
|
|
|
fgeom.bottom_height = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
|
|
|
|
g_assert (gravity >= 0);
|
|
|
|
|
|
|
|
meta_window_get_position (window, &x, &y);
|
|
|
|
|
|
|
|
meta_ui_resize_popup_set (window->display->grab_resize_popup,
|
|
|
|
gravity,
|
|
|
|
x, y,
|
|
|
|
window->rect.width,
|
|
|
|
window->rect.height,
|
|
|
|
window->size_hints.base_width,
|
|
|
|
window->size_hints.base_height,
|
|
|
|
window->size_hints.min_width,
|
|
|
|
window->size_hints.min_height,
|
|
|
|
window->size_hints.width_inc,
|
|
|
|
window->size_hints.height_inc,
|
|
|
|
fgeom.left_width,
|
|
|
|
fgeom.right_width,
|
|
|
|
fgeom.top_height,
|
|
|
|
fgeom.bottom_height);
|
|
|
|
|
|
|
|
meta_ui_resize_popup_set_showing (window->display->grab_resize_popup,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
}
|
on unminimize, queue calc_showing on all transients
2002-05-05 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_unminimize): on unminimize, queue
calc_showing on all transients
(meta_window_activate): on activate, unminimize all a window's
ancestors, not just the window itself.
* src/workspace.c (set_work_area_hint): don't increment "tmp" by
16 unsigned long, increment by 4
* src/window.c (meta_window_free): if a window isn't minimized,
restore its WM_STATE to NormalState instead of IconicState,
since IconicState on initial window map means that the window
should be minimized.
* src/workspace.c (meta_workspace_invalidate_work_area): queue an
idle to recompute the work area hint.
(set_work_area_hint): we need 4*num_workspaces ints, not just
num_workspaces.
* src/screen.c (meta_screen_new): add work_area_idle field,
handle it on screen shutdown
* src/common.h (META_PRIORITY_PREFS_NOTIFY,
META_PRIORITY_WORK_AREA_HINT): define some idle priorities
* src/window.c (meta_window_calc_showing): hide windows if
their parent window is minimized
(meta_window_minimize): also queue_calc_showing on all
transients of the window being minimized
* src/place.c (constrain_placement): function to apply
placement-time-only constraints, such as "not off the left of the
screen"
(meta_window_place): put dialogs down a bit over their parent,
not right at the top.
(meta_window_place): when centering a dialog, center it
on the current xinerama screen, rather than the entire
screen.
* src/screen.c (meta_screen_get_current_xinerama): new function,
but not implemented
2002-05-05 01:41:13 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_foreach_transient (MetaWindow *window,
|
|
|
|
MetaWindowForeachFunc func,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
GSList *windows;
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
windows = meta_display_list_windows (window->display);
|
|
|
|
|
|
|
|
tmp = windows;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
|
|
|
MetaWindow *transient = tmp->data;
|
|
|
|
|
|
|
|
if (meta_window_is_ancestor_of_transient (window, transient))
|
|
|
|
(* func) (transient, data);
|
|
|
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (windows);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_window_is_ancestor_of_transient (MetaWindow *window,
|
|
|
|
MetaWindow *transient)
|
|
|
|
{
|
|
|
|
MetaWindow *w;
|
|
|
|
|
|
|
|
if (window == transient)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
w = transient;
|
|
|
|
while (w != NULL)
|
|
|
|
{
|
|
|
|
if (w->xtransient_for == None)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (w->xtransient_for == window->xwindow)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
w = meta_display_lookup_x_window (w->display, w->xtransient_for);
|
|
|
|
|
|
|
|
if (w == transient)
|
|
|
|
return FALSE; /* Cycle */
|
|
|
|
|
|
|
|
/* w may be null... */
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|