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
2003-02-23 12:09:46 -05:00
* Copyright ( C ) 2002 , 2003 Red Hat , Inc .
* Copyright ( C ) 2003 Rob Adams
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"
2002-08-12 17:32:13 -04:00
# include "group.h"
2002-11-03 18:42:21 -05:00
# include "window-props.h"
2003-03-08 18:43:17 -05:00
# include "constraints.h"
2001-06-06 00:47:37 -04:00
2001-06-02 00:14:18 -04:00
# include <X11/Xatom.h>
2002-10-26 12:40:50 -04:00
# include <string.h>
2001-06-02 00:14:18 -04:00
2003-01-05 02:51:02 -05:00
# ifdef HAVE_SHAPE
# include <X11/extensions/shape.h>
# endif
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-18 22:50:03 -05:00
static int destroying_windows_disallowed = 0 ;
2001-06-09 17:58:30 -04:00
2002-01-03 19:58:39 -05:00
static void update_net_wm_state ( MetaWindow * window ) ;
static void update_mwm_hints ( MetaWindow * window ) ;
2002-10-21 17:44:35 -04:00
static void update_wm_class ( MetaWindow * window ) ;
static void update_transient_for ( MetaWindow * window ) ;
2001-06-09 17:58:30 -04:00
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 ) ;
2004-01-10 12:16:07 -05:00
static void update_net_frame_extents ( 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 ) ;
2003-02-27 20:24:44 -05:00
static void invalidate_work_areas ( MetaWindow * window ) ;
2002-10-21 17:44:35 -04:00
static void set_wm_state ( MetaWindow * window ,
2001-06-06 00:47:37 -04:00
int state ) ;
2002-10-21 17:44:35 -04:00
static void set_net_wm_state ( MetaWindow * window ) ;
2004-01-10 12:16:07 -05:00
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-09-24 17:33:34 -04:00
static void meta_window_save_rect ( MetaWindow * window ) ;
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
2004-08-05 13:48:39 -04:00
static void ensure_mru_position_after ( MetaWindow * window ,
MetaWindow * after_this_one ) ;
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
2003-02-27 20:24:44 -05:00
/* FIXME we need an abstraction that covers all these queues. */
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 ) ;
2003-02-27 20:24:44 -05:00
static void meta_window_update_icon_now ( MetaWindow * window ) ;
void meta_window_unqueue_update_icon ( MetaWindow * window ) ;
void meta_window_flush_update_icon ( MetaWindow * window ) ;
2001-07-27 00:36:44 -04:00
static void meta_window_apply_session_info ( MetaWindow * window ,
const MetaWindowSessionInfo * info ) ;
2002-12-08 14:17:17 -05:00
# ifdef WITH_VERBOSE_MODE
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 " ;
}
2002-12-08 14:17:17 -05:00
# endif
2002-03-10 10:48:38 -05:00
2003-05-16 17:59:08 -04:00
static gboolean
is_desktop_or_dock_foreach ( MetaWindow * window ,
void * data )
{
gboolean * result = data ;
* result =
window - > type = = META_WINDOW_DESKTOP | |
window - > type = = META_WINDOW_DOCK ;
if ( * result )
return FALSE ; /* stop as soon as we find one */
else
return TRUE ;
}
/* window is the window that's newly mapped provoking
* the possible change
*/
static void
maybe_leave_show_desktop_mode ( MetaWindow * window )
{
gboolean is_desktop_or_dock ;
Make the "showing desktop" mode be per-workspace instead of per-screen.
2004-10-16 Elijah Newren <newren@math.utah.edu>
Make the "showing desktop" mode be per-workspace instead of
per-screen. (fixes #142198)
* src/keybindings.c (handle_toggle_desktop): access
showing_desktop through the active workspace
* src/screen.c (meta_screen_new): remove initialization of
screen->showing_desktop,
(meta_screen_update_showing_desktop_hint): rename and make not
static and access showing_desktop through the active workspace,
(queue_windows_showing): replace meta_display_list_windows() with
screen->active_workspace->windows,
(meta_screen_minimize_all_on_active_workspace_except): renamed
from meta_screen_minimize_all_except since it now only works on
the active workspace, (meta_screen_show_desktop,
meta_screen_unshow_desktop): access showing_desktop through the
active workspace
* src/screen.h (struct _MetaScreen): remove showing_desktop field,
(meta_screen_minimize_all_on_active_workspace_except): rename from
meta_screen_minimize_all_except,
(meta_screen_update)_showing_desktop_hint): export this function too
* src/window.c (maybe_leave_show_desktop_mode): access
showing_desktop through the active workspace and use new name for
meta_screen_minimize_all_on_active_workspace_except,
(window_should_be_showing): access showing_desktop through the
active workspace
* src/workspace.c (meta_workspace_new): initialize
workspace->showing_desktop, (meta_workspace_activate_with_focus):
add note that old can be NULL, update showing_desktop_hint if
different on this workspace than the previous one
* src/workspace.h (struct _MetaWorkspace): add showing_desktop
field
2004-10-17 00:28:29 -04:00
if ( ! window - > screen - > active_workspace - > showing_desktop )
2003-05-16 17:59:08 -04:00
return ;
/* If the window is a transient for the dock or desktop, don't
* leave show desktop mode when the window opens . That ' s
* so you can e . g . hide all windows , manipulate a file on
* the desktop via a dialog , then unshow windows again .
*/
is_desktop_or_dock = FALSE ;
2003-05-18 13:16:03 -04:00
is_desktop_or_dock_foreach ( window ,
& is_desktop_or_dock ) ;
2003-05-16 17:59:08 -04:00
meta_window_foreach_ancestor ( window , is_desktop_or_dock_foreach ,
& is_desktop_or_dock ) ;
if ( ! is_desktop_or_dock )
{
Make the "showing desktop" mode be per-workspace instead of per-screen.
2004-10-16 Elijah Newren <newren@math.utah.edu>
Make the "showing desktop" mode be per-workspace instead of
per-screen. (fixes #142198)
* src/keybindings.c (handle_toggle_desktop): access
showing_desktop through the active workspace
* src/screen.c (meta_screen_new): remove initialization of
screen->showing_desktop,
(meta_screen_update_showing_desktop_hint): rename and make not
static and access showing_desktop through the active workspace,
(queue_windows_showing): replace meta_display_list_windows() with
screen->active_workspace->windows,
(meta_screen_minimize_all_on_active_workspace_except): renamed
from meta_screen_minimize_all_except since it now only works on
the active workspace, (meta_screen_show_desktop,
meta_screen_unshow_desktop): access showing_desktop through the
active workspace
* src/screen.h (struct _MetaScreen): remove showing_desktop field,
(meta_screen_minimize_all_on_active_workspace_except): rename from
meta_screen_minimize_all_except,
(meta_screen_update)_showing_desktop_hint): export this function too
* src/window.c (maybe_leave_show_desktop_mode): access
showing_desktop through the active workspace and use new name for
meta_screen_minimize_all_on_active_workspace_except,
(window_should_be_showing): access showing_desktop through the
active workspace
* src/workspace.c (meta_workspace_new): initialize
workspace->showing_desktop, (meta_workspace_activate_with_focus):
add note that old can be NULL, update showing_desktop_hint if
different on this workspace than the previous one
* src/workspace.h (struct _MetaWorkspace): add showing_desktop
field
2004-10-17 00:28:29 -04:00
meta_screen_minimize_all_on_active_workspace_except ( window - > screen ,
window ) ;
2003-05-16 17:59:08 -04:00
meta_screen_unshow_desktop ( window - > screen ) ;
}
}
2001-05-30 11:36:31 -04:00
MetaWindow *
2002-10-26 03:37:11 -04:00
meta_window_new ( MetaDisplay * display ,
Window xwindow ,
gboolean must_be_viewable )
2001-05-30 11:36:31 -04:00
{
XWindowAttributes attrs ;
2003-11-20 21:32:05 -05:00
MetaWindow * window ;
meta_display_grab ( display ) ;
meta_error_trap_push ( display ) ; /* Push a trap over all of window
* creation , to reduce XSync ( ) calls
*/
meta_error_trap_push_with_return ( display ) ;
XGetWindowAttributes ( display - > xdisplay ,
xwindow , & attrs ) ;
if ( meta_error_trap_pop_with_return ( display , TRUE ) ! = Success )
{
meta_verbose ( " Failed to get attributes for window 0x%lx \n " ,
xwindow ) ;
meta_error_trap_pop ( display , TRUE ) ;
meta_display_ungrab ( display ) ;
return NULL ;
}
window = meta_window_new_with_attrs ( display , xwindow ,
must_be_viewable , & attrs ) ;
meta_error_trap_pop ( display , FALSE ) ;
meta_display_ungrab ( display ) ;
return window ;
}
MetaWindow *
meta_window_new_with_attrs ( MetaDisplay * display ,
Window xwindow ,
gboolean must_be_viewable ,
XWindowAttributes * attrs )
{
MetaWindow * window ;
2001-05-30 11:36:31 -04:00
GSList * tmp ;
2001-06-12 20:56:08 -04:00
MetaWorkspace * space ;
2001-06-24 02:47:54 -04:00
gulong existing_wm_state ;
2003-01-05 02:51:02 -05:00
gulong event_mask ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
# define N_INITIAL_PROPS 13
2002-11-03 18:42:21 -05:00
Atom initial_props [ N_INITIAL_PROPS ] ;
2002-11-03 19:19:08 -05:00
int i ;
2003-01-05 02:51:02 -05:00
gboolean has_shape ;
2003-11-20 21:32:05 -05:00
g_assert ( attrs ! = NULL ) ;
2002-10-26 03:37:11 -04:00
g_assert ( N_INITIAL_PROPS = = ( int ) G_N_ELEMENTS ( initial_props ) ) ;
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 ;
}
2003-11-20 21:32:05 -05:00
if ( attrs - > override_redirect )
{
meta_verbose ( " Deciding not to manage override_redirect window 0x%lx \n " , xwindow ) ;
return NULL ;
}
2002-01-05 22:15:49 -05:00
2001-06-10 23:24:20 -04:00
/* Grab server */
meta_display_grab ( display ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_push ( display ) ; /* Push a trap over all of window
* creation , to reduce XSync ( ) calls
*/
2001-06-10 23:24:20 -04:00
2003-11-20 21:32:05 -05:00
meta_verbose ( " must_be_viewable = %d attrs->map_state = %d (%s) \n " ,
2002-03-10 10:48:38 -05:00
must_be_viewable ,
2003-11-20 21:32:05 -05:00
attrs - > map_state ,
( attrs - > map_state = = IsUnmapped ) ?
2001-08-19 02:23:59 -04:00
" IsUnmapped " :
2003-11-20 21:32:05 -05:00
( attrs - > map_state = = IsViewable ) ?
2001-08-19 02:23:59 -04:00
" IsViewable " :
2003-11-20 21:32:05 -05:00
( attrs - > map_state = = IsUnviewable ) ?
2001-08-19 02:23:59 -04:00
" IsUnviewable " :
" (unknown) " ) ;
2001-06-24 02:47:54 -04:00
existing_wm_state = WithdrawnState ;
2003-11-20 21:32:05 -05:00
if ( must_be_viewable & & attrs - > map_state ! = IsViewable )
2001-06-11 01:47:51 -04:00
{
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( display , TRUE ) ;
2001-06-23 14:30:27 -04:00
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
}
2002-10-21 17:44:35 -04:00
meta_error_trap_push_with_return ( display ) ;
2001-05-31 02:42:58 -04:00
XAddToSaveSet ( display - > xdisplay , xwindow ) ;
2003-01-05 02:51:02 -05:00
event_mask =
PropertyChangeMask | EnterWindowMask | LeaveWindowMask |
FocusChangeMask | ColormapChangeMask ;
XSelectInput ( display - > xdisplay , xwindow , event_mask ) ;
has_shape = FALSE ;
# ifdef HAVE_SHAPE
if ( META_DISPLAY_HAS_SHAPE ( display ) )
{
int x_bounding , y_bounding , x_clip , y_clip ;
unsigned w_bounding , h_bounding , w_clip , h_clip ;
int bounding_shaped , clip_shaped ;
XShapeSelectInput ( display - > xdisplay , xwindow , ShapeNotifyMask ) ;
XShapeQueryExtents ( display - > xdisplay , xwindow ,
& bounding_shaped , & x_bounding , & y_bounding ,
& w_bounding , & h_bounding ,
& clip_shaped , & x_clip , & y_clip ,
& w_clip , & h_clip ) ;
has_shape = bounding_shaped ! = FALSE ;
meta_topic ( META_DEBUG_SHAPES ,
" Window has_shape = %d extents %d,%d %d x %d \n " ,
has_shape , x_bounding , y_bounding ,
w_bounding , h_bounding ) ;
}
# endif
2001-06-04 00:58:22 -04:00
/* Get rid of any borders */
2003-11-20 21:32:05 -05:00
if ( attrs - > border_width ! = 0 )
2001-06-04 00:58:22 -04:00
XSetWindowBorderWidth ( display - > xdisplay , xwindow , 0 ) ;
2001-06-30 19:17:52 -04:00
/* Get rid of weird gravities */
2003-11-20 21:32:05 -05:00
if ( attrs - > win_gravity ! = NorthWestGravity )
2001-06-30 19:17:52 -04:00
{
XSetWindowAttributes set_attrs ;
set_attrs . win_gravity = NorthWestGravity ;
XChangeWindowAttributes ( display - > xdisplay ,
xwindow ,
CWWinGravity ,
& set_attrs ) ;
}
2001-05-31 02:42:58 -04:00
2002-10-21 17:44:35 -04:00
if ( meta_error_trap_pop_with_return ( display , FALSE ) ! = Success )
2001-05-30 11:36:31 -04:00
{
meta_verbose ( " Window 0x%lx disappeared just as we tried to manage it \n " ,
xwindow ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( display , FALSE ) ;
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
2003-11-20 21:32:05 -05: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 ;
2002-12-09 22:23:04 -05:00
2001-05-31 02:42:58 -04:00
/* this is in window->screen->display, but that's too annoying to
* type
*/
window - > display = display ;
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
window - > workspace = NULL ;
2002-12-09 22:23:04 -05:00
# ifdef HAVE_XSYNC
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
window - > sync_request_counter = None ;
window - > sync_request_serial = 0 ;
window - > sync_request_time . tv_sec = 0 ;
window - > sync_request_time . tv_usec = 0 ;
2002-12-09 22:23:04 -05:00
# endif
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 ;
2003-11-20 21:32:05 -05:00
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
2003-05-16 17:59:08 -04:00
window - > desc = g_strdup_printf ( " 0x%lx " , window - > xwindow ) ;
2003-06-07 13:15:33 -04:00
2001-06-10 23:24:20 -04:00
/* avoid tons of stack updates */
meta_stack_freeze ( window - > screen - > stack ) ;
2003-01-05 02:51:02 -05:00
window - > has_shape = has_shape ;
2001-06-10 23:24:20 -04:00
2001-06-04 00:58:22 -04:00
/* Remember this rect is the actual window size */
2003-11-20 21:32:05 -05: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-06-04 00:58:22 -04:00
/* And border width, size_hints are the "request" */
2003-11-20 21:32:05 -05:00
window - > border_width = attrs - > border_width ;
window - > size_hints . x = attrs - > x ;
window - > size_hints . y = attrs - > y ;
window - > size_hints . width = attrs - > width ;
window - > size_hints . height = attrs - > height ;
2003-04-26 13:40:32 -04:00
/* initialize the remaining size_hints as if size_hints.flags were zero */
meta_set_normal_hints ( window , NULL ) ;
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
2003-11-20 21:32:05 -05:00
window - > depth = attrs - > depth ;
window - > xvisual = attrs - > visual ;
window - > colormap = attrs - > colormap ;
2002-05-09 18:34:00 -04:00
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-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 ;
2003-06-09 19:49:02 -04:00
window - > maximize_after_placement = 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 ;
2003-11-20 21:32:05 -05:00
window - > mapped = attrs - > map_state ! = IsUnmapped ;
2004-12-28 01:01:42 -05:00
/* if already mapped, no need to worry about focus-on-first-time-showing */
window - > showing_for_first_time = ! window - > mapped ;
2001-06-21 23:20:21 -04:00
/* 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 ) ;
2005-02-11 14:20:44 -05:00
window - > denied_focus_and_not_transient = FALSE ;
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 ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
window - > initial_timestamp_set = FALSE ;
window - > net_wm_user_time_set = FALSE ;
2001-06-24 04:09:10 -04:00
window - > calc_placement = FALSE ;
2003-06-12 01:55:06 -04:00
window - > shaken_loose = FALSE ;
2003-10-13 16:15:40 -04:00
window - > have_focus_click_grab = FALSE ;
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
window - > disable_sync = 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 ;
2002-06-21 23:23:02 -04:00
window - > mwm_border_only = FALSE ;
2001-06-23 14:30:27 -04:00
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 ;
2003-05-16 17:59:08 -04:00
window - > always_sticky = FALSE ;
2001-06-23 02:54:28 -04:00
2001-06-09 23:17:15 -04:00
window - > wm_state_modal = FALSE ;
2002-07-06 15:05:37 -04:00
window - > skip_taskbar = FALSE ;
window - > skip_pager = FALSE ;
2001-06-11 01:47:51 -04:00
window - > wm_state_skip_taskbar = FALSE ;
window - > wm_state_skip_pager = FALSE ;
2002-10-01 20:47:29 -04:00
window - > wm_state_above = FALSE ;
window - > wm_state_below = FALSE ;
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
window - > wm_state_demands_attention = 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 ;
2002-11-30 22:58:04 -05:00
window - > startup_id = NULL ;
2002-04-13 00:58:45 -04:00
window - > net_wm_pid = - 1 ;
2001-06-09 17:58:30 -04:00
window - > xtransient_for = None ;
window - > xclient_leader = None ;
2002-09-27 15:42:59 -04:00
window - > transient_parent_is_root_window = FALSE ;
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
2003-06-25 23:09:38 -04:00
window - > struts = NULL ;
2002-08-12 17:32:13 -04:00
2002-11-03 19:19:08 -05:00
window - > using_net_wm_name = FALSE ;
window - > using_net_wm_icon_name = FALSE ;
2003-02-27 20:24:44 -05:00
window - > need_reread_icon = TRUE ;
2003-05-16 17:59:08 -04:00
window - > update_icon_queued = FALSE ;
2002-01-10 01:31:31 -05:00
2002-09-28 12:33:39 -04:00
window - > layer = META_LAYER_LAST ; /* invalid value */
window - > stack_position = - 1 ;
2001-06-24 02:47:54 -04:00
window - > initial_workspace = 0 ; /* not used */
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
window - > initial_timestamp = 0 ; /* not used */
2003-11-24 14:09:25 -05:00
2001-05-31 02:42:58 -04:00
meta_display_register_x_window ( display , & window - > xwindow , window ) ;
2003-11-24 14:09:25 -05:00
/* assign the window to its group, or create a new group if needed
*/
window - > group = NULL ;
window - > xgroup_leader = None ;
meta_window_compute_group ( window ) ;
2002-10-26 03:37:11 -04:00
2002-12-15 16:59:38 -05:00
/* Fill these in the order we want them to be gotten.
* we want to get window name and class first
* so we can use them in error messages and such .
*/
2002-11-03 19:19:08 -05:00
i = 0 ;
2002-12-15 16:59:38 -05:00
initial_props [ i + + ] = display - > atom_net_wm_name ;
2002-11-03 19:19:08 -05:00
initial_props [ i + + ] = display - > atom_wm_client_machine ;
initial_props [ i + + ] = display - > atom_net_wm_pid ;
initial_props [ i + + ] = XA_WM_NAME ;
initial_props [ i + + ] = display - > atom_net_wm_icon_name ;
initial_props [ i + + ] = XA_WM_ICON_NAME ;
2002-11-21 00:02:38 -05:00
initial_props [ i + + ] = display - > atom_net_wm_desktop ;
2002-11-30 22:58:04 -05:00
initial_props [ i + + ] = display - > atom_net_startup_id ;
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
initial_props [ i + + ] = display - > atom_net_wm_sync_request_counter ;
2003-02-27 20:24:44 -05:00
initial_props [ i + + ] = XA_WM_NORMAL_HINTS ;
initial_props [ i + + ] = display - > atom_wm_protocols ;
initial_props [ i + + ] = XA_WM_HINTS ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
initial_props [ i + + ] = display - > atom_net_wm_user_time ;
2002-11-03 19:19:08 -05:00
g_assert ( N_INITIAL_PROPS = = i ) ;
2002-11-03 18:42:21 -05:00
meta_window_reload_properties ( window , initial_props , N_INITIAL_PROPS ) ;
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 ) ;
2003-02-27 20:24:44 -05:00
meta_window_update_icon_now ( window ) ;
2003-06-04 15:15:46 -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 ;
}
2002-11-30 22:58:04 -05:00
/* Apply any window attributes such as initial workspace
* based on startup notification
*/
meta_screen_apply_startup_properties ( window - > screen , 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 ) ;
2003-10-13 16:15:40 -04:00
meta_display_grab_focus_window_button ( window - > display , window ) ;
2003-12-14 14:19:40 -05:00
if ( window - > type = = META_WINDOW_DESKTOP | |
window - > type = = META_WINDOW_DOCK )
{
/* Change the default, but don't enforce this if the user
* focuses the dock / desktop and unsticks it using key shortcuts .
* Need to set this before adding to the workspaces so the MRU
* lists will be updated .
*/
window - > on_all_workspaces = TRUE ;
}
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 ) ;
2003-12-14 14:19:40 -05:00
/* need to set on_all_workspaces first so that it will be
* added to all the MRU lists
*/
2003-12-13 18:00:06 -05:00
window - > on_all_workspaces = TRUE ;
2003-12-14 14:19:40 -05:00
meta_workspace_add_window ( window - > screen - > active_workspace , window ) ;
2001-10-24 21:39:36 -04:00
}
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 =
2002-10-16 16:12:24 -04:00
meta_screen_get_workspace_by_index ( window - > screen ,
window - > initial_workspace ) ;
2001-10-24 21:39:36 -04:00
if ( space )
meta_workspace_add_window ( space , window ) ;
}
2001-06-24 02:47:54 -04:00
}
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace = = NULL & &
2001-06-24 02:47:54 -04:00
window - > xtransient_for ! = None )
{
/* Try putting dialog on parent's workspace */
MetaWindow * parent ;
parent = meta_display_lookup_x_window ( window - > display ,
window - > xtransient_for ) ;
2005-02-23 12:42:51 -05:00
if ( parent & & parent - > workspace )
2001-06-24 02:47:54 -04:00
{
2002-03-03 23:54:46 -05:00
meta_topic ( META_DEBUG_PLACEMENT ,
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
" Putting window %s on same workspace as parent %s \n " ,
2002-03-03 23:54:46 -05:00
window - > desc , parent - > desc ) ;
2001-06-24 02:47:54 -04:00
if ( parent - > on_all_workspaces )
window - > on_all_workspaces = TRUE ;
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
/* this will implicitly add to the appropriate MRU lists
*/
meta_workspace_add_window ( parent - > workspace , window ) ;
2001-06-24 02:47:54 -04:00
}
}
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace = = NULL )
2001-06-24 02:47:54 -04:00
{
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-10-25 23:54:55 -04:00
/* for the various on_all_workspaces = TRUE possible above */
meta_window_set_current_workspace_hint ( window ) ;
2003-06-25 23:09:38 -04:00
meta_window_update_struts ( window ) ;
2002-08-01 19:52:47 -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 ) ;
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 ) ;
}
}
2005-01-25 21:47:49 -05:00
/* FIXME we have a tendency to set this then immediately
* change it again .
*/
set_wm_state ( window , window - > iconic ? IconicState : NormalState ) ;
set_net_wm_state ( window ) ;
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 */
2003-05-16 17:59:08 -04:00
maybe_leave_show_desktop_mode ( window ) ;
2001-06-10 23:24:20 -04:00
2001-06-06 00:47:37 -04:00
meta_window_queue_calc_showing ( window ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( display , FALSE ) ; /* pop the XSync()-reducing trap */
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 ;
}
2003-11-20 21:32:05 -05:00
/* This function should only be called from the end of meta_window_new_with_attrs () */
2001-07-27 00:36:44 -04:00
static void
meta_window_apply_session_info ( MetaWindow * window ,
const MetaWindowSessionInfo * info )
{
2002-06-22 20:21:20 -04:00
if ( info - > stack_position_set )
{
meta_topic ( META_DEBUG_SM ,
" Restoring stack position %d for window %s \n " ,
info - > stack_position , window - > desc ) ;
/* FIXME well, I'm not sure how to do this. */
}
if ( info - > minimized_set )
{
meta_topic ( META_DEBUG_SM ,
" Restoring minimized state %d for window %s \n " ,
info - > minimized , window - > desc ) ;
if ( window - > has_minimize_func & & info - > minimized )
meta_window_minimize ( window ) ;
}
if ( info - > maximized_set )
{
meta_topic ( META_DEBUG_SM ,
" Restoring maximized state %d for window %s \n " ,
info - > maximized , window - > desc ) ;
if ( window - > has_maximize_func & & info - > maximized )
2002-09-03 22:44:52 -04:00
{
meta_window_maximize ( window ) ;
if ( info - > saved_rect_set )
{
meta_topic ( META_DEBUG_SM ,
" Restoring saved rect %d,%d %dx%d for window %s \n " ,
info - > saved_rect . x ,
info - > saved_rect . y ,
info - > saved_rect . width ,
info - > saved_rect . height ,
window - > desc ) ;
window - > saved_rect . x = info - > saved_rect . x ;
window - > saved_rect . y = info - > saved_rect . y ;
window - > saved_rect . width = info - > saved_rect . width ;
window - > saved_rect . height = info - > saved_rect . height ;
}
}
2002-06-22 20:21:20 -04:00
}
2001-07-27 00:36:44 -04:00
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 =
2002-10-16 16:12:24 -04:00
meta_screen_get_workspace_by_index ( window - > screen ,
GPOINTER_TO_INT ( tmp - > data ) ) ;
2001-07-27 00:36:44 -04:00
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 .
*/
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace )
meta_workspace_remove_window ( window - > workspace , window ) ;
2001-07-27 00:36:44 -04:00
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
/* Only restore to the first workspace if the window
* happened to be on more than one , since we have replaces
* window - > workspaces with window - > workspace
*/
meta_workspace_add_window ( spaces - > data , window ) ;
2001-07-27 00:36:44 -04:00
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
meta_topic ( META_DEBUG_SM ,
" Restoring saved window %s to workspace %d \n " ,
window - > desc ,
meta_workspace_index ( spaces - > data ) ) ;
2001-07-27 00:36:44 -04:00
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-10-28 00:35:30 -05:00
if ( window - > display - > window_with_menu = = window )
{
meta_ui_window_menu_free ( window - > display - > window_menu ) ;
window - > display - > window_menu = NULL ;
window - > display - > window_with_menu = NULL ;
}
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-08-25 16:59:09 -04:00
if ( window - > fullscreen )
{
MetaGroup * group ;
/* If the window is fullscreen, it may be forcing
* other windows in its group to a higher layer
*/
meta_stack_freeze ( window - > screen - > stack ) ;
group = meta_window_get_group ( window ) ;
if ( group )
meta_group_update_layers ( group ) ;
meta_stack_thaw ( window - > screen - > stack ) ;
}
2002-10-27 09:45:29 -05:00
meta_window_shutdown_group ( window ) ; /* safe to do this early as
* group . c won ' t re - add to the
* group if window - > unmanaging
*/
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 ,
2004-06-24 16:02:46 -04:00
" Focusing default window since we're unmanaging %s \n " ,
2002-01-03 18:28:19 -05:00
window - > desc ) ;
Fix a variety of focus race conditions in all focus modes, or at least
2004-10-04 Elijah Newren <newren@math.utah.edu>
Fix a variety of focus race conditions in all focus modes, or at
least make them harder to trigger (fixes #152000)
* src/core.[ch] (meta_core_user_lower_and_unfocus): add a
timestamp parameter; pass it along to
meta_workspace_focus_default_window
* src/display.[ch] (meta_display_get_current_time_roundtrip): new
function
* src/display.c (event_callback): pass a timestamp to the
meta_workspace_activate and meta_workspace_focus_default_window
function calls
* src/frames.c (meta_frames_button_press_event): pass a timestamp
to meta_core_user_lower_and_unfocus
* src/keybindings.c (handle_activate_workspace): pass a timestamp
to meta_workspace_activate, (process_workspace_switch_grab): pass
a timestamp to meta_workspace_focus_default_window and
meta_workspace_activate, (handle_toggle_desktop): pass a timestamp
to meta_workspace_focus_default_window,
(do_handle_move_to_workspace): pass a timestamp to
meta_workspace_activate_with_focus, (handle_workspace_switch):
meta_workspace_activate
* src/screen.c (meta_screen_new): pass a timestamp to
meta_workspace_activate
* src/window.c (meta_window_free): pass a timestamp to
meta_workspace_focus_default_window, (idle_calc_showing): don't
increment the focus sentinel here, (meta_window_minimize): pass a
timestamp to meta_workspace_focus_default_window,
(meta_window_client_message), pass a timestamp to
meta_workspace_focus_default_window
* src/workspace.h (meta_workspace_activate): add timestamp
parameter, (meta_workspace_activate_with_focus): add timestamp
parameter, (meta_workspace_focus_default_window): add timestamp
parameter
* src/workspace.c (meta_workspace_focus_mru_window): make this
function take a timestamp and use it for meta_window_focus or
XSetInputFocus, (meta_workspace_activate_with_focus): make this
function take a timestamp and pass it along to meta_window_focus
and meta_workspace_focus_default_window,
(meta_workspace_activate): make this function take a timestamp and
pass it to meta_workspace_activate_with_focus),
(meta_workspace_focus_default_window): make this function take a
timestamp, warn if its 0 but try to handle that case sanely, and
pass the timestamp on to meta_window_focus or
meta_workspace_focus_mru_window or XSetInputFocus
2004-10-04 16:32:59 -04:00
meta_workspace_focus_default_window ( window - > screen - > active_workspace , window , meta_display_get_current_time_roundtrip ( window - > display ) ) ;
2002-01-03 18:28:19 -05:00
}
2002-08-08 00:45:13 -04:00
else if ( window - > display - > expected_focus_window = = window )
{
meta_topic ( META_DEBUG_FOCUS ,
2004-06-24 16:02:46 -04:00
" Focusing default window since expected focus window freed %s \n " ,
2002-08-08 00:45:13 -04:00
window - > desc ) ;
window - > display - > expected_focus_window = NULL ;
Fix a variety of focus race conditions in all focus modes, or at least
2004-10-04 Elijah Newren <newren@math.utah.edu>
Fix a variety of focus race conditions in all focus modes, or at
least make them harder to trigger (fixes #152000)
* src/core.[ch] (meta_core_user_lower_and_unfocus): add a
timestamp parameter; pass it along to
meta_workspace_focus_default_window
* src/display.[ch] (meta_display_get_current_time_roundtrip): new
function
* src/display.c (event_callback): pass a timestamp to the
meta_workspace_activate and meta_workspace_focus_default_window
function calls
* src/frames.c (meta_frames_button_press_event): pass a timestamp
to meta_core_user_lower_and_unfocus
* src/keybindings.c (handle_activate_workspace): pass a timestamp
to meta_workspace_activate, (process_workspace_switch_grab): pass
a timestamp to meta_workspace_focus_default_window and
meta_workspace_activate, (handle_toggle_desktop): pass a timestamp
to meta_workspace_focus_default_window,
(do_handle_move_to_workspace): pass a timestamp to
meta_workspace_activate_with_focus, (handle_workspace_switch):
meta_workspace_activate
* src/screen.c (meta_screen_new): pass a timestamp to
meta_workspace_activate
* src/window.c (meta_window_free): pass a timestamp to
meta_workspace_focus_default_window, (idle_calc_showing): don't
increment the focus sentinel here, (meta_window_minimize): pass a
timestamp to meta_workspace_focus_default_window,
(meta_window_client_message), pass a timestamp to
meta_workspace_focus_default_window
* src/workspace.h (meta_workspace_activate): add timestamp
parameter, (meta_workspace_activate_with_focus): add timestamp
parameter, (meta_workspace_focus_default_window): add timestamp
parameter
* src/workspace.c (meta_workspace_focus_mru_window): make this
function take a timestamp and use it for meta_window_focus or
XSetInputFocus, (meta_workspace_activate_with_focus): make this
function take a timestamp and pass it along to meta_window_focus
and meta_workspace_focus_default_window,
(meta_workspace_activate): make this function take a timestamp and
pass it to meta_workspace_activate_with_focus),
(meta_workspace_focus_default_window): make this function take a
timestamp, warn if its 0 but try to handle that case sanely, and
pass the timestamp on to meta_window_focus or
meta_workspace_focus_mru_window or XSetInputFocus
2004-10-04 16:32:59 -04:00
meta_workspace_focus_default_window ( window - > screen - > active_workspace , window , meta_display_get_current_time_roundtrip ( window - > display ) ) ;
2002-08-08 00:45:13 -04:00
}
2002-01-03 18:28:19 -05:00
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
2003-06-25 23:09:38 -04:00
if ( window - > struts )
2002-02-07 22:34:26 -05:00
{
2003-06-25 23:09:38 -04:00
g_free ( window - > struts ) ;
window - > struts = NULL ;
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
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 ) ;
2003-02-27 20:24:44 -05:00
meta_window_unqueue_update_icon ( window ) ;
2002-04-13 00:58:45 -04:00
meta_window_free_delete_dialog ( window ) ;
2001-06-21 23:20:21 -04:00
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace )
meta_workspace_remove_window ( window - > workspace , window ) ;
2001-06-06 00:47:37 -04:00
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
g_assert ( window - > workspace = = NULL ) ;
2001-06-07 01:18:10 -04:00
2003-12-12 22:58:55 -05:00
# ifndef G_DISABLE_CHECKS
tmp = window - > screen - > workspaces ;
while ( tmp ! = NULL )
{
MetaWorkspace * workspace = tmp - > data ;
g_assert ( g_list_find ( workspace - > windows , window ) = = NULL ) ;
g_assert ( g_list_find ( workspace - > mru_list , window ) = = NULL ) ;
tmp = tmp - > next ;
}
# endif
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 */
2002-08-10 13:32:29 -04:00
if ( window - > frame )
meta_window_destroy_frame ( window ) ;
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2002-03-10 10:48:38 -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
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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
}
2002-08-10 13:32:29 -04:00
/* And we need to be sure the window is mapped so other WMs
* know that it isn ' t Withdrawn
*/
meta_error_trap_push ( window - > display ) ;
XMapWindow ( window - > display - > xdisplay ,
window - > xwindow ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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
}
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 ) ;
2003-10-13 16:15:40 -04:00
meta_display_ungrab_focus_window_button ( window - > display , window ) ;
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 ) ;
2003-01-05 02:51:02 -05:00
# ifdef HAVE_SHAPE
if ( META_DISPLAY_HAS_SHAPE ( window - > display ) )
XShapeSelectInput ( window - > display - > xdisplay , window - > xwindow , NoEventMask ) ;
# endif
2001-06-04 02:17:52 -04:00
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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 ) ;
2004-09-15 11:54:51 -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 ) ;
2002-11-30 22:58:04 -05:00
g_free ( window - > startup_id ) ;
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 ) ;
}
2002-10-21 17:44:35 -04:00
static void
2001-06-06 00:47:37 -04:00
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 ) ;
2003-02-22 23:56:11 -05:00
/* Metacity doesn't use icon windows, so data[1] should be None
* according to the ICCCM 2.0 Section 4.1 .3 .1 .
2001-06-06 00:47:37 -04:00
*/
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-10 23:24:20 -04:00
}
2002-10-21 17:44:35 -04:00
static void
2001-06-10 23:24:20 -04:00
set_net_wm_state ( MetaWindow * window )
{
int i ;
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
unsigned long data [ 11 ] ;
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-11-19 23:37:55 -05:00
if ( window - > skip_pager )
2001-06-11 01:47:51 -04:00
{
data [ i ] = window - > display - > atom_net_wm_state_skip_pager ;
+ + i ;
}
2002-11-19 23:37:55 -05:00
if ( window - > 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 ;
}
2005-01-28 09:48:47 -05:00
if ( ! meta_window_showing_on_its_workspace ( window ) | | window - > shaded )
2002-02-08 23:50:58 -05:00
{
data [ i ] = window - > display - > atom_net_wm_state_hidden ;
+ + i ;
}
2002-10-01 20:47:29 -04:00
if ( window - > wm_state_above )
{
data [ i ] = window - > display - > atom_net_wm_state_above ;
+ + i ;
}
if ( window - > wm_state_below )
{
data [ i ] = window - > display - > atom_net_wm_state_below ;
+ + i ;
}
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
if ( window - > wm_state_demands_attention )
{
data [ i ] = window - > display - > atom_net_wm_state_demands_attention ;
+ + 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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-06 00:47:37 -04:00
}
2001-10-25 00:51:25 -04:00
gboolean
2004-12-22 19:20:33 -05:00
meta_window_located_on_workspace ( MetaWindow * window ,
2001-10-25 00:51:25 -04:00
MetaWorkspace * workspace )
{
2002-06-19 22:29:19 -04:00
return ( window - > on_all_workspaces & & window - > screen = = workspace - > screen ) | |
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
( window - > workspace = = workspace ) ;
2001-10-25 00:51:25 -04:00
}
2003-03-17 01:36:39 -05:00
static gboolean
is_minimized_foreach ( MetaWindow * window ,
void * data )
{
gboolean * result = data ;
* result = window - > minimized ;
if ( * result )
return FALSE ; /* stop as soon as we find one */
else
return TRUE ;
}
static gboolean
ancestor_is_minimized ( MetaWindow * window )
{
gboolean is_minimized ;
is_minimized = FALSE ;
meta_window_foreach_ancestor ( window , is_minimized_foreach , & is_minimized ) ;
return is_minimized ;
}
2005-01-28 09:48:47 -05:00
gboolean
meta_window_showing_on_its_workspace ( MetaWindow * window )
2001-06-06 00:47:37 -04:00
{
2004-10-22 16:28:36 -04:00
gboolean showing ;
2003-11-08 00:29:23 -05:00
gboolean is_desktop_or_dock ;
2004-10-22 16:28:36 -04:00
MetaWorkspace * workspace_of_window ;
2001-07-03 22:10:54 -04:00
2004-10-22 16:28:36 -04:00
showing = TRUE ;
2001-10-14 23:39:41 -04:00
2004-10-22 16:28:36 -04:00
/* 1. See if we're minimized */
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 ( window - > minimized )
showing = FALSE ;
2004-10-22 16:28:36 -04:00
/* 2. See if we're in "show desktop" mode */
2003-11-08 00:29:23 -05:00
is_desktop_or_dock = FALSE ;
is_desktop_or_dock_foreach ( window ,
& is_desktop_or_dock ) ;
meta_window_foreach_ancestor ( window , is_desktop_or_dock_foreach ,
& is_desktop_or_dock ) ;
2004-10-22 16:28:36 -04:00
if ( window - > on_all_workspaces )
workspace_of_window = window - > screen - > active_workspace ;
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
else if ( window - > workspace )
workspace_of_window = window - > workspace ;
2004-10-22 16:28:36 -04:00
else /* This only seems to be needed for startup */
workspace_of_window = NULL ;
2003-05-16 17:59:08 -04:00
if ( showing & &
2004-10-22 16:28:36 -04:00
workspace_of_window & & workspace_of_window - > showing_desktop & &
2003-11-08 00:29:23 -05:00
! is_desktop_or_dock )
2001-10-14 23:39:41 -04:00
{
2004-10-22 16:28:36 -04:00
meta_verbose ( " We're showing the desktop on the workspace(s) that window %s is on \n " ,
2001-10-14 23:39:41 -04:00
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
2004-10-22 16:28:36 -04:00
/* 3. See if an ancestor is minimized (note that
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
* 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 )
{
2003-03-17 01:36:39 -05:00
if ( ancestor_is_minimized ( window ) )
showing = FALSE ;
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
}
2003-10-12 02:25:38 -04:00
#if 0
2004-10-22 16:28:36 -04:00
/* 4. See if we're drawing wireframe
2003-10-12 02:25:38 -04:00
*/
if ( window - > display - > grab_window = = window & &
window - > display - > grab_wireframe_active )
showing = FALSE ;
# endif
2004-10-22 16:28:36 -04:00
2002-11-03 15:30:45 -05:00
return showing ;
}
2004-12-19 21:53:08 -05:00
gboolean
meta_window_should_be_showing ( MetaWindow * window )
2004-10-22 16:28:36 -04:00
{
gboolean on_workspace ;
meta_verbose ( " Should be showing for window %s \n " , window - > desc ) ;
/* See if we're on the workspace */
2004-12-22 19:20:33 -05:00
on_workspace = meta_window_located_on_workspace ( window ,
2004-10-22 16:28:36 -04:00
window - > screen - > active_workspace ) ;
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 ) ) ;
if ( window - > on_all_workspaces )
meta_verbose ( " Window %s is on all workspaces \n " , window - > desc ) ;
2005-01-28 09:48:47 -05:00
return on_workspace & & meta_window_showing_on_its_workspace ( window ) ;
2004-10-22 16:28:36 -04:00
}
2002-11-03 15:30:45 -05:00
static void
implement_showing ( MetaWindow * window ,
gboolean showing )
{
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
/* Actually show/hide the window */
2002-11-03 18:42:21 -05:00
meta_verbose ( " Implement showing = %d for window %s \n " ,
showing , 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
if ( ! showing )
2001-06-06 00:47:37 -04:00
{
2002-11-03 15:30:45 -05:00
gboolean on_workspace ;
2004-12-22 19:20:33 -05:00
on_workspace = meta_window_located_on_workspace ( window ,
2002-11-03 15:30:45 -05:00
window - > screen - > active_workspace ) ;
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 .
*/
2003-10-12 02:25:38 -04:00
if ( on_workspace & & window - > minimized & & window - > mapped & &
! meta_prefs_get_reduced_resources ( ) )
2001-08-05 12:04:52 -04:00
{
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
2002-11-03 15:30:45 -05:00
void
meta_window_calc_showing ( MetaWindow * window )
{
2004-12-19 21:53:08 -05:00
implement_showing ( window , meta_window_should_be_showing ( window ) ) ;
2002-11-03 15:30:45 -05:00
}
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 ;
2002-11-03 15:30:45 -05:00
GSList * should_show ;
GSList * should_hide ;
GSList * unplaced ;
2003-05-30 16:24:00 -04:00
GSList * displays ;
2004-06-24 16:02:46 -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
2002-11-03 15:30:45 -05:00
/* We map windows from top to bottom and unmap from bottom to
* top , to avoid extra expose events . The exception is
* for unplaced windows , which have to be mapped from bottom to
* top so placement works .
2001-06-24 04:09:10 -04:00
*/
2002-11-03 15:30:45 -05:00
should_show = NULL ;
should_hide = NULL ;
unplaced = NULL ;
2003-05-30 16:24:00 -04:00
displays = NULL ;
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 ;
2002-11-03 15:30:45 -05:00
if ( ! window - > placed )
unplaced = g_slist_prepend ( unplaced , window ) ;
2004-12-19 21:53:08 -05:00
else if ( meta_window_should_be_showing ( window ) )
2002-11-03 15:30:45 -05:00
should_show = g_slist_prepend ( should_show , window ) ;
else
should_hide = g_slist_prepend ( should_hide , window ) ;
2001-06-21 23:20:21 -04:00
2002-11-03 15:30:45 -05:00
tmp = tmp - > next ;
}
/* bottom to top */
unplaced = g_slist_sort ( unplaced , stackcmp ) ;
should_hide = g_slist_sort ( should_hide , stackcmp ) ;
/* top to bottom */
should_show = g_slist_sort ( should_show , stackcmp ) ;
should_show = g_slist_reverse ( should_show ) ;
tmp = unplaced ;
while ( tmp ! = NULL )
{
MetaWindow * window ;
window = tmp - > data ;
2001-06-21 23:20:21 -04:00
meta_window_calc_showing ( window ) ;
2002-11-03 15:30:45 -05:00
tmp = tmp - > next ;
}
tmp = should_hide ;
while ( tmp ! = NULL )
{
MetaWindow * window ;
window = tmp - > data ;
implement_showing ( window , FALSE ) ;
tmp = tmp - > next ;
}
tmp = should_show ;
while ( tmp ! = NULL )
{
MetaWindow * window ;
window = tmp - > data ;
implement_showing ( window , TRUE ) ;
tmp = tmp - > next ;
}
tmp = copy ;
while ( tmp ! = NULL )
{
MetaWindow * window ;
window = tmp - > data ;
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 ;
}
2003-05-30 16:24:00 -04:00
2005-02-21 21:11:25 -05:00
if ( meta_prefs_get_focus_mode ( ) ! = META_FOCUS_MODE_CLICK )
{
/* When display->mouse_mode is false, we want to ignore
* EnterNotify events unless they come from mouse motion . To do
* that , we set a sentinel property on the root window if we ' re
* not in mouse_mode .
*/
tmp = should_show ;
while ( tmp ! = NULL )
{
MetaWindow * window = tmp - > data ;
if ( ! window - > display - > mouse_mode )
meta_display_increment_focus_sentinel ( window - > display ) ;
tmp = tmp - > next ;
}
}
2001-10-29 21:00:53 -05:00
g_slist_free ( copy ) ;
2002-01-18 22:50:03 -05:00
2002-11-03 15:30:45 -05:00
g_slist_free ( unplaced ) ;
g_slist_free ( should_show ) ;
g_slist_free ( should_hide ) ;
2003-05-30 16:24:00 -04:00
g_slist_free ( displays ) ;
2002-11-03 15:30:45 -05:00
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
}
2002-06-14 21:46:13 -04:00
static gboolean
2005-02-12 02:19:41 -05:00
intervening_user_event_occurred ( MetaWindow * window )
2002-06-14 21:46:13 -04:00
{
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
Time compare ;
2005-02-12 02:19:41 -05:00
MetaWindow * focus_window ;
focus_window = window - > display - > focus_window ;
meta_topic ( META_DEBUG_STARTUP ,
" COMPARISON: \n "
" net_wm_user_time_set : %d \n "
" net_wm_user_time : %lu \n "
" initial_timestamp_set: %d \n "
" initial_timestamp : %lu \n " ,
window - > net_wm_user_time_set ,
window - > net_wm_user_time ,
window - > initial_timestamp_set ,
window - > initial_timestamp ) ;
if ( focus_window ! = NULL )
{
meta_topic ( META_DEBUG_STARTUP ,
" COMPARISON (continued): \n "
" focus_window : %s \n "
" fw->net_wm_user_time : %lu \n " ,
focus_window - > desc ,
focus_window - > net_wm_user_time ) ;
}
/* We expect the most common case for not focusing a new window
* to be when a hint to not focus it has been set . Since we can
* deal with that case rapidly , we use special case it - - this is
* merely a preliminary optimization . : )
*/
if ( ( ( window - > net_wm_user_time_set = = TRUE ) & &
( window - > net_wm_user_time = = 0 ) )
| |
( ( window - > initial_timestamp_set = = TRUE ) & &
( window - > initial_timestamp = = 0 ) ) )
{
meta_topic ( META_DEBUG_STARTUP ,
" window %s explicitly requested no focus \n " ,
window - > desc ) ;
return TRUE ;
}
if ( ! ( window - > net_wm_user_time_set ) & & ! ( window - > initial_timestamp_set ) )
{
meta_topic ( META_DEBUG_STARTUP ,
" no information about window %s found \n " ,
window - > desc ) ;
return FALSE ;
}
/* To determine the "launch" time of an application,
* startup - notification can set the TIMESTAMP and the
* application ( usually via its toolkit such as gtk or qt ) can
* set the _NET_WM_USER_TIME . If both are set , then it means
* the user has interacted with the application since it
* launched , and _NET_WM_USER_TIME is the value that should be
* used in the comparison .
*/
compare = window - > initial_timestamp_set ? window - > initial_timestamp : 0 ;
compare = window - > net_wm_user_time_set ? window - > net_wm_user_time : compare ;
if ( ( focus_window ! = NULL ) & &
XSERVER_TIME_IS_BEFORE ( compare , focus_window - > net_wm_user_time ) )
{
meta_topic ( META_DEBUG_STARTUP ,
" window %s focus prevented by other activity; %lu < %lu \n " ,
window - > desc , compare ,
focus_window - > net_wm_user_time ) ;
return TRUE ;
}
else
{
meta_topic ( META_DEBUG_STARTUP ,
" new window %s with no intervening events \n " ,
window - > desc ) ;
return FALSE ;
}
}
/* This function determines what state the window should have assuming that it
* and the focus_window have no relation
*/
static void
window_state_on_map ( MetaWindow * window ,
gboolean * takes_focus ,
gboolean * places_on_top )
{
gboolean intervening_events ;
intervening_events = intervening_user_event_occurred ( window ) ;
* takes_focus = ! intervening_events ;
* places_on_top = * takes_focus ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
2002-06-14 21:46:13 -04:00
/* don't initially focus windows that are intended to not accept
* focus
*/
if ( ! ( window - > input | | window - > take_focus ) )
2005-02-12 02:19:41 -05:00
{
* takes_focus = FALSE ;
return ;
}
2002-06-14 21:46:13 -04:00
switch ( window - > type )
{
2005-02-12 02:19:41 -05:00
case META_WINDOW_UTILITY :
case META_WINDOW_TOOLBAR :
* takes_focus = FALSE ;
* places_on_top = FALSE ;
break ;
2002-06-14 21:46:13 -04:00
case META_WINDOW_DOCK :
case META_WINDOW_DESKTOP :
case META_WINDOW_SPLASHSCREEN :
case META_WINDOW_MENU :
2005-02-12 02:19:41 -05:00
/* don't focus any of these; places_on_top may be irrelevant for some of
* these ( e . g . dock ) - - but you never know - - the focus window might also be
* of the same type in some weird situation . . .
*/
* takes_focus = FALSE ;
2002-06-14 21:46:13 -04:00
break ;
case META_WINDOW_NORMAL :
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
case META_WINDOW_DIALOG :
case META_WINDOW_MODAL_DIALOG :
2005-02-12 02:19:41 -05:00
/* The default is correct for these */
2002-06-14 21:46:13 -04:00
break ;
}
}
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 ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
gboolean takes_focus_on_map ;
2005-02-12 02:19:41 -05:00
gboolean place_on_top_on_map ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04: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 ;
2005-02-12 02:19:41 -05:00
window_state_on_map ( window , & takes_focus_on_map , & place_on_top_on_map ) ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
2005-02-12 02:19:41 -05:00
meta_topic ( META_DEBUG_WINDOW_STATE ,
" Window %s %s focus on map, and %s place on top on map. \n " ,
window - > desc ,
takes_focus_on_map ? " does " : " does not " ,
place_on_top_on_map ? " does " : " does not " ) ;
if ( ! takes_focus_on_map & &
window - > display - > focus_window ! = NULL & &
2005-02-20 17:40:08 -05:00
! place_on_top_on_map & &
window - > showing_for_first_time )
2004-08-05 13:48:39 -04:00
{
2004-10-25 12:28:57 -04:00
if ( meta_window_is_ancestor_of_transient ( window - > display - > focus_window ,
window ) )
{
/* This happens for error dialogs or alerts; these need to remain on
* top , but it would be confusing to have its ancestor remain
* focused .
*/
meta_topic ( META_DEBUG_STARTUP ,
" The focus window %s is an ancestor of the newly mapped "
" window %s which isn't being focused. Unfocusing the "
" ancestor. \n " ,
window - > display - > focus_window - > desc , window - > desc ) ;
meta_display_focus_the_no_focus_window ( window - > display , meta_display_get_current_time_roundtrip ( window - > display ) ) ;
}
else
{
meta_window_stack_just_below ( window , window - > display - > focus_window ) ;
ensure_mru_position_after ( window , window - > display - > focus_window ) ;
2005-02-11 14:20:44 -05:00
if ( ! window - > placed )
window - > denied_focus_and_not_transient = TRUE ;
2004-10-25 12:28:57 -04:00
}
2004-08-05 13:48:39 -04:00
}
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
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 ;
2005-02-11 14:20:44 -05:00
/* Don't want to accidentally reuse the fact that we had been denied
* focus in any future constraints unless we ' re denied focus again .
*/
window - > denied_focus_and_not_transient = FALSE ;
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-09 23:17:15 -04:00
}
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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
2004-12-28 01:01:42 -05:00
/* We don't want to worry about all cases from inside
* implement_showing ( ) ; we only want to worry about focus if this
* window has not been shown before .
*/
if ( window - > showing_for_first_time )
2001-10-29 21:00:53 -05:00
{
2004-12-28 01:01:42 -05:00
window - > showing_for_first_time = FALSE ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
if ( takes_focus_on_map )
2002-06-14 21:46:13 -04:00
{
meta_window_focus ( window ,
2004-10-25 12:28:57 -04:00
meta_display_get_current_time_roundtrip ( window - > display ) ) ;
2002-05-16 15:08:20 -04:00
}
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
else
2004-10-25 12:28:57 -04:00
{
2005-02-12 02:19:41 -05:00
/* Only set the demands attention hint if the window doesn't
* take focus on map and it isn ' t placed on top on map .
*/
if ( ! place_on_top_on_map )
window - > wm_state_demands_attention = TRUE ;
2004-10-25 12:28:57 -04:00
/* Prevent EnterNotify events in sloppy/mouse focus from
* erroneously focusing the window that had been denied
* focus . FIXME : This introduces a race ; I have a couple
* ideas for a better way to accomplish the same thing , but
* they ' re more involved so do it this way for now .
*/
meta_display_increment_focus_sentinel ( window - > display ) ;
}
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 ) ;
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
2003-06-25 23:09:38 -04:00
if ( window - > struts )
2002-02-08 01:01:58 -05:00
{
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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 ) ;
2003-06-25 23:09:38 -04:00
if ( window - > 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
}
2003-03-17 01:36:39 -05:00
static gboolean
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
queue_calc_showing_func ( MetaWindow * window ,
void * data )
{
meta_window_queue_calc_showing ( window ) ;
2003-03-17 01:36:39 -05:00
return 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
}
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 ,
2004-06-24 16:02:46 -04:00
" Focusing default window due to minimization of focus window %s \n " ,
2002-01-03 18:28:19 -05:00
window - > desc ) ;
Fix a variety of focus race conditions in all focus modes, or at least
2004-10-04 Elijah Newren <newren@math.utah.edu>
Fix a variety of focus race conditions in all focus modes, or at
least make them harder to trigger (fixes #152000)
* src/core.[ch] (meta_core_user_lower_and_unfocus): add a
timestamp parameter; pass it along to
meta_workspace_focus_default_window
* src/display.[ch] (meta_display_get_current_time_roundtrip): new
function
* src/display.c (event_callback): pass a timestamp to the
meta_workspace_activate and meta_workspace_focus_default_window
function calls
* src/frames.c (meta_frames_button_press_event): pass a timestamp
to meta_core_user_lower_and_unfocus
* src/keybindings.c (handle_activate_workspace): pass a timestamp
to meta_workspace_activate, (process_workspace_switch_grab): pass
a timestamp to meta_workspace_focus_default_window and
meta_workspace_activate, (handle_toggle_desktop): pass a timestamp
to meta_workspace_focus_default_window,
(do_handle_move_to_workspace): pass a timestamp to
meta_workspace_activate_with_focus, (handle_workspace_switch):
meta_workspace_activate
* src/screen.c (meta_screen_new): pass a timestamp to
meta_workspace_activate
* src/window.c (meta_window_free): pass a timestamp to
meta_workspace_focus_default_window, (idle_calc_showing): don't
increment the focus sentinel here, (meta_window_minimize): pass a
timestamp to meta_workspace_focus_default_window,
(meta_window_client_message), pass a timestamp to
meta_workspace_focus_default_window
* src/workspace.h (meta_workspace_activate): add timestamp
parameter, (meta_workspace_activate_with_focus): add timestamp
parameter, (meta_workspace_focus_default_window): add timestamp
parameter
* src/workspace.c (meta_workspace_focus_mru_window): make this
function take a timestamp and use it for meta_window_focus or
XSetInputFocus, (meta_workspace_activate_with_focus): make this
function take a timestamp and pass it along to meta_window_focus
and meta_workspace_focus_default_window,
(meta_workspace_activate): make this function take a timestamp and
pass it to meta_workspace_activate_with_focus),
(meta_workspace_focus_default_window): make this function take a
timestamp, warn if its 0 but try to handle that case sanely, and
pass the timestamp on to meta_window_focus or
meta_workspace_focus_mru_window or XSetInputFocus
2004-10-04 16:32:59 -04:00
meta_workspace_focus_default_window ( window - > screen - > active_workspace , window , meta_display_get_current_time_roundtrip ( window - > display ) ) ;
2002-01-03 18:28:19 -05:00
}
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 )
{
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
}
}
2002-09-24 17:33:34 -04:00
static void
meta_window_save_rect ( MetaWindow * window )
{
if ( ! ( window - > maximized | | window - > fullscreen ) )
{
/* 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 ;
}
}
}
2003-06-09 19:49:02 -04:00
void
meta_window_maximize_internal ( MetaWindow * window ,
MetaRectangle * saved_rect )
{
meta_topic ( META_DEBUG_WINDOW_OPS ,
" Maximizing %s \n " , window - > desc ) ;
if ( saved_rect ! = NULL )
window - > saved_rect = * saved_rect ;
else
meta_window_save_rect ( window ) ;
window - > maximized = TRUE ;
recalc_window_features ( window ) ;
set_net_wm_state ( window ) ;
}
2001-06-07 01:18:10 -04:00
void
meta_window_maximize ( MetaWindow * window )
{
if ( ! window - > maximized )
{
2002-08-10 15:04:55 -04:00
if ( window - > shaded )
meta_window_unshade ( window ) ;
2002-01-10 01:31:31 -05:00
2003-06-09 19:49:02 -04:00
/* if the window hasn't been placed yet, we'll maximize it then
*/
if ( ! window - > placed )
{
window - > maximize_after_placement = TRUE ;
return ;
}
meta_window_maximize_internal ( window , NULL ) ;
2001-10-14 18:13:53 -04:00
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-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
2003-06-30 10:49:11 -04:00
/* When we unmaximize, if we're doing a mouse move also we could
* get the window suddenly jumping to the upper left corner of
* the workspace , since that ' s where it was when the grab op
* started . So we need to update the grab state .
*/
if ( meta_grab_op_is_moving ( window - > display - > grab_op ) & &
window - > display - > grab_window = = window )
{
2003-10-12 02:25:38 -04:00
window - > display - > grab_anchor_window_pos = window - > saved_rect ;
2003-06-30 10:49:11 -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
2005-01-06 00:24:59 -05:00
if ( window - > display - > grab_wireframe_active )
{
window - > display - > grab_wireframe_rect = window - > saved_rect ;
}
2003-01-15 22:20:34 -05:00
recalc_window_features ( window ) ;
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
}
2003-06-27 10:49:56 -04:00
void
meta_window_make_above ( MetaWindow * window )
{
window - > wm_state_above = TRUE ;
meta_window_update_layer ( window ) ;
meta_window_raise ( window ) ;
set_net_wm_state ( window ) ;
}
void
meta_window_unmake_above ( MetaWindow * window )
{
window - > wm_state_above = FALSE ;
meta_window_raise ( window ) ;
meta_window_update_layer ( window ) ;
set_net_wm_state ( window ) ;
}
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 ) ;
2002-08-10 15:04:55 -04:00
if ( window - > shaded )
meta_window_unshade ( window ) ;
2002-09-24 17:33:34 -04:00
meta_window_save_rect ( window ) ;
2002-02-23 17:58:02 -05:00
window - > fullscreen = TRUE ;
2002-08-12 17:32:13 -04:00
meta_stack_freeze ( window - > screen - > stack ) ;
2002-09-24 17:22:06 -04:00
meta_window_update_layer ( window ) ;
2002-08-12 17:32:13 -04:00
2002-02-23 17:58:02 -05:00
meta_window_raise ( window ) ;
2002-08-12 17:32:13 -04:00
meta_stack_thaw ( window - > screen - > stack ) ;
2002-02-23 17:58:02 -05:00
/* move_resize with new constraints
*/
meta_window_queue_move_resize ( window ) ;
2003-01-15 22:20:34 -05:00
recalc_window_features ( window ) ;
2002-02-23 17:58:02 -05:00
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 ) ;
2005-01-31 11:49:23 -05:00
meta_window_update_layer ( window ) ;
2003-01-15 22:20:34 -05:00
recalc_window_features ( window ) ;
2002-02-23 17:58:02 -05:00
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
{
2002-08-06 00:11:23 -04:00
#if 0
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
}
2002-08-06 00:11:23 -04:00
# endif
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 ,
2005-02-08 22:18:46 -05:00
meta_display_get_current_time_roundtrip ( window - > display ) ) ;
2002-01-03 18:28:19 -05:00
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 ) ;
2005-02-08 22:18:46 -05:00
meta_window_focus ( window ,
meta_display_get_current_time_roundtrip ( window - > display ) ) ;
2001-06-10 23:24:20 -04:00
set_net_wm_state ( window ) ;
}
}
2003-03-17 01:36:39 -05:00
static gboolean
unminimize_func ( MetaWindow * window ,
void * data )
{
meta_window_unminimize ( window ) ;
return 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
static void
unminimize_window_and_all_transient_parents ( MetaWindow * window )
{
2003-05-18 13:16:03 -04:00
meta_window_unminimize ( window ) ;
2003-03-17 01:36:39 -05:00
meta_window_foreach_ancestor ( window , unminimize_func , NULL ) ;
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
}
2001-10-29 02:00:46 -05:00
void
meta_window_activate ( MetaWindow * window ,
guint32 timestamp )
{
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
2005-02-20 12:14:16 -05:00
meta_topic ( META_DEBUG_FOCUS ,
" _NET_ACTIVE_WINDOW message sent for %s at time %lu. \n " ,
window - > desc , ( unsigned long ) timestamp ) ;
2005-02-06 11:52:26 -05:00
/* Older EWMH spec didn't specify a timestamp, so it can be 0 and we
* have to treat that as a new request .
*/
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
2005-02-20 12:14:16 -05:00
if ( XSERVER_TIME_IS_BEFORE ( timestamp , window - > display - > last_user_time ) & &
2005-02-06 11:52:26 -05:00
timestamp ! = 0 )
{
meta_topic ( META_DEBUG_FOCUS ,
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
2005-02-20 12:14:16 -05:00
" last_user_time (%lu) is more recent; ignoring "
" _NET_ACTIVE_WINDOW message. \n " ,
window - > display - > last_user_time ) ;
2005-02-06 11:52:26 -05:00
window - > wm_state_demands_attention = TRUE ;
set_net_wm_state ( window ) ;
return ;
}
2005-02-08 22:15:11 -05:00
if ( timestamp = = 0 )
timestamp = meta_display_get_current_time_roundtrip ( window - > display ) ;
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
2005-02-20 12:14:16 -05:00
meta_window_set_user_time ( window , timestamp ) ;
2004-08-07 20:02:02 -04:00
2002-04-28 00:52:26 -04:00
/* disable show desktop mode unless we're a desktop component */
2003-05-16 17:59:08 -04:00
maybe_leave_show_desktop_mode ( window ) ;
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 ) ;
2005-02-20 17:44:15 -05:00
/* Activate the window, moving to its workspace if necessary */
if ( ! meta_window_located_on_workspace ( window ,
window - > screen - > active_workspace ) )
{
meta_topic ( META_DEBUG_FOCUS ,
" Focusing and moving to workspace of window %s due to "
" activation \n " ,
window - > desc ) ;
meta_workspace_activate_with_focus ( window - > workspace ,
window ,
timestamp ) ;
}
else
{
meta_window_raise ( window ) ;
meta_topic ( META_DEBUG_FOCUS ,
" Focusing window %s due to activation \n " ,
window - > desc ) ;
meta_window_focus ( window , timestamp ) ;
}
2001-10-29 02:00:46 -05:00
}
2001-06-10 23:24:20 -04:00
2003-03-08 18:43:17 -05:00
/* returns values suitable for meta_window_move
* i . e . static gravity
*/
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 ,
2003-03-08 18:43:17 -05:00
int width ,
int height ,
2001-06-10 23:24:20 -04:00
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 ;
2003-03-08 18:43:17 -05:00
frame_width = child_x + width + fgeom - > right_width ;
frame_height = child_y + height + fgeom - > bottom_height ;
2001-06-10 23:24:20 -04:00
}
else
{
child_x = 0 ;
child_y = 0 ;
2003-03-08 18:43:17 -05:00
frame_width = width ;
frame_height = height ;
2001-06-10 23:24:20 -04:00
}
/* 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 :
2003-03-08 18:43:17 -05:00
ref_x = x + width / 2 + bw ;
2001-06-10 23:24:20 -04:00
ref_y = y ;
break ;
case NorthEastGravity :
2003-03-08 18:43:17 -05:00
ref_x = x + width + bw * 2 ;
2001-06-10 23:24:20 -04:00
ref_y = y ;
break ;
case WestGravity :
ref_x = x ;
2003-03-08 18:43:17 -05:00
ref_y = y + height / 2 + bw ;
2001-06-10 23:24:20 -04:00
break ;
case CenterGravity :
2003-03-08 18:43:17 -05:00
ref_x = x + width / 2 + bw ;
ref_y = y + height / 2 + bw ;
2001-06-10 23:24:20 -04:00
break ;
case EastGravity :
2003-03-08 18:43:17 -05:00
ref_x = x + width + bw * 2 ;
ref_y = y + height / 2 + bw ;
2001-06-10 23:24:20 -04:00
break ;
case SouthWestGravity :
ref_x = x ;
2003-03-08 18:43:17 -05:00
ref_y = y + height + bw * 2 ;
2001-06-10 23:24:20 -04:00
break ;
case SouthGravity :
2003-03-08 18:43:17 -05:00
ref_x = x + width / 2 + bw ;
ref_y = y + height + bw * 2 ;
2001-06-10 23:24:20 -04:00
break ;
case SouthEastGravity :
2003-03-08 18:43:17 -05:00
ref_x = x + width + bw * 2 ;
ref_y = y + height + bw * 2 ;
2001-06-10 23:24:20 -04:00
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 ;
}
2003-03-08 18:43:17 -05:00
static void
get_mouse_deltas_for_resize ( MetaWindow * window ,
int resize_gravity ,
int w ,
int h ,
int * x_delta ,
int * y_delta )
{
switch ( meta_x_direction_from_gravity ( resize_gravity ) )
{
case META_RESIZE_LEFT_OR_TOP :
* x_delta = window - > rect . width - w ;
break ;
case META_RESIZE_RIGHT_OR_BOTTOM :
* x_delta = w - window - > rect . width ;
break ;
case META_RESIZE_CENTER :
/* FIXME this implies that with center gravity you have to grow
* in increments of two
*/
* x_delta = ( w - window - > rect . width ) / 2 ;
break ;
}
switch ( meta_y_direction_from_gravity ( resize_gravity ) )
{
case META_RESIZE_LEFT_OR_TOP :
* y_delta = window - > rect . height - h ;
break ;
case META_RESIZE_RIGHT_OR_BOTTOM :
* y_delta = h - window - > rect . height ;
break ;
case META_RESIZE_CENTER :
/* FIXME this implies that with center gravity you have to grow
* in increments of two
*/
* y_delta = ( h - window - > rect . height ) / 2 ;
break ;
}
}
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
# ifdef HAVE_XSYNC
static void
send_sync_request ( MetaWindow * window )
{
XSyncValue value ;
XClientMessageEvent ev ;
window - > sync_request_serial + + ;
XSyncIntToValue ( & value , window - > sync_request_serial ) ;
ev . type = ClientMessage ;
ev . window = window - > xwindow ;
ev . message_type = window - > display - > atom_wm_protocols ;
ev . format = 32 ;
ev . data . l [ 0 ] = window - > display - > atom_net_wm_sync_request ;
ev . data . l [ 1 ] = meta_display_get_current_time ( window - > display ) ;
ev . data . l [ 2 ] = XSyncValueLow32 ( value ) ;
ev . data . l [ 3 ] = XSyncValueHigh32 ( value ) ;
/* We don't need to trap errors here as we are already
* inside an error_trap_push ( ) / pop ( ) pair .
*/
XSendEvent ( window - > display - > xdisplay ,
window - > xwindow , False , 0 , ( XEvent * ) & ev ) ;
g_get_current_time ( & window - > sync_request_time ) ;
}
# endif
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 frame_size_dx ;
2001-08-28 23:37:03 -04:00
int frame_size_dy ;
2003-11-08 12:25:49 -05:00
int size_dx ;
int size_dy ;
2001-08-28 23:37:03 -04:00
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 ;
2003-03-08 18:43:17 -05:00
int x_delta ;
int y_delta ;
MetaRectangle new_rect ;
MetaRectangle old_rect ;
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. */
2003-03-08 18:43:17 -05:00
meta_window_unqueue_move_resize ( window ) ;
2003-02-23 12:09:46 -05:00
2003-03-08 18:43:17 -05:00
old_rect = window - > rect ;
meta_window_get_position ( window , & old_rect . x , & old_rect . y ) ;
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) " : " " ,
old_rect . x , old_rect . y , old_rect . width , old_rect . height ) ;
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 ) ;
2003-03-08 18:43:17 -05:00
if ( is_configure_request | | do_gravity_adjust )
{
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 ,
w , h ,
& root_x_nw ,
& root_y_nw ) ;
meta_topic ( META_DEBUG_GEOMETRY ,
" Compensated position for gravity, new pos %d,%d \n " ,
root_x_nw , root_y_nw ) ;
}
2001-06-09 23:17:15 -04:00
2003-03-08 18:43:17 -05:00
get_mouse_deltas_for_resize ( window , resize_gravity , w , h ,
& x_delta , & y_delta ) ;
meta_window_constrain ( window ,
2003-03-30 05:52:07 -05:00
window - > frame ? & fgeom : NULL ,
2003-03-08 18:43:17 -05:00
& old_rect ,
root_x_nw - old_rect . x ,
root_y_nw - old_rect . y ,
meta_x_direction_from_gravity ( resize_gravity ) ,
x_delta ,
meta_y_direction_from_gravity ( resize_gravity ) ,
y_delta ,
& new_rect ) ;
2003-06-25 23:09:38 -04:00
2003-03-08 18:43:17 -05:00
w = new_rect . width ;
h = new_rect . height ;
root_x_nw = new_rect . x ;
root_y_nw = new_rect . y ;
2001-06-09 23:17:15 -04:00
if ( w ! = window - > rect . width | |
h ! = window - > rect . height )
need_resize_client = TRUE ;
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
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-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
2004-01-10 12:16:07 -05:00
/* If frame extents have changed, fill in other frame fields and
change frame ' s extents property . */
if ( window - > frame & &
( 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
{
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 ;
2004-01-10 12:16:07 -05:00
update_net_frame_extents ( window ) ;
2001-06-07 22:17:48 -04:00
}
2004-01-10 12:16:07 -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
2003-11-08 12:25:49 -05:00
/* configure frame first if we grow more than we shrink
*/
size_dx = w - window - > rect . width ;
size_dy = h - window - > rect . height ;
configure_frame_first = ( size_dx + size_dy > = 0 ) ;
2002-01-19 18:59:11 -05:00
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 ) ;
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
2004-08-08 12:18:52 -04:00
# ifdef HAVE_XSYNC
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
if ( window - > sync_request_counter ! = None & &
window - > display - > grab_sync_request_alarm ! = None & &
window - > sync_request_time . tv_usec = = 0 & &
window - > sync_request_time . tv_sec = = 0 )
{
send_sync_request ( window ) ;
}
2004-08-08 12:18:52 -04:00
# endif
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
2001-06-09 17:58:30 -04:00
XConfigureWindow ( window - > display - > xdisplay ,
window - > xwindow ,
mask ,
& values ) ;
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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-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-12-08 16:09:05 -05:00
static void
2003-01-03 14:06:53 -05:00
check_maximize_to_work_area ( MetaWindow * window ,
const MetaRectangle * work_area )
2002-12-08 16:09:05 -05:00
{
/* If we now fill the screen, maximize.
* the point here is that fill horz + fill vert = maximized
*/
MetaRectangle rect ;
if ( ! window - > has_maximize_func )
return ;
meta_window_get_outer_rect ( window , & rect ) ;
2003-01-03 14:06:53 -05:00
if ( rect . x > = work_area - > x & &
rect . y > = work_area - > y & &
2005-01-23 23:21:14 -05:00
( ( ( work_area - > width + work_area - > x ) - ( rect . width + rect . x ) ) <
2002-12-08 16:09:05 -05:00
window - > size_hints . width_inc ) & &
2005-01-23 23:21:14 -05:00
( ( ( work_area - > height + work_area - > y ) - ( rect . height + rect . y ) ) <
2002-12-08 16:09:05 -05:00
window - > size_hints . height_inc ) )
meta_window_maximize ( window ) ;
}
void
meta_window_fill_horizontal ( MetaWindow * window )
{
2003-01-03 14:06:53 -05:00
MetaRectangle work_area ;
2002-12-08 16:09:05 -05:00
int x , y , w , h ;
meta_window_get_user_position ( window , & x , & y ) ;
w = window - > rect . width ;
h = window - > rect . height ;
2003-02-23 12:09:46 -05:00
meta_window_get_work_area_current_xinerama ( window , & work_area ) ;
2003-01-03 14:06:53 -05:00
x = work_area . x ;
w = work_area . width ;
2002-12-08 16:09:05 -05:00
if ( window - > frame ! = NULL )
{
x + = window - > frame - > child_x ;
w - = ( window - > frame - > child_x + window - > frame - > right_width ) ;
}
meta_window_move_resize ( window , TRUE ,
x , y , w , h ) ;
2003-01-03 14:06:53 -05:00
check_maximize_to_work_area ( window , & work_area ) ;
2002-12-08 16:09:05 -05:00
}
void
meta_window_fill_vertical ( MetaWindow * window )
{
2003-01-03 14:06:53 -05:00
MetaRectangle work_area ;
2002-12-08 16:09:05 -05:00
int x , y , w , h ;
meta_window_get_user_position ( window , & x , & y ) ;
w = window - > rect . width ;
h = window - > rect . height ;
2003-02-23 12:09:46 -05:00
meta_window_get_work_area_current_xinerama ( window , & work_area ) ;
2002-12-08 16:09:05 -05:00
2003-01-03 14:06:53 -05:00
y = work_area . y ;
h = work_area . height ;
2002-12-08 16:09:05 -05:00
if ( window - > frame ! = NULL )
{
y + = window - > frame - > child_y ;
h - = ( window - > frame - > child_y + window - > frame - > bottom_height ) ;
}
meta_window_move_resize ( window , TRUE ,
x , y , w , h ) ;
2003-01-03 14:06:53 -05:00
check_maximize_to_work_area ( window , & work_area ) ;
2002-12-08 16:09:05 -05:00
}
2002-01-18 22:50:03 -05:00
static guint move_resize_idle = 0 ;
static GSList * move_resize_pending = NULL ;
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 ;
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 )
2003-09-30 16:36:02 -04:00
move_resize_idle = g_idle_add_full ( META_PRIORITY_RESIZE ,
idle_move_resize , NULL , NULL ) ;
2002-01-18 22:50:03 -05:00
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 ;
}
2004-08-18 22:05:24 -04:00
void
meta_window_get_xor_rect ( MetaWindow * window ,
const MetaRectangle * grab_wireframe_rect ,
MetaRectangle * xor_rect )
{
if ( window - > frame )
{
xor_rect - > x = grab_wireframe_rect - > x - window - > frame - > child_x ;
xor_rect - > y = grab_wireframe_rect - > y - window - > frame - > child_y ;
xor_rect - > width = grab_wireframe_rect - > width + window - > frame - > child_x + window - > frame - > right_width ;
if ( window - > shaded )
xor_rect - > height = window - > frame - > child_y ;
else
xor_rect - > height = grab_wireframe_rect - > height + window - > frame - > child_y + window - > frame - > bottom_height ;
}
else
* xor_rect = * grab_wireframe_rect ;
}
2002-11-30 22:58:04 -05:00
const char *
meta_window_get_startup_id ( MetaWindow * window )
{
if ( window - > startup_id = = NULL )
{
MetaGroup * group ;
group = meta_window_get_group ( window ) ;
if ( group ! = NULL )
return meta_group_get_startup_id ( group ) ;
}
return window - > startup_id ;
}
2005-01-25 12:26:06 -05:00
static MetaWindow *
get_modal_transient ( MetaWindow * window )
{
GSList * windows ;
GSList * tmp ;
MetaWindow * modal_transient ;
/* A window can't be the transient of itself, but this is just for
* convenience in the loop below ; we manually fix things up at the
* end if no real modal transient was found .
*/
modal_transient = window ;
windows = meta_display_list_windows ( window - > display ) ;
tmp = windows ;
while ( tmp ! = NULL )
{
MetaWindow * transient = tmp - > data ;
if ( transient - > xtransient_for = = modal_transient - > xwindow & &
transient - > wm_state_modal )
{
modal_transient = transient ;
tmp = windows ;
continue ;
}
tmp = tmp - > next ;
}
g_slist_free ( windows ) ;
if ( window = = modal_transient )
modal_transient = NULL ;
return modal_transient ;
}
2001-06-04 00:58:22 -04:00
void
meta_window_focus ( MetaWindow * window ,
Time timestamp )
2001-07-11 02:22:00 -04:00
{
2005-01-25 12:26:06 -05:00
MetaWindow * modal_transient ;
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
2005-01-25 12:26:06 -05:00
modal_transient = get_modal_transient ( window ) ;
if ( modal_transient ! = NULL )
{
meta_topic ( META_DEBUG_FOCUS ,
" %s has %s as a modal transient, so focusing it instead. \n " ,
window - > desc , modal_transient - > desc ) ;
if ( ! modal_transient - > on_all_workspaces & &
modal_transient - > workspace ! = window - > screen - > active_workspace )
meta_window_change_workspace ( modal_transient ,
window - > screen - > active_workspace ) ;
window = modal_transient ;
}
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 ;
}
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -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 ) ;
2004-12-23 01:44:56 -05:00
meta_display_set_input_focus_window ( window - > display ,
window ,
TRUE ,
timestamp ) ;
2001-06-23 01:49:35 -04:00
}
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 ,
2004-12-23 01:44:56 -05:00
" Setting input focus on %s since input = true \n " ,
2002-01-05 22:15:49 -05:00
window - > desc ) ;
2004-12-23 01:44:56 -05:00
meta_display_set_input_focus_window ( window - > display ,
window ,
FALSE ,
timestamp ) ;
2001-06-23 01:49:35 -04:00
}
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 ) ;
2002-08-08 00:45:13 -04:00
window - > display - > expected_focus_window = window ;
2001-06-23 01:49:35 -04:00
}
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-04 00:58:22 -04:00
}
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
if ( window - > wm_state_demands_attention )
{
window - > wm_state_demands_attention = FALSE ;
set_net_wm_state ( window ) ;
}
2001-06-04 00:58:22 -04:00
}
2002-11-22 01:00:18 -05:00
static void
meta_window_change_workspace_without_transients ( MetaWindow * window ,
MetaWorkspace * workspace )
2002-08-06 00:11:23 -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 ) ) ;
2002-10-04 10:49:00 -04:00
/* unstick if stuck. meta_window_unstick would call
* meta_window_change_workspace recursively if the window
* is not in the active workspace .
*/
if ( window - > on_all_workspaces )
meta_window_unstick ( window ) ;
2002-06-17 21:41:08 -04:00
/* See if we're already on this space. If not, make sure we are */
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace ! = workspace )
2002-08-06 00:11:23 -04:00
{
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
meta_workspace_remove_window ( window - > workspace , window ) ;
meta_workspace_add_window ( workspace , window ) ;
2002-08-06 00:11:23 -04:00
}
2001-06-09 01:14:43 -04:00
}
2003-03-17 01:36:39 -05:00
static gboolean
2002-11-22 01:00:18 -05:00
change_workspace_foreach ( MetaWindow * window ,
void * data )
{
meta_window_change_workspace_without_transients ( window , data ) ;
2003-03-17 01:36:39 -05:00
return TRUE ;
2002-11-22 01:00:18 -05:00
}
void
meta_window_change_workspace ( MetaWindow * window ,
MetaWorkspace * workspace )
{
meta_window_change_workspace_without_transients ( window , workspace ) ;
meta_window_foreach_transient ( window , change_workspace_foreach ,
workspace ) ;
}
2005-01-26 18:25:05 -05:00
static void
window_stick_impl ( MetaWindow * window )
2001-06-09 23:17:15 -04:00
{
2003-08-15 18:09:55 -04:00
GList * tmp ;
MetaWorkspace * workspace ;
2002-11-19 23:37:55 -05:00
meta_verbose ( " Sticking window %s current on_all_workspaces = %d \n " ,
window - > desc , window - > on_all_workspaces ) ;
2001-06-09 23:17:15 -04:00
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 ;
2003-08-15 18:09:55 -04:00
/* We do, however, change the MRU lists of all the workspaces
*/
2003-09-20 13:05:35 -04:00
tmp = window - > screen - > workspaces ;
2003-08-15 18:09:55 -04:00
while ( tmp )
{
workspace = ( MetaWorkspace * ) tmp - > data ;
if ( ! g_list_find ( workspace - > mru_list , window ) )
2004-08-05 12:23:37 -04:00
workspace - > mru_list = g_list_prepend ( workspace - > mru_list , window ) ;
2003-08-15 18:09:55 -04:00
tmp = tmp - > next ;
}
2001-06-09 23:17:15 -04:00
meta_window_set_current_workspace_hint ( window ) ;
meta_window_queue_calc_showing ( window ) ;
}
2005-01-26 18:25:05 -05:00
static void
window_unstick_impl ( MetaWindow * window )
2001-06-09 23:17:15 -04:00
{
2003-08-15 18:09:55 -04:00
GList * tmp ;
MetaWorkspace * workspace ;
2001-06-09 23:17:15 -04:00
if ( ! window - > on_all_workspaces )
return ;
/* Revert to window->workspaces */
window - > on_all_workspaces = FALSE ;
2003-08-15 18:09:55 -04:00
/* Remove window from MRU lists that it doesn't belong in */
2003-09-20 13:05:35 -04:00
tmp = window - > screen - > workspaces ;
2003-08-15 18:09:55 -04:00
while ( tmp )
{
workspace = ( MetaWorkspace * ) tmp - > data ;
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace ! = workspace )
2003-12-12 22:58:55 -05:00
workspace - > mru_list = g_list_remove ( workspace - > mru_list , window ) ;
2003-08-15 18:09:55 -04:00
tmp = tmp - > next ;
}
2001-06-09 23:17:15 -04:00
/* 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 .
*/
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > screen - > active_workspace ! = window - > workspace )
2001-06-09 23:17:15 -04:00
meta_window_change_workspace ( window , window - > screen - > active_workspace ) ;
meta_window_set_current_workspace_hint ( window ) ;
meta_window_queue_calc_showing ( window ) ;
}
2005-01-26 18:25:05 -05:00
static gboolean
stick_foreach_func ( MetaWindow * window ,
void * data )
{
gboolean stick ;
stick = * ( gboolean * ) data ;
if ( stick )
window_stick_impl ( window ) ;
else
window_unstick_impl ( window ) ;
return TRUE ;
}
void
meta_window_stick ( MetaWindow * window )
{
gboolean stick = TRUE ;
window_stick_impl ( window ) ;
meta_window_foreach_transient ( window ,
stick_foreach_func ,
& stick ) ;
}
void
meta_window_unstick ( MetaWindow * window )
{
gboolean stick = FALSE ;
window_unstick_impl ( window ) ;
meta_window_foreach_transient ( window ,
stick_foreach_func ,
& stick ) ;
}
2001-06-21 01:23:24 -04:00
unsigned long
meta_window_get_net_wm_desktop ( MetaWindow * window )
{
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > on_all_workspaces )
2001-06-21 01:23:24 -04:00
return 0xFFFFFFFF ;
else
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
return meta_workspace_index ( window - > workspace ) ;
2001-06-21 01:23:24 -04:00
}
2004-01-10 12:16:07 -05:00
static void
update_net_frame_extents ( MetaWindow * window )
{
unsigned long data [ 4 ] = { 0 , 0 , 0 , 0 } ;
if ( window - > frame )
{
/* Left */
data [ 0 ] = window - > frame - > child_x ;
/* Right */
data [ 1 ] = window - > frame - > right_width ;
/* Top */
data [ 2 ] = window - > frame - > child_y ;
/* Bottom */
data [ 3 ] = window - > frame - > bottom_height ;
}
meta_topic ( META_DEBUG_GEOMETRY ,
" Setting _NET_FRAME_EXTENTS on managed window 0x%lx "
" to top = %ld, left = %ld, bottom = %ld, right = %ld \n " ,
window - > xwindow , data [ 0 ] , data [ 1 ] , data [ 2 ] , data [ 3 ] ) ;
meta_error_trap_push ( window - > display ) ;
XChangeProperty ( window - > display - > xdisplay , window - > xwindow ,
window - > display - > atom_net_frame_extents ,
XA_CARDINAL ,
32 , PropModeReplace , ( guchar * ) data , 4 ) ;
meta_error_trap_pop ( window - > display , FALSE ) ;
}
2002-10-21 17:44:35 -04:00
void
2001-06-09 23:17:15 -04:00
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 ] ;
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
if ( window - > workspace = = NULL )
2002-03-10 10:48:38 -05:00
{
/* this happens when unmanaging windows */
2002-10-21 17:44:35 -04:00
return ;
2002-03-10 10:48:38 -05:00
}
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-09 23:17:15 -04:00
}
2005-02-12 02:34:30 -05:00
static gboolean
find_root_ancestor ( MetaWindow * window ,
void * data )
{
MetaWindow * * ancestor = data ;
/* Overwrite the previously "most-root" ancestor with the new one found */
* ancestor = window ;
/* We want this to continue until meta_window_foreach_ancestor quits because
* there are no more valid ancestors .
*/
return TRUE ;
}
2001-06-06 00:47:37 -04:00
void
meta_window_raise ( MetaWindow * window )
{
2005-02-12 02:34:30 -05:00
MetaWindow * ancestor ;
ancestor = window ;
meta_window_foreach_ancestor ( window , find_root_ancestor , & ancestor ) ;
2002-02-07 22:34:26 -05:00
meta_topic ( META_DEBUG_WINDOW_OPS ,
2005-02-12 02:34:30 -05:00
" Raising window %s, ancestor of %s \n " ,
ancestor - > desc , window - > desc ) ;
2001-06-06 00:47:37 -04:00
2005-02-12 02:34:30 -05:00
if ( window - > screen - > stack ! = ancestor - > screen - > stack )
{
meta_warning (
" Either stacks aren't per screen or some window has a weird "
" transient_for hint; window->screen->stack != "
" ancestor->screen->stack. window = %s, ancestor = %s. \n " ,
window - > desc , ancestor - > desc ) ;
/* Just punt and raise the window itself */
meta_stack_raise ( window - > screen - > stack , window ) ;
}
else
meta_stack_raise ( window - > screen - > stack , ancestor ) ;
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-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
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 ;
2002-07-24 11:41:44 -04:00
gboolean in_grab_op ;
/* We ignore configure requests while the user is moving/resizing
* the window , since these represent the app sucking and fighting
* the user , most likely due to a bug in the app ( e . g . pfaedit
* seemed to do this )
*
* Still have to do the ConfigureNotify and all , but pretend the
* app asked for the current size / position instead of the new one .
*/
in_grab_op = FALSE ;
if ( window - > display - > grab_op ! = META_GRAB_OP_NONE & &
window = = window - > display - > grab_window )
{
switch ( window - > display - > grab_op )
{
case META_GRAB_OP_MOVING :
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 :
in_grab_op = TRUE ;
break ;
default :
break ;
}
}
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
}
2002-07-24 11:41:44 -04:00
if ( in_grab_op )
allow_position_change = FALSE ;
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-07-24 11:41:44 -04:00
if ( ! in_grab_op )
{
if ( event - > xconfigurerequest . value_mask & CWWidth )
width = event - > xconfigurerequest . width ;
2001-08-29 00:16:30 -04:00
2002-07-24 11:41:44 -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 )
{
2005-02-06 12:01:41 -05:00
MetaWindow * active_window ;
active_window = window - > display - > expected_focus_window ;
if ( meta_prefs_get_disable_workarounds ( ) )
2002-05-28 22:22:04 -04:00
{
2005-02-06 12:01:41 -05:00
meta_topic ( META_DEBUG_STACK ,
" %s sent an xconfigure stacking request; this is "
" broken behavior and the request is being ignored. \n " ,
window - > desc ) ;
}
else if ( active_window & &
! meta_window_same_application ( window , active_window ) & &
XSERVER_TIME_IS_BEFORE ( window - > net_wm_user_time ,
active_window - > net_wm_user_time ) )
{
meta_topic ( META_DEBUG_STACK ,
" Ignoring xconfigure stacking request from %s (with "
" user_time %lu); currently active application is %s (with "
" user_time %lu). \n " ,
window - > desc ,
window - > net_wm_user_time ,
active_window - > desc ,
active_window - > net_wm_user_time ) ;
}
else
{
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 ;
}
2002-05-28 22:22:04 -04:00
}
}
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
2002-08-07 01:26:20 -04:00
# define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
# define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
2001-08-29 00:16:30 -04:00
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 )
{
2004-06-21 05:53:23 -04:00
Time timestamp ;
if ( event - > xclient . data . l [ 0 ] ! = 0 )
timestamp = event - > xclient . data . l [ 0 ] ;
else
timestamp = meta_display_get_current_time ( window - > display ) ;
meta_window_delete ( window , timestamp ) ;
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 ] ;
2002-11-19 23:37:55 -05:00
meta_verbose ( " Request to move %s to workspace %d \n " ,
2001-06-09 02:08:44 -04:00
window - > desc , space ) ;
workspace =
2002-10-16 16:12:24 -04:00
meta_screen_get_workspace_by_index ( window - > screen ,
space ) ;
2001-06-09 02:08:44 -04:00
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
2002-11-19 23:37:55 -05:00
meta_verbose ( " Window %s now on_all_workspaces = %d \n " ,
window - > desc , window - > on_all_workspaces ) ;
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 ;
2002-10-21 17:44:35 -04:00
meta_error_trap_push_with_return ( display ) ;
2001-06-09 02:08:44 -04:00
str1 = XGetAtomName ( display - > xdisplay , first ) ;
2002-10-21 17:44:35 -04:00
if ( meta_error_trap_pop_with_return ( display , TRUE ) ! = Success )
2001-06-09 02:08:44 -04:00
str1 = NULL ;
2002-10-21 17:44:35 -04:00
meta_error_trap_push_with_return ( display ) ;
2001-06-09 02:08:44 -04:00
str2 = XGetAtomName ( display - > xdisplay , second ) ;
2002-10-21 17:44:35 -04:00
if ( meta_error_trap_pop_with_return ( display , TRUE ) ! = Success )
2001-06-09 02:08:44 -04:00
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 )
{
2002-08-05 11:32:08 -04:00
window - > wm_state_skip_pager =
2001-06-11 01:47:51 -04:00
( action = = _NET_WM_STATE_ADD ) | |
2002-07-06 15:05:37 -04:00
( action = = _NET_WM_STATE_TOGGLE & & ! window - > skip_pager ) ;
2001-06-11 01:47:51 -04:00
2002-11-19 23:37:55 -05:00
recalc_window_features ( window ) ;
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 )
{
2002-08-05 11:32:08 -04:00
window - > wm_state_skip_taskbar =
2001-06-11 01:47:51 -04:00
( action = = _NET_WM_STATE_ADD ) | |
2002-07-06 15:05:37 -04:00
( action = = _NET_WM_STATE_TOGGLE & & ! window - > skip_taskbar ) ;
2001-06-11 01:47:51 -04:00
2002-11-19 23:37:55 -05:00
recalc_window_features ( window ) ;
2001-06-11 01:47:51 -04:00
set_net_wm_state ( window ) ;
}
2002-10-01 20:47:29 -04:00
if ( first = = display - > atom_net_wm_state_above | |
second = = display - > atom_net_wm_state_above )
{
window - > wm_state_above =
( action = = _NET_WM_STATE_ADD ) | |
( action = = _NET_WM_STATE_TOGGLE & & ! window - > wm_state_above ) ;
2002-10-16 10:53:19 -04:00
meta_window_update_layer ( window ) ;
2002-10-01 20:47:29 -04:00
set_net_wm_state ( window ) ;
}
if ( first = = display - > atom_net_wm_state_below | |
second = = display - > atom_net_wm_state_below )
{
window - > wm_state_below =
( action = = _NET_WM_STATE_ADD ) | |
( action = = _NET_WM_STATE_TOGGLE & & ! window - > wm_state_below ) ;
2002-10-16 10:53:19 -04:00
meta_window_update_layer ( window ) ;
2002-10-01 20:47:29 -04:00
set_net_wm_state ( window ) ;
}
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
if ( first = = display - > atom_net_wm_state_demands_attention | |
second = = display - > atom_net_wm_state_demands_attention )
{
window - > wm_state_demands_attention =
( action = = _NET_WM_STATE_ADD ) | |
( action = = _NET_WM_STATE_TOGGLE & & ! window - > wm_state_demands_attention ) ;
set_net_wm_state ( window ) ;
}
2001-06-11 01:47:51 -04:00
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 )
2005-01-09 19:27:00 -05: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 ;
2002-08-07 01:26:20 -04:00
int button ;
2001-08-29 00:16:30 -04:00
x_root = event - > xclient . data . l [ 0 ] ;
y_root = event - > xclient . data . l [ 1 ] ;
action = event - > xclient . data . l [ 2 ] ;
2002-08-07 01:26:20 -04:00
button = event - > xclient . data . l [ 3 ] ;
2001-08-29 00:16:30 -04:00
2002-02-24 14:58:27 -05:00
meta_topic ( META_DEBUG_WINDOW_OPS ,
2002-08-07 01:26:20 -04:00
" Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d, button %d \n " ,
2002-02-24 14:58:27 -05:00
window - > desc ,
2002-08-07 01:26:20 -04:00
x_root , y_root , action , button ) ;
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 ;
2002-08-07 01:26:20 -04:00
case _NET_WM_MOVERESIZE_SIZE_KEYBOARD :
op = META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN ;
break ;
case _NET_WM_MOVERESIZE_MOVE_KEYBOARD :
op = META_GRAB_OP_KEYBOARD_MOVING ;
break ;
2001-08-29 00:16:30 -04:00
default :
break ;
}
if ( op ! = META_GRAB_OP_NONE & &
2002-08-07 01:26:20 -04:00
( ( window - > has_move_func & & op = = META_GRAB_OP_KEYBOARD_MOVING ) | |
( window - > has_resize_func & & op = = META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN ) ) )
2001-08-29 00:16:30 -04:00
{
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
meta_window_begin_grab_op ( window ,
op ,
meta_display_get_current_time ( window - > display ) ) ;
2002-08-07 01:26:20 -04:00
}
else if ( op ! = META_GRAB_OP_NONE & &
( ( window - > has_move_func & & op = = META_GRAB_OP_MOVING ) | |
( window - > has_resize_func & &
( op ! = META_GRAB_OP_MOVING & &
op ! = META_GRAB_OP_KEYBOARD_MOVING ) ) ) )
{
/*
* the button SHOULD already be included in the message
2001-08-29 00:16:30 -04:00
*/
2002-08-07 01:26:20 -04:00
if ( button = = 0 )
{
int x , y , query_root_x , query_root_y ;
Window root , child ;
guint mask ;
/* 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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , TRUE ) ;
2002-08-07 01:26:20 -04:00
if ( mask & Button1Mask )
button = 1 ;
else if ( mask & Button2Mask )
button = 2 ;
else if ( mask & Button3Mask )
button = 3 ;
else
button = 0 ;
}
2001-08-29 00:16:30 -04:00
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 ,
2002-06-27 01:08:32 -04:00
window - > screen ,
2001-08-29 00:16:30 -04:00
window ,
op ,
2003-11-24 13:09:47 -05:00
FALSE , 0 /* event_serial */ ,
2001-08-29 00:16:30 -04:00
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 )
{
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
2005-02-20 12:14:16 -05:00
meta_verbose ( " _NET_ACTIVE_WINDOW request for window '%s', activating \n " ,
2002-01-03 18:28:19 -05:00
window - > desc ) ;
2001-10-07 19:06:19 -04:00
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
if ( event - > xclient . data . l [ 0 ] ! = 0 )
{
/* Client supports newer _NET_ACTIVE_WINDOW with a
* convenient timestamp
*/
meta_window_activate ( window ,
event - > xclient . data . l [ 1 ] ) ;
}
else
{
/* Client using older EWMH _NET_ACTIVE_WINDOW without a
* timestamp
*/
meta_window_activate ( window , meta_display_get_current_time ( window - > display ) ) ;
}
2001-10-07 19:06:19 -04:00
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-08-10 00:29:57 -04:00
/* FIXME our pointer tracking is broken; see how
* gtk + / gdk / x11 / gdkevents - x11 . c or XFree86 / xc / programs / xterm / misc . c
* handle it for the correct way . In brief you need to track
* pointer focus and regular focus , and handle EnterNotify in
* PointerRoot mode with no window manager . However as noted above ,
* accurate focus tracking will break things because we want to keep
* windows " focused " when using keybindings on them , and also we
* sometimes " focus " a window by focusing its frame or
* no_focus_window ; so this all needs rethinking massively .
*
* My suggestion is to change it so that we clearly separate
* actual keyboard focus tracking using the xterm algorithm ,
* and metacity ' s " pretend " focus window , and go through all
* the code and decide which one should be used in each place ;
* a hard bit is deciding on a policy for that .
*
* http : //bugzilla.gnome.org/show_bug.cgi?id=90382
*/
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 ;
2003-08-15 18:09:55 -04:00
2004-02-27 21:53:56 -05:00
/* Move to the front of the focusing workspace's MRU list.
* We should only be " removing " it from the MRU list if it ' s
* not already there . Note that it ' s possible that we might
* be processing this FocusIn after we ' ve changed to a
* different workspace ; we should therefore update the MRU
* list only if the window is actually on the active
* workspace .
2003-08-15 18:09:55 -04:00
*/
2004-02-27 21:53:56 -05:00
if ( window - > screen - > active_workspace & &
2004-12-22 19:20:33 -05:00
meta_window_located_on_workspace ( window ,
2004-02-27 21:53:56 -05:00
window - > screen - > active_workspace ) )
2003-08-15 18:09:55 -04:00
{
2004-02-27 21:53:56 -05:00
GList * link ;
link = g_list_find ( window - > screen - > active_workspace - > mru_list ,
window ) ;
g_assert ( link ) ;
window - > screen - > active_workspace - > mru_list =
g_list_remove_link ( window - > screen - > active_workspace - > mru_list ,
link ) ;
g_list_free ( link ) ;
2004-02-22 20:48:29 -05:00
2003-08-15 18:09:55 -04:00
window - > screen - > active_workspace - > mru_list =
g_list_prepend ( window - > screen - > active_workspace - > 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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2002-09-24 17:22:06 -04:00
/* move into FOCUSED_WINDOW layer */
meta_window_update_layer ( window ) ;
2003-06-07 01:07:08 -04:00
2003-10-13 16:15:40 -04:00
/* Ungrab click to focus button since the sync grab can interfere
* with some things you might do inside the focused window , by
* causing the client to get funky enter / leave events .
*/
2004-01-05 02:24:32 -05:00
if ( meta_prefs_get_focus_mode ( ) = = META_FOCUS_MODE_CLICK )
meta_display_ungrab_focus_window_button ( window - > display , window ) ;
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2002-09-24 17:22:06 -04:00
/* move out of FOCUSED_WINDOW layer */
meta_window_update_layer ( window ) ;
2003-06-07 01:07:08 -04:00
2003-10-13 16:15:40 -04:00
/* Re-grab for click to focus, if necessary */
2004-01-05 02:24:32 -05:00
if ( meta_prefs_get_focus_mode ( ) = = META_FOCUS_MODE_CLICK )
meta_display_grab_focus_window_button ( window - > display , window ) ;
}
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 )
{
2002-11-30 22:58:04 -05:00
/* FIXME once we move entirely to the window-props.h framework, we
* can just call reload on the property in the event and get rid of
* this if - else chain .
*/
2002-11-03 19:19:08 -05:00
if ( event - > atom = = XA_WM_NAME )
{
meta_verbose ( " Property notify on %s for WM_NAME \n " , window - > desc ) ;
/* don't bother reloading WM_NAME if using _NET_WM_NAME already */
if ( ! window - > using_net_wm_name )
meta_window_reload_property ( window , XA_WM_NAME ) ;
}
else if ( event - > atom = = window - > display - > atom_net_wm_name )
2001-06-02 00:14:18 -04:00
{
2002-11-03 19:19:08 -05:00
meta_verbose ( " Property notify on %s for NET_WM_NAME \n " , window - > desc ) ;
meta_window_reload_property ( window , window - > display - > atom_net_wm_name ) ;
/* if _NET_WM_NAME was unset, reload WM_NAME */
if ( ! window - > using_net_wm_name )
meta_window_reload_property ( window , XA_WM_NAME ) ;
}
else if ( event - > atom = = XA_WM_ICON_NAME )
{
meta_verbose ( " Property notify on %s for WM_ICON_NAME \n " , window - > desc ) ;
/* don't bother reloading WM_ICON_NAME if using _NET_WM_ICON_NAME already */
if ( ! window - > using_net_wm_icon_name )
meta_window_reload_property ( window , XA_WM_ICON_NAME ) ;
2001-06-02 00:14:18 -04:00
}
2002-11-03 19:19:08 -05:00
else if ( event - > atom = = window - > display - > atom_net_wm_icon_name )
{
meta_verbose ( " Property notify on %s for NET_WM_ICON_NAME \n " , window - > desc ) ;
meta_window_reload_property ( window , window - > display - > atom_net_wm_icon_name ) ;
/* if _NET_WM_ICON_NAME was unset, reload WM_ICON_NAME */
if ( ! window - > using_net_wm_icon_name )
meta_window_reload_property ( window , XA_WM_ICON_NAME ) ;
}
2001-06-02 00:14:18 -04:00
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 ) ;
2003-02-27 20:24:44 -05:00
meta_window_reload_property ( window , XA_WM_NORMAL_HINTS ) ;
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 ) ;
2003-02-27 20:24:44 -05:00
meta_window_reload_property ( window , window - > display - > atom_wm_protocols ) ;
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
2003-02-27 20:24:44 -05:00
meta_window_reload_property ( window , XA_WM_HINTS ) ;
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 ) ;
2002-08-24 17:49:32 -04:00
/* because ensure/destroy frame may unmap */
meta_window_queue_calc_showing ( window ) ;
2001-06-09 17:58:30 -04:00
}
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 = =
2003-06-12 03:03:04 -04:00
window - > display - > atom_net_wm_window_type )
2001-06-09 23:17:15 -04:00
{
2003-06-12 03:03:04 -04:00
meta_verbose ( " Property notify on %s for NET_WM_WINDOW_TYPE \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 )
{
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 ) ;
2003-02-27 20:24:44 -05:00
meta_window_queue_update_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 ) ;
2003-02-27 20:24:44 -05:00
meta_window_queue_update_icon ( window ) ;
2001-08-22 02:01:01 -04:00
}
2003-06-25 23:09:38 -04:00
else if ( ( event - > atom = = window - > display - > atom_net_wm_strut ) | |
( event - > atom = = window - > display - > atom_net_wm_strut_partial ) )
2002-01-10 01:31:31 -05:00
{
meta_verbose ( " Property notify on %s for _NET_WM_STRUT \n " , window - > desc ) ;
2003-06-25 23:09:38 -04:00
meta_window_update_struts ( window ) ;
2002-01-10 01:31:31 -05:00
}
2002-11-30 22:58:04 -05:00
else if ( event - > atom = = window - > display - > atom_net_startup_id )
{
meta_verbose ( " Property notify on %s for _NET_STARTUP_ID \n " , window - > desc ) ;
meta_window_reload_property ( window ,
window - > display - > atom_net_startup_id ) ;
}
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
else if ( event - > atom = = window - > display - > atom_net_wm_sync_request_counter )
2002-12-09 22:23:04 -05:00
{
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
meta_verbose ( " Property notify on %s for _NET_WM_SYNC_REQUEST_COUNTER \n " , window - > desc ) ;
2002-12-09 22:23:04 -05:00
meta_window_reload_property ( window ,
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
window - > display - > atom_net_wm_sync_request_counter ) ;
2002-12-09 22:23:04 -05:00
}
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
else if ( event - > atom = = window - > display - > atom_net_wm_user_time )
{
meta_verbose ( " Property notify on %s for _NET_WM_USER_TIME \n " , window - > desc ) ;
meta_window_reload_property ( window ,
window - > display - > atom_net_wm_user_time ) ;
}
2003-12-13 18:00:06 -05:00
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-02 21:33:27 -04:00
}
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 ;
2002-07-06 15:05:37 -04:00
window - > wm_state_skip_taskbar = FALSE ;
window - > wm_state_skip_pager = FALSE ;
2002-10-01 20:47:29 -04:00
window - > wm_state_above = FALSE ;
window - > wm_state_below = FALSE ;
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
window - > wm_state_demands_attention = FALSE ;
2002-07-06 15:05:37 -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 )
2003-06-09 19:49:02 -04:00
window - > maximize_after_placement = TRUE ;
2002-01-03 19:58:39 -05:00
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_maximized_vert )
2003-06-09 19:49:02 -04:00
window - > maximize_after_placement = TRUE ;
2002-01-03 19:58:39 -05:00
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_modal )
window - > wm_state_modal = TRUE ;
2002-07-06 15:05:37 -04:00
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_skip_taskbar )
window - > wm_state_skip_taskbar = TRUE ;
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_skip_pager )
window - > wm_state_skip_pager = TRUE ;
2002-09-18 16:19:45 -04:00
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_fullscreen )
window - > fullscreen = TRUE ;
2002-10-01 20:47:29 -04:00
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_above )
window - > wm_state_above = TRUE ;
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_below )
window - > wm_state_below = TRUE ;
Fix some support for EWMH hints, and fix USER_TIME support to include the
2004-07-31 Rob Adams <readams@readams.net>
Fix some support for EWMH hints, and fix USER_TIME support to
include the DEMANDS_ATTENTION hint. Also includes some code for
implementing _NET_RESTACK_WINDOW and _NET_MOVERESIZE_WINDOW, but
this is disabled pending feature thaw.
* COMPLIANCE: update with new information
* src/display.c (meta_display_open): add new hints to list
* src/display.h (_MetaDisplay): Add new atoms to struct
* src/screen.c (set_supported_hint): update the list of support
hints.
(set_desktop_viewport_hint): new function sets the viewport hint
to (0,0) as required by the spec for WMs with no viewport support.
(set_desktop_geometry_hint): new function to set the desktop size
hint to the size of the display, since we don't implement large
desktop support, as required by the spec.
(meta_screen_resize): update the geometry hint on screen resize
* src/window.c (meta_window_new_with_attrs): Initialize
demands_attention state
(set_net_wm_state): Set demands_attention hint in the window state
(meta_window_show): If we don't pop up a window because of
USER_TIME, set DEMANDS_ATTENTION on the window.
(meta_window_focus): When a window receives focus, remove
DEMANDS_ATTENTION hint
(meta_window_client_message): Allow other apps to set
DEMANDS_ATTENTION on a window. Also, if the _NET_ACTIVE_WINDOW
hint includes a timestamp, use it.
(update_net_wm_state): Read DEMANDS_ATTENTION state also
* src/window.h (_MetaWindow): add wm_state_demands_attention bit.
2004-07-31 15:56:10 -04:00
else if ( atoms [ i ] = = window - > display - > atom_net_wm_state_demands_attention )
window - > wm_state_demands_attention = TRUE ;
2002-10-01 20:47:29 -04:00
2002-01-03 19:58:39 -05:00
+ + 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 ;
2002-06-21 23:23:02 -04:00
window - > mwm_border_only = FALSE ;
2001-06-23 14:30:27 -04:00
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 ) ;
2005-02-04 22:02:42 -05:00
recalc_window_features ( window ) ;
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 ;
2002-06-21 23:23:02 -04:00
/* some input methods use this */
else if ( hints - > decorations = = MWM_DECOR_BORDER )
window - > mwm_border_only = TRUE ;
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-10-26 03:37:11 -04:00
meta_XFree ( hints ) ;
2001-06-23 14:30:27 -04:00
recalc_window_features ( window ) ;
2001-06-08 02:39:38 -04:00
}
2002-10-24 01:21:51 -04:00
gboolean
2001-08-05 12:04:52 -04:00
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
}
2002-10-21 17:44:35 -04:00
static void
2001-06-09 17:58:30 -04:00
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 ;
ch . res_name = NULL ;
ch . res_class = NULL ;
2002-10-26 12:40:50 -04:00
meta_prop_get_class_hint ( window - > display ,
window - > xwindow ,
XA_WM_CLASS ,
& ch ) ;
2001-06-09 17:58:30 -04:00
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 ,
2002-12-19 15:18:54 -05:00
window - > res_class ? window - > res_class : " none " ,
window - > res_name ? window - > res_name : " none " ) ;
2001-06-09 17:58:30 -04:00
}
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 ;
}
2003-03-17 01:36:39 -05:00
typedef struct
{
Window leader ;
} ClientLeaderData ;
static gboolean
find_client_leader_func ( MetaWindow * ancestor ,
void * data )
{
ClientLeaderData * d ;
d = data ;
d - > leader = read_client_leader ( ancestor - > display ,
ancestor - > xwindow ) ;
/* keep going if no client leader found */
return d - > leader = = None ;
}
2001-06-09 17:58:30 -04:00
static void
update_sm_hints ( MetaWindow * window )
{
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 .
*/
2003-03-17 01:36:39 -05:00
leader = read_client_leader ( window - > display , window - > xwindow ) ;
if ( leader = = None )
2001-06-09 17:58:30 -04:00
{
2003-03-17 01:36:39 -05:00
ClientLeaderData d ;
d . leader = None ;
meta_window_foreach_ancestor ( window , find_client_leader_func ,
& d ) ;
leader = d . leader ;
2001-06-09 17:58:30 -04:00
}
2003-03-17 01:36:39 -05:00
if ( leader ! = None )
2001-06-09 17:58:30 -04:00
{
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
}
else
2002-08-24 17:28:02 -04:00
{
meta_verbose ( " Didn't find a client leader for %s \n " , window - > desc ) ;
if ( ! meta_prefs_get_disable_workarounds ( ) )
{
/* Some broken apps (kdelibs fault?) set SM_CLIENT_ID on the app
* instead of the client leader
*/
char * str ;
str = NULL ;
if ( meta_prop_get_latin1_string ( window - > display , window - > xwindow ,
window - > display - > atom_sm_client_id ,
& str ) )
{
if ( window - > sm_client_id = = NULL ) /* first time through */
meta_warning ( _ ( " Window %s sets SM_CLIENT_ID on itself, instead of on the WM_CLIENT_LEADER window as specified in the ICCCM. \n " ) ,
window - > desc ) ;
window - > sm_client_id = g_strdup ( str ) ;
meta_XFree ( str ) ;
}
}
}
meta_verbose ( " Window %s client leader: 0x%lx SM_CLIENT_ID: '%s' \n " ,
window - > desc , window - > xclient_leader ,
2002-12-19 15:18:54 -05:00
window - > sm_client_id ? window - > sm_client_id : " none " ) ;
2001-06-09 17:58:30 -04:00
}
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
}
2002-10-21 17:44:35 -04:00
static void
2001-06-09 17:58:30 -04:00
update_transient_for ( MetaWindow * window )
{
Window w ;
meta_error_trap_push ( window - > display ) ;
w = None ;
XGetTransientForHint ( window - > display - > xdisplay ,
window - > xwindow ,
& w ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , TRUE ) ;
2001-06-09 17:58:30 -04:00
window - > xtransient_for = w ;
2002-09-27 15:42:59 -04:00
window - > transient_parent_is_root_window =
window - > xtransient_for = = window - > screen - > xroot ;
2001-06-09 17:58:30 -04:00
if ( window - > xtransient_for ! = None )
2002-09-27 15:42:59 -04:00
meta_verbose ( " Window %s transient for 0x%lx (root = %d) \n " , window - > desc ,
window - > xtransient_for , window - > transient_parent_is_root_window ) ;
2001-06-09 17:58:30 -04:00
else
meta_verbose ( " Window %s is not transient \n " , window - > desc ) ;
2002-09-27 15:42:59 -04:00
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
}
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
2003-06-12 03:03:04 -04:00
meta_prop_get_atom_list ( window - > display , window - > xwindow ,
window - > display - > atom_net_wm_window_type ,
& atoms , & n_atoms ) ;
2001-06-21 02:08:35 -04: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 | |
2002-11-30 22:58:04 -05:00
atoms [ i ] = = window - > display - > atom_net_wm_window_type_splash )
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , TRUE ) ;
2002-05-04 18:53:13 -04:00
}
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 ) ;
}
2002-10-21 17:44:35 -04:00
static void
2003-02-27 20:24:44 -05:00
redraw_icon ( MetaWindow * window )
{
/* We could probably be smart and just redraw the icon here,
* instead of the whole frame .
*/
2003-09-30 15:45:56 -04:00
if ( window - > frame & & ( window - > mapped | | window - > frame - > mapped ) )
2003-02-27 20:24:44 -05:00
meta_ui_queue_frame_draw ( window - > screen - > ui , window - > frame - > xwindow ) ;
}
static void
meta_window_update_icon_now ( 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 ;
2003-02-27 20:24:44 -05:00
redraw_icon ( window ) ;
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
}
2003-02-27 20:24:44 -05:00
static guint update_icon_idle = 0 ;
static GSList * update_icon_pending = NULL ;
static gboolean
idle_update_icon ( gpointer data )
2002-05-24 04:16:59 -04:00
{
2003-02-27 20:24:44 -05:00
GSList * tmp ;
GSList * copy ;
meta_topic ( META_DEBUG_GEOMETRY , " Clearing the update_icon queue \n " ) ;
/* 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 update_icons .
*/
copy = g_slist_copy ( update_icon_pending ) ;
g_slist_free ( update_icon_pending ) ;
update_icon_pending = NULL ;
update_icon_idle = 0 ;
destroying_windows_disallowed + = 1 ;
tmp = copy ;
while ( tmp ! = NULL )
{
MetaWindow * window ;
window = tmp - > data ;
meta_window_update_icon_now ( window ) ;
2003-09-30 15:45:56 -04:00
window - > update_icon_queued = FALSE ;
2003-02-27 20:24:44 -05:00
tmp = tmp - > next ;
}
g_slist_free ( copy ) ;
destroying_windows_disallowed - = 1 ;
return FALSE ;
}
void
meta_window_unqueue_update_icon ( MetaWindow * window )
{
if ( ! window - > update_icon_queued )
return ;
meta_topic ( META_DEBUG_GEOMETRY ,
" Removing %s from the update_icon queue \n " ,
window - > desc ) ;
/* Note that window may not actually be in update_icon_pending
* because it may have been in " copy " inside the idle handler
*/
update_icon_pending = g_slist_remove ( update_icon_pending , window ) ;
window - > update_icon_queued = FALSE ;
if ( update_icon_pending = = NULL & &
update_icon_idle ! = 0 )
{
g_source_remove ( update_icon_idle ) ;
update_icon_idle = 0 ;
}
}
void
meta_window_flush_update_icon ( MetaWindow * window )
{
if ( window - > update_icon_queued )
{
meta_window_unqueue_update_icon ( window ) ;
meta_window_update_icon_now ( window ) ;
}
}
void
meta_window_queue_update_icon ( MetaWindow * window )
{
if ( window - > unmanaging )
return ;
if ( window - > update_icon_queued )
return ;
meta_topic ( META_DEBUG_GEOMETRY ,
" Putting %s in the update_icon queue \n " ,
window - > desc ) ;
window - > update_icon_queued = TRUE ;
if ( update_icon_idle = = 0 )
update_icon_idle = g_idle_add ( idle_update_icon , NULL ) ;
update_icon_pending = g_slist_prepend ( update_icon_pending , window ) ;
2002-05-24 04:16:59 -04:00
}
2003-06-25 23:09:38 -04:00
GList *
2002-01-10 01:31:31 -05:00
meta_window_get_workspaces ( MetaWindow * window )
{
if ( window - > on_all_workspaces )
2002-10-16 16:12:24 -04:00
return window - > screen - > workspaces ;
2002-01-10 01:31:31 -05:00
else
Partially resolve the conflicting requirements of windows on multiple
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-22 18:52:52 -05:00
return g_list_prepend ( NULL , window - > workspace ) ;
2002-01-10 01:31:31 -05:00
}
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 ;
}
}
2003-06-25 23:09:38 -04:00
void
meta_window_update_struts ( MetaWindow * window )
2002-01-10 01:31:31 -05:00
{
gulong * struts = NULL ;
int nitems ;
2002-06-08 01:13:55 -04:00
gboolean old_has_struts ;
2003-06-25 23:09:38 -04:00
gboolean new_has_struts ;
MetaRectangle old_left ;
MetaRectangle old_right ;
MetaRectangle old_top ;
MetaRectangle old_bottom ;
MetaRectangle new_left ;
MetaRectangle new_right ;
MetaRectangle new_top ;
MetaRectangle new_bottom ;
2003-06-28 12:12:32 -04:00
2004-08-15 11:26:30 -04:00
/**
* This gap must be kept to at least 75 pixels , since otherwise
* struts on opposite sides of the screen left / right could interfere
* in each other in a way that makes it so there is no feasible
* solution to the constraint satisfaction problem . See
* constraints . c .
*/
# define MIN_EMPTY (76)
2002-06-08 01:13:55 -04:00
2002-01-10 01:31:31 -05:00
meta_verbose ( " Updating struts for %s \n " , window - > desc ) ;
2003-06-25 23:09:38 -04:00
if ( window - > struts )
{
old_has_struts = TRUE ;
old_left = window - > struts - > left ;
old_right = window - > struts - > right ;
old_top = window - > struts - > top ;
old_bottom = window - > struts - > bottom ;
}
else
{
old_has_struts = FALSE ;
}
new_has_struts = FALSE ;
new_left . width = 0 ;
new_left . x = 0 ;
new_left . y = 0 ;
new_left . height = window - > screen - > height ;
new_right . width = 0 ;
new_right . x = window - > screen - > width ;
new_right . y = 0 ;
new_right . height = window - > screen - > height ;
new_top . height = 0 ;
new_top . y = 0 ;
new_top . x = 0 ;
new_top . width = window - > screen - > width ;
new_bottom . height = 0 ;
new_bottom . y = window - > screen - > height ;
new_bottom . x = 0 ;
new_bottom . width = window - > screen - > width ;
2002-01-10 01:31:31 -05:00
if ( meta_prop_get_cardinal_list ( window - > display ,
window - > xwindow ,
2003-06-25 23:09:38 -04:00
window - > display - > atom_net_wm_strut_partial ,
2002-01-10 01:31:31 -05:00
& struts , & nitems ) )
{
2003-06-25 23:09:38 -04:00
if ( nitems ! = 12 )
2002-01-10 01:31:31 -05:00
{
2003-06-25 23:09:38 -04:00
meta_verbose ( " _NET_WM_STRUT_PARTIAL on %s has %d values instead of 12 \n " ,
2002-01-10 01:31:31 -05:00
window - > desc , nitems ) ;
}
2003-06-25 23:09:38 -04:00
else
{
2004-08-15 11:26:30 -04:00
int gap ;
gap = window - > screen - > width - struts [ 0 ] - struts [ 1 ] ;
gap - = MIN_EMPTY ;
2003-06-25 23:09:38 -04:00
new_has_struts = TRUE ;
2004-08-15 11:26:30 -04:00
new_left . width = ( int ) struts [ 0 ] + MIN ( 0 , gap / 2 ) ;
new_right . width = ( int ) struts [ 1 ] + MIN ( 0 , gap / 2 ) ;
2004-08-15 13:32:45 -04:00
gap = window - > screen - > height - struts [ 2 ] - struts [ 3 ] ;
2004-08-15 11:26:30 -04:00
gap - = MIN_EMPTY ;
new_top . height = ( int ) struts [ 2 ] + MIN ( 0 , gap / 2 ) ;
new_bottom . height = ( int ) struts [ 3 ] + MIN ( 0 , gap / 2 ) ;
2003-06-25 23:09:38 -04:00
new_right . x = window - > screen - > width -
new_right . width ;
new_bottom . y = window - > screen - > height -
new_bottom . height ;
new_left . y = struts [ 4 ] ;
2003-09-20 00:58:25 -04:00
new_left . height = struts [ 5 ] - new_left . y + 1 ;
2003-06-25 23:09:38 -04:00
new_right . y = struts [ 6 ] ;
2003-09-20 00:58:25 -04:00
new_right . height = struts [ 7 ] - new_right . y + 1 ;
2003-06-25 23:09:38 -04:00
new_top . x = struts [ 8 ] ;
2003-09-20 00:58:25 -04:00
new_top . width = struts [ 9 ] - new_top . x + 1 ;
2003-06-25 23:09:38 -04:00
new_bottom . x = struts [ 10 ] ;
2003-09-20 00:58:25 -04:00
new_bottom . width = struts [ 11 ] - new_bottom . x + 1 ;
2003-06-25 23:09:38 -04:00
meta_verbose ( " _NET_WM_STRUT_PARTIAL struts %d %d %d %d for window %s \n " ,
new_left . width ,
new_right . width ,
new_top . height ,
new_bottom . height ,
window - > desc ) ;
}
2002-01-10 01:31:31 -05:00
meta_XFree ( struts ) ;
}
else
{
meta_verbose ( " No _NET_WM_STRUT property for %s \n " ,
window - > desc ) ;
}
2003-06-25 23:09:38 -04:00
if ( ! new_has_struts )
{
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 ) ;
}
else
{
2004-08-15 11:26:30 -04:00
int gap ;
gap = window - > screen - > width - struts [ 0 ] - struts [ 1 ] ;
gap - = MIN_EMPTY ;
2003-06-25 23:09:38 -04:00
new_has_struts = TRUE ;
2004-08-15 11:26:30 -04:00
new_left . width = ( int ) struts [ 0 ] + MIN ( 0 , gap / 2 ) ;
new_right . width = ( int ) struts [ 1 ] + MIN ( 0 , gap / 2 ) ;
2004-08-15 13:32:45 -04:00
gap = window - > screen - > height - struts [ 2 ] - struts [ 3 ] ;
2004-08-15 11:26:30 -04:00
gap - = MIN_EMPTY ;
new_top . height = ( int ) struts [ 2 ] + MIN ( 0 , gap / 2 ) ;
new_bottom . height = ( int ) struts [ 3 ] + MIN ( 0 , gap / 2 ) ;
2003-06-25 23:09:38 -04:00
new_left . x = 0 ;
new_right . x = window - > screen - > width -
new_right . width ;
new_top . y = 0 ;
new_bottom . y = window - > screen - > height -
new_bottom . height ;
2004-08-15 11:26:30 -04:00
2003-06-25 23:09:38 -04:00
meta_verbose ( " _NET_WM_STRUT struts %d %d %d %d for window %s \n " ,
new_left . width ,
new_right . width ,
new_top . height ,
new_bottom . height ,
window - > desc ) ;
}
meta_XFree ( struts ) ;
}
else
{
meta_verbose ( " No _NET_WM_STRUT property for %s \n " ,
window - > desc ) ;
}
}
if ( old_has_struts ! = new_has_struts | |
( new_has_struts & & old_has_struts & &
( ! meta_rectangle_equal ( & old_left , & new_left ) | |
! meta_rectangle_equal ( & old_right , & new_right ) | |
! meta_rectangle_equal ( & old_top , & new_top ) | |
! meta_rectangle_equal ( & old_bottom , & new_bottom ) ) ) )
{
if ( new_has_struts )
{
if ( ! window - > struts )
window - > struts = g_new ( MetaStruts , 1 ) ;
window - > struts - > left = new_left ;
window - > struts - > right = new_right ;
window - > struts - > top = new_top ;
window - > struts - > bottom = new_bottom ;
}
else
{
g_free ( window - > struts ) ;
window - > struts = NULL ;
}
2002-06-08 01:13:55 -04:00
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
}
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 ;
2002-11-30 22:58:04 -05:00
else if ( window - > type_atom = = window - > display - > atom_net_wm_window_type_splash )
2002-02-09 01:54:44 -05:00
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 */
2002-09-24 17:22:06 -04:00
meta_window_update_layer ( window ) ;
2003-02-27 17:44:36 -05:00
meta_window_grab_keys ( window ) ;
2001-06-11 01:47:51 -04:00
}
2001-06-09 23:17:15 -04:00
}
2002-10-21 17:44:35 -04:00
static void
2002-08-01 19:52:47 -04:00
set_allowed_actions_hint ( MetaWindow * window )
{
2003-11-16 19:06:58 -05:00
# define MAX_N_ACTIONS 10
2002-08-01 19:52:47 -04:00
unsigned long data [ MAX_N_ACTIONS ] ;
int i ;
i = 0 ;
if ( window - > has_move_func )
{
data [ i ] = window - > display - > atom_net_wm_action_move ;
+ + i ;
}
if ( window - > has_resize_func )
{
data [ i ] = window - > display - > atom_net_wm_action_resize ;
2003-11-17 11:46:01 -05:00
+ + i ;
2003-11-16 19:06:58 -05:00
data [ i ] = window - > display - > atom_net_wm_action_fullscreen ;
+ + i ;
}
if ( window - > has_minimize_func )
{
data [ i ] = window - > display - > atom_net_wm_action_minimize ;
2002-08-01 19:52:47 -04:00
+ + i ;
}
if ( window - > has_shade_func )
{
data [ i ] = window - > display - > atom_net_wm_action_shade ;
+ + i ;
}
2003-11-16 19:06:58 -05:00
/* sticky according to EWMH is different from metacity's sticky;
* metacity doesn ' t support EWMH sticky
*/
if ( window - > has_maximize_func )
2002-08-01 19:52:47 -04:00
{
2003-11-16 19:06:58 -05:00
data [ i ] = window - > display - > atom_net_wm_action_maximize_horz ;
+ + i ;
data [ i ] = window - > display - > atom_net_wm_action_maximize_vert ;
2002-08-01 19:52:47 -04:00
+ + i ;
}
/* We always allow this */
data [ i ] = window - > display - > atom_net_wm_action_change_desktop ;
+ + i ;
2003-11-16 19:06:58 -05:00
if ( window - > has_close_func )
{
data [ i ] = window - > display - > atom_net_wm_action_close ;
+ + i ;
}
2002-08-01 19:52:47 -04:00
g_assert ( i < = MAX_N_ACTIONS ) ;
meta_verbose ( " Setting _NET_WM_ALLOWED_ACTIONS with %d atoms \n " , i ) ;
meta_error_trap_push ( window - > display ) ;
XChangeProperty ( window - > display - > xdisplay , window - > xwindow ,
window - > display - > atom_net_wm_allowed_actions ,
XA_ATOM ,
32 , PropModeReplace , ( guchar * ) data , i ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2002-08-01 19:52:47 -04:00
# undef MAX_N_ACTIONS
}
2003-02-27 20:24:44 -05:00
void
meta_window_recalc_features ( MetaWindow * window )
{
recalc_window_features ( window ) ;
}
2001-06-23 14:30:27 -04:00
static void
recalc_window_features ( MetaWindow * window )
{
2002-08-01 19:52:47 -04:00
gboolean old_has_close_func ;
gboolean old_has_minimize_func ;
gboolean old_has_move_func ;
gboolean old_has_resize_func ;
gboolean old_has_shade_func ;
gboolean old_always_sticky ;
old_has_close_func = window - > has_close_func ;
old_has_minimize_func = window - > has_minimize_func ;
old_has_move_func = window - > has_move_func ;
old_has_resize_func = window - > has_resize_func ;
old_has_shade_func = window - > has_shade_func ;
old_always_sticky = window - > always_sticky ;
2001-06-23 14:30:27 -04:00
/* Use MWM hints initially */
window - > decorated = window - > mwm_decorated ;
2002-06-21 23:23:02 -04:00
window - > border_only = window - > mwm_border_only ;
2001-06-23 14:30:27 -04:00
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 ;
2002-08-24 16:54:23 -04:00
window - > has_resize_func = TRUE ;
/* 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 ;
else if ( ! window - > mwm_has_resize_func )
{
/* We ignore mwm_has_resize_func because WM_NORMAL_HINTS is the
* authoritative source for that info . Some apps such as mplayer or
* xine disable resize via MWM but not WM_NORMAL_HINTS , but that
* leads to e . g . us not fullscreening their windows . Apps that set
* MWM but not WM_NORMAL_HINTS are basically broken . We complain
* about these apps but make them work .
*/
meta_warning ( _ ( " Window %s sets an MWM hint indicating it isn't resizable, but sets min size %d x %d and max size %d x %d; this doesn't make much sense. \n " ) ,
window - > desc ,
window - > size_hints . min_width ,
window - > size_hints . min_height ,
window - > size_hints . max_width ,
window - > size_hints . max_height ) ;
}
2001-06-23 14:30:27 -04:00
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
}
2001-08-03 00:20:27 -04:00
if ( ! window - > has_resize_func )
2002-08-24 16:54:23 -04:00
{
2002-02-23 17:58:02 -05:00
window - > has_maximize_func = FALSE ;
2002-08-24 16:54:23 -04:00
/* don't allow fullscreen if we can't resize, unless the size
* is entire screen size ( kind of broken , because we
* actually fullscreen to xinerama head size not screen size )
*/
2002-08-15 01:14:49 -04:00
if ( window - > size_hints . min_width = = window - > screen - > width & &
window - > size_hints . min_height = = window - > screen - > height & &
! window - > decorated )
; /* leave fullscreen available */
else
window - > has_fullscreen_func = FALSE ;
2002-09-22 21:43:20 -04:00
}
2002-08-24 16:54:23 -04:00
2002-09-22 21:43:20 -04:00
/* We leave fullscreen windows decorated, just push the frame outside
* the screen . This avoids flickering to unparent them .
*
* Note that setting has_resize_func = FALSE here must come after the
* above code that may disable fullscreen , because if the window
* is not resizable purely due to fullscreen , we don ' t want to
* disable fullscreen mode .
*/
if ( window - > fullscreen )
{
window - > has_shade_func = FALSE ;
window - > has_move_func = FALSE ;
window - > has_resize_func = FALSE ;
window - > has_maximize_func = FALSE ;
2002-02-23 17:58:02 -05:00
}
2001-08-03 00:20:27 -04:00
2002-09-22 21:43:20 -04:00
meta_topic ( META_DEBUG_WINDOW_OPS ,
" Window %s fullscreen = %d not resizable, maximizable = %d fullscreenable = %d min size %dx%d max size %dx%d \n " ,
window - > desc ,
window - > fullscreen ,
window - > has_maximize_func , window - > has_fullscreen_func ,
window - > size_hints . min_width ,
window - > size_hints . min_height ,
window - > size_hints . max_width ,
window - > size_hints . max_height ) ;
2001-08-03 00:20:27 -04:00
/* no shading if not decorated */
2002-07-24 22:45:38 -04:00
if ( ! window - > decorated | | window - > border_only )
2001-08-03 00:20:27 -04:00
window - > has_shade_func = FALSE ;
2002-07-06 15:05:37 -04:00
window - > skip_taskbar = FALSE ;
window - > skip_pager = FALSE ;
if ( window - > wm_state_skip_taskbar )
window - > skip_taskbar = TRUE ;
2001-08-03 00:20:27 -04:00
2002-07-06 15:05:37 -04:00
if ( window - > wm_state_skip_pager )
window - > skip_pager = TRUE ;
switch ( window - > type )
{
/* Force skip taskbar/pager on these window types */
case META_WINDOW_DESKTOP :
case META_WINDOW_DOCK :
case META_WINDOW_TOOLBAR :
case META_WINDOW_MENU :
case META_WINDOW_UTILITY :
case META_WINDOW_SPLASHSCREEN :
window - > skip_taskbar = TRUE ;
window - > skip_pager = TRUE ;
break ;
case META_WINDOW_DIALOG :
case META_WINDOW_MODAL_DIALOG :
2003-01-09 18:28:01 -05:00
/* only skip taskbar if we have a real transient parent */
if ( window - > xtransient_for ! = None & &
window - > xtransient_for ! = window - > screen - > xroot )
window - > skip_taskbar = TRUE ;
2002-07-06 15:05:37 -04:00
break ;
case META_WINDOW_NORMAL :
break ;
}
2002-08-01 19:52:47 -04:00
2002-09-22 21:43:20 -04:00
meta_topic ( META_DEBUG_WINDOW_OPS ,
" Window %s decorated = %d border_only = %d has_close = %d has_minimize = %d has_maximize = %d has_move = %d has_shade = %d skip_taskbar = %d skip_pager = %d \n " ,
window - > desc ,
window - > decorated ,
window - > border_only ,
window - > has_close_func ,
window - > has_minimize_func ,
window - > has_maximize_func ,
window - > has_move_func ,
window - > has_shade_func ,
window - > skip_taskbar ,
window - > skip_pager ) ;
2002-08-01 19:52:47 -04:00
/* FIXME:
* Lame workaround for recalc_window_features
* being used overzealously . The fix is to
* only recalc_window_features when something
* has actually changed .
*/
if ( old_has_close_func ! = window - > has_close_func | |
old_has_minimize_func ! = window - > has_minimize_func | |
old_has_move_func ! = window - > has_move_func | |
old_has_resize_func ! = window - > has_resize_func | |
old_has_shade_func ! = window - > has_shade_func | |
old_always_sticky ! = window - > always_sticky )
set_allowed_actions_hint ( window ) ;
2002-07-06 15:05:37 -04:00
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-23 01:49:35 -04:00
static void
menu_callback ( MetaWindowMenu * menu ,
Display * xdisplay ,
Window client_xwindow ,
2004-06-21 12:47:27 -04:00
Time timestamp ,
2001-06-23 01:49:35 -04:00
MetaMenuOp op ,
int workspace_index ,
gpointer data )
{
MetaDisplay * display ;
MetaWindow * window ;
2003-12-21 01:31:40 -05:00
MetaWorkspace * workspace ;
2001-06-23 01:49:35 -04:00
display = meta_display_for_x_display ( xdisplay ) ;
window = meta_display_lookup_x_window ( display , client_xwindow ) ;
2003-12-21 01:31:40 -05:00
workspace = NULL ;
2001-06-23 01:49:35 -04:00
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 :
2004-06-21 12:47:27 -04:00
meta_window_delete ( window , timestamp ) ;
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 ;
2003-12-21 01:31:40 -05:00
case META_MENU_OP_MOVE_LEFT :
workspace = meta_workspace_get_neighbor ( window - > screen - > active_workspace ,
META_MOTION_LEFT ) ;
break ;
2001-06-23 01:49:35 -04:00
2003-12-21 01:31:40 -05:00
case META_MENU_OP_MOVE_RIGHT :
workspace = meta_workspace_get_neighbor ( window - > screen - > active_workspace ,
META_MOTION_RIGHT ) ;
break ;
2001-06-23 01:49:35 -04:00
2003-12-21 01:31:40 -05:00
case META_MENU_OP_MOVE_UP :
workspace = meta_workspace_get_neighbor ( window - > screen - > active_workspace ,
META_MOTION_UP ) ;
break ;
case META_MENU_OP_MOVE_DOWN :
workspace = meta_workspace_get_neighbor ( window - > screen - > active_workspace ,
META_MOTION_DOWN ) ;
break ;
case META_MENU_OP_WORKSPACES :
workspace = meta_screen_get_workspace_by_index ( window - > screen ,
workspace_index ) ;
2001-06-23 01:49:35 -04:00
break ;
case META_MENU_OP_STICK :
meta_window_stick ( window ) ;
break ;
case META_MENU_OP_UNSTICK :
meta_window_unstick ( window ) ;
break ;
2003-12-21 01:31:40 -05:00
case META_MENU_OP_ABOVE :
meta_window_make_above ( window ) ;
break ;
case META_MENU_OP_UNABOVE :
meta_window_unmake_above ( window ) ;
break ;
2001-07-11 02:22:00 -04:00
case META_MENU_OP_MOVE :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
meta_window_begin_grab_op ( window ,
META_GRAB_OP_KEYBOARD_MOVING ,
meta_display_get_current_time ( window - > display ) ) ;
2001-07-11 02:22:00 -04:00
break ;
case META_MENU_OP_RESIZE :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
meta_window_begin_grab_op ( window ,
META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN ,
meta_display_get_current_time ( window - > display ) ) ;
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 ;
}
2003-12-21 01:31:40 -05:00
if ( workspace )
{
meta_window_change_workspace ( window ,
workspace ) ;
#if 0
meta_workspace_activate ( workspace ) ;
meta_window_raise ( window ) ;
# endif
}
2001-06-23 01:49:35 -04:00
}
else
{
meta_verbose ( " Menu callback on nonexistent window \n " ) ;
}
2002-10-28 00:35:30 -05:00
if ( display - > window_menu = = menu )
{
display - > window_menu = NULL ;
display - > window_with_menu = NULL ;
}
2001-06-23 01:49:35 -04:00
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 ;
2003-12-21 01:31:40 -05:00
MetaWorkspaceLayout layout ;
2004-08-07 13:50:40 -04:00
int n_workspaces ;
2001-06-23 01:49:35 -04:00
2003-03-16 20:19:07 -05:00
if ( window - > display - > window_menu )
{
meta_ui_window_menu_free ( window - > display - > window_menu ) ;
window - > display - > window_menu = NULL ;
window - > display - > window_with_menu = NULL ;
}
2001-06-23 01:49:35 -04:00
ops = 0 ;
insensitive = 0 ;
2004-08-07 13:50:40 -04:00
ops | = ( META_MENU_OP_DELETE | META_MENU_OP_MINIMIZE | META_MENU_OP_MOVE | META_MENU_OP_RESIZE ) ;
n_workspaces = meta_screen_get_n_workspaces ( window - > screen ) ;
if ( n_workspaces > 1 )
ops | = META_MENU_OP_WORKSPACES ;
2003-12-21 01:31:40 -05:00
meta_screen_calc_workspace_layout ( window - > screen ,
2004-08-07 13:50:40 -04:00
n_workspaces ,
2003-12-21 01:31:40 -05:00
meta_workspace_index ( window - > screen - > active_workspace ) ,
& layout ) ;
2004-01-17 13:57:26 -05:00
if ( ! window - > on_all_workspaces )
{
2004-08-07 13:50:40 -04:00
2004-01-17 13:57:26 -05:00
if ( layout . current_col > 0 )
ops | = META_MENU_OP_MOVE_LEFT ;
2004-08-07 13:50:40 -04:00
if ( ( layout . current_col < layout . cols - 1 ) & &
( layout . current_row * layout . cols + ( layout . current_col + 1 ) < n_workspaces ) )
2004-01-17 13:57:26 -05:00
ops | = META_MENU_OP_MOVE_RIGHT ;
if ( layout . current_row > 0 )
ops | = META_MENU_OP_MOVE_UP ;
2004-08-07 13:50:40 -04:00
if ( ( layout . current_row < layout . rows - 1 ) & &
( ( layout . current_row + 1 ) * layout . cols + layout . current_col < n_workspaces ) )
2004-01-17 13:57:26 -05:00
ops | = META_MENU_OP_MOVE_DOWN ;
}
2001-06-23 01:49:35 -04:00
if ( window - > maximized )
ops | = META_MENU_OP_UNMAXIMIZE ;
else
ops | = META_MENU_OP_MAXIMIZE ;
2003-12-21 01:31:40 -05:00
#if 0
2001-06-23 01:49:35 -04:00
if ( window - > shaded )
ops | = META_MENU_OP_UNSHADE ;
else
ops | = META_MENU_OP_SHADE ;
2003-12-21 01:31:40 -05:00
# endif
2001-06-23 01:49:35 -04:00
if ( window - > on_all_workspaces )
ops | = META_MENU_OP_UNSTICK ;
else
ops | = META_MENU_OP_STICK ;
2004-01-17 13:57:26 -05:00
2003-12-21 01:31:40 -05:00
if ( window - > wm_state_above )
ops | = META_MENU_OP_UNABOVE ;
else
ops | = META_MENU_OP_ABOVE ;
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
2002-07-02 22:32:40 -04:00
if ( ! META_WINDOW_ALLOWS_MOVE ( window ) )
2001-07-11 02:22:00 -04:00
insensitive | = META_MENU_OP_MOVE ;
2002-07-02 22:32:40 -04:00
if ( ! META_WINDOW_ALLOWS_RESIZE ( window ) )
2001-07-11 02:22:00 -04:00
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 ;
2004-01-17 13:57:26 -05:00
if ( ( window - > type = = META_WINDOW_DESKTOP ) | |
( window - > type = = META_WINDOW_DOCK ) | |
( window - > type = = META_WINDOW_SPLASHSCREEN ) )
insensitive | = META_MENU_OP_ABOVE | META_MENU_OP_UNABOVE ;
2004-12-24 14:40:09 -05:00
/* If all operations are disabled, just quit without showing the menu.
* This is the case , for example , with META_WINDOW_DESKTOP windows .
*/
if ( ( ops & ~ insensitive ) = = 0 )
return ;
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
2002-10-28 00:35:30 -05:00
window - > display - > window_menu = menu ;
window - > display - > window_with_menu = window ;
2001-06-23 01:49:35 -04:00
meta_verbose ( " Popping up window menu for %s \n " , window - > desc ) ;
2002-10-28 00:35:30 -05:00
2001-06-23 01:49:35 -04:00
meta_ui_window_menu_popup ( menu , root_x , root_y , button , timestamp ) ;
}
2001-06-24 04:09:10 -04:00
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
static double
timeval_to_ms ( const GTimeVal * timeval )
2002-10-03 17:49:13 -04:00
{
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
return ( timeval - > tv_sec * G_USEC_PER_SEC + timeval - > tv_usec ) / 1000.0 ;
}
static double
time_diff ( const GTimeVal * first ,
const GTimeVal * second )
{
double first_ms = timeval_to_ms ( first ) ;
double second_ms = timeval_to_ms ( second ) ;
return first_ms - second_ms ;
2002-10-03 17:49:13 -04:00
}
2002-08-10 01:27:17 -04:00
static gboolean
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
check_moveresize_frequency ( MetaWindow * window ,
gdouble * remaining )
2002-08-10 01:27:17 -04:00
{
GTimeVal current_time ;
g_get_current_time ( & current_time ) ;
2002-12-09 22:23:04 -05:00
# ifdef HAVE_XSYNC
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
if ( ! window - > disable_sync & &
window - > display - > grab_sync_request_alarm ! = None )
{
if ( window - > sync_request_time . tv_sec ! = 0 | |
window - > sync_request_time . tv_usec ! = 0 )
{
double elapsed =
time_diff ( & current_time , & window - > sync_request_time ) ;
if ( elapsed < 1000.0 )
{
/* We want to be sure that the timeout happens at
* a time where elapsed will definitely be
* greater than 1000 , so we can disable sync
*/
if ( remaining )
* remaining = 1000.0 - elapsed + 100 ;
return FALSE ;
}
else
{
/* We have now waited for more than a second for the
* application to respond to the sync request
*/
window - > disable_sync = TRUE ;
return TRUE ;
}
}
else
{
/* No outstanding sync requests. Go ahead and resize
*/
return TRUE ;
}
}
2002-12-09 22:23:04 -05:00
else
# endif /* HAVE_XSYNC */
2002-12-08 21:53:16 -05:00
{
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
const double max_resizes_per_second = 25.0 ;
const double ms_between_resizes = 1000.0 / max_resizes_per_second ;
double elapsed ;
elapsed = time_diff ( & current_time , & window - > display - > grab_last_moveresize_time ) ;
if ( elapsed > = 0.0 & & elapsed < ms_between_resizes )
{
meta_topic ( META_DEBUG_RESIZING ,
" Delaying move/resize as only %g of %g ms elapsed \n " ,
elapsed , ms_between_resizes ) ;
if ( remaining )
* remaining = ( ms_between_resizes - elapsed ) ;
return FALSE ;
}
2002-12-09 22:23:04 -05:00
meta_topic ( META_DEBUG_RESIZING ,
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
" Checked moveresize freq, allowing move/resize now (%g of %g seconds elapsed) \n " ,
elapsed / 1000.0 , 1.0 / max_resizes_per_second ) ;
return TRUE ;
2002-12-08 21:53:16 -05:00
}
2002-08-10 01:27:17 -04:00
}
static void
2001-07-25 22:55:35 -04:00
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 ;
2003-06-12 01:55:06 -04:00
int shake_threshold ;
2002-12-09 22:23:04 -05:00
window - > display - > grab_latest_motion_x = x ;
window - > display - > grab_latest_motion_y = y ;
2001-07-25 22:55:35 -04:00
2003-10-12 02:25:38 -04:00
dx = x - window - > display - > grab_anchor_root_x ;
dy = y - window - > display - > grab_anchor_root_y ;
2003-06-12 01:55:06 -04:00
2003-10-12 02:25:38 -04:00
new_x = window - > display - > grab_anchor_window_pos . x + dx ;
new_y = window - > display - > grab_anchor_window_pos . y + dy ;
2003-06-12 01:55:06 -04:00
2003-10-12 02:25:38 -04:00
meta_verbose ( " x,y = %d,%d anchor ptr %d,%d anchor pos %d,%d dx,dy %d,%d \n " ,
x , y ,
window - > display - > grab_anchor_root_x ,
window - > display - > grab_anchor_root_y ,
window - > display - > grab_anchor_window_pos . x ,
window - > display - > grab_anchor_window_pos . y ,
dx , dy ) ;
2003-06-12 01:55:06 -04:00
/* shake loose (unmaximize) maximized window if dragged beyond the threshold
* in the Y direction . You can ' t pull a window loose via X motion .
*/
# define DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR 6
shake_threshold = meta_ui_get_drag_threshold ( window - > screen - > ui ) *
DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR ;
if ( window - > maximized & & ABS ( dy ) > = shake_threshold )
{
2003-07-27 22:09:20 -04:00
double prop ;
2003-06-12 01:55:06 -04:00
/* Shake loose */
window - > shaken_loose = TRUE ;
2004-02-16 14:01:25 -05:00
2003-07-27 22:09:20 -04:00
/* move the unmaximized window to the cursor */
prop =
2004-02-16 14:01:25 -05:00
( ( double ) ( x - window - > display - > grab_initial_window_pos . x ) ) /
( ( double ) window - > display - > grab_initial_window_pos . width ) ;
2003-06-12 01:55:06 -04:00
2003-07-27 22:09:20 -04:00
window - > display - > grab_initial_window_pos . x =
2004-02-16 14:01:25 -05:00
x - window - > saved_rect . width * prop ;
2003-07-27 22:09:20 -04:00
window - > display - > grab_initial_window_pos . y = y ;
if ( window - > frame )
2004-02-16 14:01:25 -05:00
{
window - > display - > grab_initial_window_pos . y + = window - > frame - > child_y / 2 ;
}
window - > saved_rect . x = window - > display - > grab_initial_window_pos . x ;
window - > saved_rect . y = window - > display - > grab_initial_window_pos . y ;
window - > display - > grab_anchor_root_x = x ;
window - > display - > grab_anchor_root_y = y ;
2003-07-27 22:09:20 -04:00
2003-06-12 01:55:06 -04:00
meta_window_unmaximize ( window ) ;
return ;
}
/* remaximize window on an other xinerama monitor if window has
* been shaken loose or it is still maximized ( then move straight )
*/
else if ( window - > shaken_loose | | window - > maximized )
{
const MetaXineramaScreenInfo * wxinerama ;
2003-07-27 22:09:20 -04:00
MetaRectangle work_area ;
2003-06-12 01:55:06 -04:00
int monitor ;
wxinerama = meta_screen_get_xinerama_for_window ( window - > screen , window ) ;
for ( monitor = 0 ; monitor < window - > screen - > n_xinerama_infos ; monitor + + )
{
2004-02-16 14:01:25 -05:00
meta_window_get_work_area_for_xinerama ( window , monitor , & work_area ) ;
2003-07-27 22:09:20 -04:00
/* check if cursor is near the top of a xinerama work area */
if ( x > = work_area . x & &
x < ( work_area . x + work_area . width ) & &
2004-02-16 14:01:25 -05:00
y > = work_area . y & &
y < ( work_area . y + shake_threshold ) )
2003-06-12 01:55:06 -04:00
{
/* move the saved rect if window will become maximized on an
* other monitor so user isn ' t surprised on a later unmaximize
*/
if ( wxinerama - > number ! = monitor )
{
2003-07-27 22:09:20 -04:00
window - > saved_rect . x = work_area . x ;
2004-02-16 14:01:25 -05:00
window - > saved_rect . y = work_area . y ;
2003-06-12 01:55:06 -04:00
if ( window - > frame )
{
window - > saved_rect . x + = window - > frame - > child_x ;
window - > saved_rect . y + = window - > frame - > child_y ;
}
meta_window_unmaximize ( window ) ;
}
2001-07-25 22:55:35 -04:00
2004-02-16 14:01:25 -05:00
window - > display - > grab_initial_window_pos = work_area ;
window - > display - > grab_anchor_root_x = x ;
window - > display - > grab_anchor_root_y = y ;
window - > shaken_loose = FALSE ;
meta_window_maximize ( window ) ;
2003-06-12 01:55:06 -04:00
2004-02-16 14:01:25 -05:00
return ;
2003-06-12 01:55:06 -04:00
}
}
}
/* don't allow a maximized window to move */
if ( window - > maximized )
return ;
2001-07-25 23:58:24 -04:00
2003-10-12 02:25:38 -04:00
if ( window - > display - > grab_wireframe_active )
2001-07-25 23:58:24 -04:00
{
2003-10-12 02:25:38 -04:00
/* FIXME Horribly broken, does not honor position
* constraints
*/
MetaRectangle new_xor ;
2004-08-18 22:05:24 -04:00
window - > display - > grab_wireframe_rect . x = new_x ;
window - > display - > grab_wireframe_rect . y = new_y ;
meta_window_get_xor_rect ( window ,
& window - > display - > grab_wireframe_rect ,
& new_xor ) ;
2002-08-10 01:27:17 -04:00
2003-10-12 02:25:38 -04:00
meta_effects_update_wireframe ( window - > screen ,
2004-08-18 22:05:24 -04:00
& window - > display - > grab_wireframe_last_xor_rect ,
2003-10-12 02:25:38 -04:00
& new_xor ) ;
2004-08-18 22:05:24 -04:00
window - > display - > grab_wireframe_last_xor_rect = new_xor ;
2003-10-12 02:25:38 -04:00
}
else
{
/* FIXME, edge snapping broken in wireframe mode */
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 ) ;
}
meta_window_move ( window , TRUE , new_x , new_y ) ;
}
2001-07-25 22:55:35 -04:00
}
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
static void update_resize ( MetaWindow * window ,
int x ,
int y ,
gboolean force ) ;
static gboolean
update_resize_timeout ( gpointer data )
{
MetaWindow * window = data ;
update_resize ( window ,
window - > display - > grab_latest_motion_x ,
window - > display - > grab_latest_motion_y ,
TRUE ) ;
return FALSE ;
}
2001-07-25 22:55:35 -04:00
static void
update_resize ( MetaWindow * window ,
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
int x , int y ,
gboolean force )
2001-07-25 22:55:35 -04:00
{
int dx , dy ;
int new_w , new_h ;
int gravity ;
2002-12-09 22:23:04 -05:00
MetaRectangle old ;
2003-10-12 02:25:38 -04:00
int new_x , new_y ;
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
double remaining ;
2002-12-09 22:23:04 -05:00
window - > display - > grab_latest_motion_x = x ;
window - > display - > grab_latest_motion_y = y ;
2001-07-25 22:55:35 -04:00
2003-10-12 02:25:38 -04:00
dx = x - window - > display - > grab_anchor_root_x ;
dy = y - window - > display - > grab_anchor_root_y ;
2001-07-25 22:55:35 -04:00
2003-10-12 02:25:38 -04:00
new_w = window - > display - > grab_anchor_window_pos . width ;
new_h = window - > display - > grab_anchor_window_pos . height ;
2001-07-25 22:55:35 -04:00
2003-10-12 02:25:38 -04:00
/* FIXME this is only used in wireframe mode */
new_x = window - > display - > grab_anchor_window_pos . x ;
new_y = window - > display - > grab_anchor_window_pos . y ;
2001-07-25 22:55:35 -04:00
switch ( window - > display - > grab_op )
{
case META_GRAB_OP_RESIZING_SE :
case META_GRAB_OP_RESIZING_NE :
case META_GRAB_OP_RESIZING_E :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
case META_GRAB_OP_KEYBOARD_RESIZING_SE :
case META_GRAB_OP_KEYBOARD_RESIZING_NE :
case META_GRAB_OP_KEYBOARD_RESIZING_E :
2001-07-25 22:55:35 -04:00
new_w + = dx ;
break ;
case META_GRAB_OP_RESIZING_NW :
case META_GRAB_OP_RESIZING_SW :
case META_GRAB_OP_RESIZING_W :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
case META_GRAB_OP_KEYBOARD_RESIZING_NW :
case META_GRAB_OP_KEYBOARD_RESIZING_SW :
case META_GRAB_OP_KEYBOARD_RESIZING_W :
2001-07-25 22:55:35 -04:00
new_w - = dx ;
2003-10-12 02:25:38 -04:00
new_x + = dx ;
2001-07-25 22:55:35 -04:00
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 :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
case META_GRAB_OP_KEYBOARD_RESIZING_SE :
case META_GRAB_OP_KEYBOARD_RESIZING_S :
case META_GRAB_OP_KEYBOARD_RESIZING_SW :
2001-07-25 22:55:35 -04:00
new_h + = dy ;
break ;
case META_GRAB_OP_RESIZING_N :
case META_GRAB_OP_RESIZING_NE :
case META_GRAB_OP_RESIZING_NW :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
case META_GRAB_OP_KEYBOARD_RESIZING_N :
case META_GRAB_OP_KEYBOARD_RESIZING_NE :
case META_GRAB_OP_KEYBOARD_RESIZING_NW :
2001-07-25 22:55:35 -04:00
new_h - = dy ;
2003-10-12 02:25:38 -04:00
new_y + = dy ;
2001-07-25 22:55:35 -04:00
break ;
default :
break ;
}
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
if ( ! check_moveresize_frequency ( window , & remaining ) & & ! force )
{
/* we are ignoring an event here, so we schedule a
* compensation event when we would otherwise not ignore
* an event . Otherwise we can become stuck if the user never
* generates another event .
*/
if ( ! window - > display - > grab_resize_timeout_id )
{
window - > display - > grab_resize_timeout_id =
g_timeout_add ( ( int ) remaining , update_resize_timeout , window ) ;
}
return ;
}
/* Remove any scheduled compensation events */
if ( window - > display - > grab_resize_timeout_id )
{
g_source_remove ( window - > display - > grab_resize_timeout_id ) ;
window - > display - > grab_resize_timeout_id = 0 ;
}
2003-03-28 08:11:24 -05:00
2002-12-09 22:23:04 -05:00
old = window - > rect ;
2003-10-12 02:25:38 -04:00
2001-07-25 22:55:35 -04:00
/* 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 ) ;
2002-12-09 22:23:04 -05:00
2003-10-12 02:25:38 -04:00
if ( window - > display - > grab_wireframe_active )
{
/* FIXME This is crap. For example, the wireframe isn't
* constrained in the way that a real resize would be . An
* obvious elegant solution is to unmap the window during
* wireframe , but still resize it ; however , that probably
* confuses broken clients that have problems with opaque
* resize , they probably don ' t track their visibility .
*/
MetaRectangle new_xor ;
if ( ( new_x + new_w < = new_x ) | | ( new_y + new_h < = new_y ) )
return ;
2004-08-18 22:05:24 -04:00
window - > display - > grab_wireframe_rect . x = new_x ;
window - > display - > grab_wireframe_rect . y = new_y ;
window - > display - > grab_wireframe_rect . width = new_w ;
window - > display - > grab_wireframe_rect . height = new_h ;
2003-10-12 02:25:38 -04:00
2004-08-18 22:05:24 -04:00
meta_window_get_xor_rect ( window , & window - > display - > grab_wireframe_rect ,
& new_xor ) ;
2003-10-12 02:25:38 -04:00
meta_effects_update_wireframe ( window - > screen ,
2004-08-18 22:05:24 -04:00
& window - > display - > grab_wireframe_last_xor_rect ,
2003-10-12 02:25:38 -04:00
& new_xor ) ;
2004-08-18 22:05:24 -04:00
window - > display - > grab_wireframe_last_xor_rect = new_xor ;
2003-10-12 02:25:38 -04:00
/* do this after drawing the wires, so we don't draw over it */
meta_window_refresh_resize_popup ( window ) ;
}
else
{
meta_window_resize_with_gravity ( window , TRUE , new_w , new_h , gravity ) ;
}
2002-12-09 22:23:04 -05:00
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
/* Store the latest resize time, if we actually resized. */
if ( window - > rect . width ! = old . width & &
window - > rect . height ! = old . height )
{
g_get_current_time ( & window - > display - > grab_last_moveresize_time ) ;
}
2001-07-25 22:55:35 -04:00
}
2003-01-11 14:32:12 -05:00
typedef struct
{
2003-01-21 23:54:04 -05:00
const XEvent * current_event ;
2003-01-11 14:32:12 -05:00
int count ;
2003-01-21 23:54:04 -05:00
Time last_time ;
} EventScannerData ;
2003-01-11 14:32:12 -05:00
static Bool
2003-01-21 23:54:04 -05:00
find_last_time_predicate ( Display * display ,
2003-01-11 14:32:12 -05:00
XEvent * xevent ,
XPointer arg )
{
2003-01-21 23:54:04 -05:00
EventScannerData * esd = ( void * ) arg ;
if ( esd - > current_event - > type = = xevent - > type & &
esd - > current_event - > xany . window = = xevent - > xany . window )
2003-01-11 14:32:12 -05:00
{
2003-01-21 23:54:04 -05:00
esd - > count + = 1 ;
esd - > last_time = xevent - > xmotion . time ;
2003-01-11 14:32:12 -05:00
}
2003-01-21 23:54:04 -05:00
return False ;
2003-01-11 14:32:12 -05:00
}
2003-01-21 23:54:04 -05:00
static gboolean
check_use_this_motion_notify ( MetaWindow * window ,
XEvent * event )
2003-01-11 14:32:12 -05:00
{
2003-01-21 23:54:04 -05:00
EventScannerData esd ;
XEvent useless ;
/* This code is copied from Owen's GDK code. */
2003-01-11 14:32:12 -05:00
2003-01-21 23:54:04 -05:00
if ( window - > display - > grab_motion_notify_time ! = 0 )
{
/* == is really the right test, but I'm all for paranoia */
if ( window - > display - > grab_motion_notify_time < =
event - > xmotion . time )
{
meta_topic ( META_DEBUG_RESIZING ,
" Arrived at event with time %lu (waiting for %lu), using it \n " ,
( unsigned long ) event - > xmotion . time ,
( unsigned long ) window - > display - > grab_motion_notify_time ) ;
window - > display - > grab_motion_notify_time = 0 ;
return TRUE ;
}
else
return FALSE ; /* haven't reached the saved timestamp yet */
}
esd . current_event = event ;
esd . count = 0 ;
esd . last_time = 0 ;
2003-01-11 14:32:12 -05:00
2003-01-21 23:54:04 -05:00
/* "useless" isn't filled in because the predicate never returns True */
XCheckIfEvent ( window - > display - > xdisplay ,
& useless ,
find_last_time_predicate ,
( XPointer ) & esd ) ;
2003-01-11 14:32:12 -05:00
2003-01-21 23:54:04 -05:00
if ( esd . count > 0 )
meta_topic ( META_DEBUG_RESIZING ,
" Will skip %d motion events and use the event with time %lu \n " ,
esd . count , ( unsigned long ) esd . last_time ) ;
if ( esd . last_time = = 0 )
return TRUE ;
else
2003-01-11 14:32:12 -05:00
{
2003-01-21 23:54:04 -05:00
/* Save this timestamp, and ignore all motion notify
* until we get to the one with this stamp .
*/
window - > display - > grab_motion_notify_time = esd . last_time ;
return FALSE ;
2003-01-11 14:32:12 -05:00
}
}
2001-07-25 22:55:35 -04:00
void
meta_window_handle_mouse_grab_op_event ( MetaWindow * window ,
XEvent * event )
{
2002-12-09 22:23:04 -05:00
# ifdef HAVE_XSYNC
if ( event - > type = = ( window - > display - > xsync_event_base + XSyncAlarmNotify ) )
2001-07-25 22:55:35 -04:00
{
2002-12-09 22:23:04 -05:00
meta_topic ( META_DEBUG_RESIZING ,
" Alarm event received last motion x = %d y = %d \n " ,
window - > display - > grab_latest_motion_x ,
window - > display - > grab_latest_motion_y ) ;
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
/* If sync was previously disabled, turn it back on and hope
* the application has come to its senses ( maybe it was just
* busy with a pagefault or a long computation ) .
*/
window - > disable_sync = FALSE ;
window - > sync_request_time . tv_sec = 0 ;
window - > sync_request_time . tv_usec = 0 ;
2002-12-09 22:23:04 -05:00
/* This means we are ready for another configure. */
2001-07-25 22:55:35 -04:00
switch ( window - > display - > grab_op )
{
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 :
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
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 :
2002-12-09 22:23:04 -05:00
/* no pointer round trip here, to keep in sync */
update_resize ( window ,
window - > display - > grab_latest_motion_x ,
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
window - > display - > grab_latest_motion_y ,
TRUE ) ;
2002-12-09 22:23:04 -05:00
break ;
2001-07-25 22:55:35 -04:00
default :
break ;
2002-05-11 01:09:54 -04:00
}
2002-12-09 22:23:04 -05:00
}
# endif /* HAVE_XSYNC */
switch ( event - > type )
{
case ButtonRelease :
if ( meta_grab_op_is_moving ( window - > display - > grab_op ) )
{
if ( event - > xbutton . root = = window - > screen - > xroot )
update_move ( window , event - > xbutton . state ,
event - > xbutton . x_root , event - > xbutton . y_root ) ;
}
else if ( meta_grab_op_is_resizing ( window - > display - > grab_op ) )
{
if ( event - > xbutton . root = = window - > screen - > xroot )
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
update_resize ( window ,
event - > xbutton . x_root ,
event - > xbutton . y_root ,
TRUE ) ;
2002-12-09 22:23:04 -05:00
}
2002-05-11 01:09:54 -04:00
meta_display_end_grab_op ( window - > display , event - > xbutton . time ) ;
2002-12-09 22:23:04 -05:00
break ;
case MotionNotify :
if ( meta_grab_op_is_moving ( window - > display - > grab_op ) )
{
if ( event - > xmotion . root = = window - > screen - > xroot )
2003-01-11 14:32:12 -05:00
{
2003-01-21 23:54:04 -05:00
if ( check_use_this_motion_notify ( window ,
event ) )
update_move ( window ,
event - > xmotion . state ,
event - > xmotion . x_root ,
event - > xmotion . y_root ) ;
2003-01-11 14:32:12 -05:00
}
2002-12-09 22:23:04 -05:00
}
else if ( meta_grab_op_is_resizing ( window - > display - > grab_op ) )
{
if ( event - > xmotion . root = = window - > screen - > xroot )
2003-01-11 14:32:12 -05:00
{
2003-01-21 23:54:04 -05:00
if ( check_use_this_motion_notify ( window ,
event ) )
update_resize ( window ,
event - > xmotion . x_root ,
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
event - > xmotion . y_root ,
FALSE ) ;
2003-01-11 14:32:12 -05:00
}
2002-12-09 22:23:04 -05:00
}
2001-07-25 22:55:35 -04:00
break ;
2002-12-09 22:23:04 -05:00
2002-12-09 16:07:27 -05:00
case EnterNotify :
case LeaveNotify :
2002-12-09 22:23:04 -05:00
if ( meta_grab_op_is_moving ( window - > display - > grab_op ) )
2001-07-25 22:55:35 -04:00
{
2002-12-09 22:23:04 -05:00
if ( event - > xcrossing . root = = window - > screen - > xroot )
update_move ( window ,
event - > xcrossing . state ,
event - > xcrossing . x_root ,
event - > xcrossing . y_root ) ;
}
else if ( meta_grab_op_is_resizing ( window - > display - > grab_op ) )
{
if ( event - > xcrossing . root = = window - > screen - > xroot )
update_resize ( window ,
event - > xcrossing . x_root ,
Fix bug 143333, support for update counter spec, and 109362, schedule
Sat Jun 19 02:21:08 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Fix bug 143333, support for update counter spec, and 109362,
schedule compensation events when events are ignored.
* src/display.c (meta_display_open): Add _NET_WM_SYNC_REQUEST and
_NET_WM_SYNC_REQUEST_COUNTER atoms. Remove the old
METACITY_SYNC_COUNTER stuff.
(meta_display_begin_op): Setup the sync counter
* src/xprops.c, src/xprops.h, src/window-props.c, src/display.h:
Add new atoms.
* src/window.c (send_sync_request): new function.
(meta_window_move_resize_internal): send a sync request before
resizing.
(check_move_resize_frequence): Rework logic to also check the SYNC
case. If an event is ignored return the remaining time.
(update_resize_timeout): Timeout that gets called when a
compensation event is scheduled.
(uddate_resize): schedule compensation events when an event is
ignored.
(meta_window_handle_mouse_grap_op_event): When an alarm is
received and sync was turned off, turn it back on.
* src/window.h (struct MetaWindow) Add some variables
2004-06-18 20:45:24 -04:00
event - > xcrossing . y_root ,
FALSE ) ;
2001-07-25 22:55:35 -04:00
}
break ;
default :
break ;
}
}
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 ) ;
2002-10-21 17:44:35 -04:00
meta_error_trap_pop ( window - > display , FALSE ) ;
2001-06-30 19:17:52 -04:00
}
2002-01-10 01:31:31 -05:00
2003-02-23 12:09:46 -05:00
static void
2003-03-08 18:43:17 -05:00
get_work_area_xinerama ( MetaWindow * window ,
MetaRectangle * area ,
int which_xinerama )
2002-01-10 01:31:31 -05:00
{
MetaRectangle space_area ;
2003-02-23 12:09:46 -05:00
GList * tmp ;
2002-06-06 23:18:46 -04:00
int left_strut ;
int right_strut ;
int top_strut ;
int bottom_strut ;
2003-02-23 12:09:46 -05:00
int xinerama_origin_x ;
int xinerama_origin_y ;
int xinerama_width ;
int xinerama_height ;
g_assert ( which_xinerama > = 0 ) ;
2002-01-10 01:31:31 -05:00
2003-02-23 12:09:46 -05:00
xinerama_origin_x = window - > screen - > xinerama_infos [ which_xinerama ] . x_origin ;
xinerama_origin_y = window - > screen - > xinerama_infos [ which_xinerama ] . y_origin ;
xinerama_width = window - > screen - > xinerama_infos [ which_xinerama ] . width ;
xinerama_height = window - > screen - > xinerama_infos [ which_xinerama ] . height ;
left_strut = 0 ;
right_strut = 0 ;
top_strut = 0 ;
bottom_strut = 0 ;
2002-01-10 01:31:31 -05:00
2003-02-23 12:09:46 -05:00
tmp = meta_window_get_workspaces ( window ) ;
2002-01-10 01:31:31 -05:00
while ( tmp ! = NULL )
{
2003-02-23 12:09:46 -05:00
meta_workspace_get_work_area_for_xinerama ( tmp - > data ,
which_xinerama ,
& space_area ) ;
2002-01-10 01:31:31 -05:00
2003-02-23 12:09:46 -05:00
left_strut = MAX ( left_strut , space_area . x - xinerama_origin_x ) ;
2002-01-10 01:31:31 -05:00
right_strut = MAX ( right_strut ,
2003-02-23 12:09:46 -05:00
( xinerama_width -
( space_area . x - xinerama_origin_x ) -
space_area . width ) ) ;
top_strut = MAX ( top_strut , space_area . y - xinerama_origin_y ) ;
2002-01-10 01:31:31 -05:00
bottom_strut = MAX ( bottom_strut ,
2003-02-23 12:09:46 -05:00
( xinerama_height -
( space_area . y - xinerama_origin_y ) -
2003-03-08 18:43:17 -05:00
space_area . height ) ) ;
2002-01-10 01:31:31 -05:00
tmp = tmp - > next ;
}
2002-06-06 23:18:46 -04:00
2003-02-23 12:09:46 -05:00
area - > x = xinerama_origin_x + left_strut ;
area - > y = xinerama_origin_y + top_strut ;
area - > width = xinerama_width - left_strut - right_strut ;
area - > height = xinerama_height - top_strut - bottom_strut ;
2002-01-10 01:31:31 -05:00
2002-02-07 22:34:26 -05:00
meta_topic ( META_DEBUG_WORKAREA ,
2003-03-08 18:43:17 -05:00
" Window %s xinerama %d has work area %d,%d %d x %d \n " ,
window - > desc , which_xinerama ,
area - > x , area - > y , area - > width , area - > height ) ;
2002-01-10 01:31:31 -05:00
}
2002-01-27 00:50:34 -05:00
2003-02-23 12:09:46 -05:00
void
meta_window_get_work_area_current_xinerama ( MetaWindow * window ,
MetaRectangle * area )
{
const MetaXineramaScreenInfo * xinerama = NULL ;
xinerama = meta_screen_get_xinerama_for_window ( window - > screen ,
window ) ;
meta_window_get_work_area_for_xinerama ( window ,
xinerama - > number ,
area ) ;
}
void
meta_window_get_work_area_for_xinerama ( MetaWindow * window ,
int which_xinerama ,
MetaRectangle * area )
{
g_return_if_fail ( which_xinerama > = 0 ) ;
2003-03-08 18:43:17 -05:00
get_work_area_xinerama ( window ,
area ,
which_xinerama ) ;
}
void
meta_window_get_work_area_all_xineramas ( MetaWindow * window ,
MetaRectangle * area )
{
MetaRectangle space_area ;
GList * tmp ;
int left_strut ;
int right_strut ;
int top_strut ;
int bottom_strut ;
int screen_origin_x ;
int screen_origin_y ;
int screen_width ;
int screen_height ;
screen_origin_x = 0 ;
screen_origin_y = 0 ;
screen_width = window - > screen - > width ;
screen_height = window - > screen - > height ;
left_strut = 0 ;
right_strut = 0 ;
top_strut = 0 ;
bottom_strut = 0 ;
tmp = meta_window_get_workspaces ( window ) ;
while ( tmp ! = NULL )
{
meta_workspace_get_work_area_all_xineramas ( tmp - > data ,
& space_area ) ;
left_strut = MAX ( left_strut , space_area . x - screen_origin_x ) ;
right_strut = MAX ( right_strut ,
( screen_width -
( space_area . x - screen_origin_x ) -
space_area . width ) ) ;
top_strut = MAX ( top_strut , space_area . y - screen_origin_y ) ;
bottom_strut = MAX ( bottom_strut ,
( screen_height -
( space_area . y - screen_origin_y ) -
space_area . height ) ) ;
tmp = tmp - > next ;
}
area - > x = screen_origin_x + left_strut ;
area - > y = screen_origin_y + top_strut ;
area - > width = screen_width - left_strut - right_strut ;
area - > height = screen_height - top_strut - bottom_strut ;
meta_topic ( META_DEBUG_WORKAREA ,
" Window %s has whole-screen work area %d,%d %d x %d \n " ,
window - > desc , area - > x , area - > y , area - > width , area - > height ) ;
2003-02-23 12:09:46 -05:00
}
2003-03-08 18:43:17 -05:00
2002-01-27 00:50:34 -05:00
gboolean
meta_window_same_application ( MetaWindow * window ,
MetaWindow * other_window )
{
2002-11-30 22:58:04 -05:00
return
meta_window_get_group ( window ) = =
meta_window_get_group ( other_window ) ;
2002-01-27 00:50:34 -05:00
}
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 ;
2003-10-12 02:25:38 -04:00
/* FIXME for now we bail out when doing wireframe, because our
* server grab keeps us from being able to redraw the stuff
* underneath the resize popup .
*/
if ( window - > display - > grab_wireframe_active )
return ;
2002-03-17 12:22:23 -05:00
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 )
{
2002-10-18 18:37:01 -04:00
if ( window - > size_hints . width_inc > 1 | |
window - > size_hints . height_inc > 1 )
window - > display - > grab_resize_popup =
meta_ui_resize_popup_new ( window - > display - > xdisplay ,
window - > screen - > number ) ;
2002-03-17 12:22:23 -05:00
}
if ( window - > display - > grab_resize_popup ! = NULL )
{
int gravity ;
2003-10-12 02:25:38 -04:00
int x , y , width , height ;
2002-03-17 12:22:23 -05:00
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 ) ;
2003-10-12 02:25:38 -04:00
if ( window - > display - > grab_wireframe_active )
{
x = window - > display - > grab_wireframe_rect . x ;
y = window - > display - > grab_wireframe_rect . y ;
width = window - > display - > grab_wireframe_rect . width ;
height = window - > display - > grab_wireframe_rect . height ;
}
else
{
meta_window_get_position ( window , & x , & y ) ;
width = window - > rect . width ;
height = window - > rect . height ;
}
2002-03-17 12:22:23 -05:00
meta_ui_resize_popup_set ( window - > display - > grab_resize_popup ,
gravity ,
x , y ,
2003-10-12 02:25:38 -04:00
width , height ,
2002-03-17 12:22:23 -05:00
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 ) )
2003-03-17 01:36:39 -05:00
{
if ( ! ( * func ) ( transient , data ) )
break ;
}
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
tmp = tmp - > next ;
}
g_slist_free ( windows ) ;
}
2003-03-17 01:36:39 -05:00
void
meta_window_foreach_ancestor ( MetaWindow * window ,
MetaWindowForeachFunc func ,
void * data )
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
{
MetaWindow * w ;
2003-03-17 01:36:39 -05:00
MetaWindow * tortoise ;
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
2003-03-17 01:36:39 -05:00
w = window ;
tortoise = window ;
while ( TRUE )
{
2002-09-27 15:42:59 -04:00
if ( w - > xtransient_for = = None | |
w - > transient_parent_is_root_window )
2003-03-17 01:36:39 -05:00
break ;
w = meta_display_lookup_x_window ( w - > display , w - > xtransient_for ) ;
if ( w = = NULL | | w = = tortoise )
break ;
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
2003-03-17 01:36:39 -05:00
if ( ! ( * func ) ( w , data ) )
break ;
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
2003-03-17 01:36:39 -05:00
if ( w - > xtransient_for = = None | |
w - > transient_parent_is_root_window )
break ;
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
w = meta_display_lookup_x_window ( w - > display , w - > xtransient_for ) ;
2003-03-17 01:36:39 -05:00
if ( w = = NULL | | w = = tortoise )
break ;
if ( ! ( * func ) ( w , data ) )
break ;
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
2003-03-17 01:36:39 -05:00
tortoise = meta_display_lookup_x_window ( tortoise - > display ,
tortoise - > xtransient_for ) ;
/* "w" should have already covered all ground covered by the
* tortoise , so the following must hold .
*/
g_assert ( tortoise ! = NULL ) ;
g_assert ( tortoise - > xtransient_for ! = None ) ;
g_assert ( ! tortoise - > transient_parent_is_root_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
}
2003-03-17 01:36:39 -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
2003-03-17 01:36:39 -05:00
typedef struct
{
MetaWindow * ancestor ;
gboolean found ;
} FindAncestorData ;
static gboolean
find_ancestor_func ( MetaWindow * window ,
void * data )
{
FindAncestorData * d = data ;
if ( window = = d - > ancestor )
{
d - > found = TRUE ;
return FALSE ;
}
return TRUE ;
}
gboolean
meta_window_is_ancestor_of_transient ( MetaWindow * window ,
MetaWindow * transient )
{
FindAncestorData d ;
d . ancestor = window ;
d . found = FALSE ;
meta_window_foreach_ancestor ( transient , find_ancestor_func , & d ) ;
return d . found ;
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
}
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
2003-10-12 02:25:38 -04:00
/* Warp pointer to location appropriate for grab,
* return root coordinates where pointer ended up .
*/
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
static gboolean
2003-10-12 02:25:38 -04:00
warp_grab_pointer ( MetaWindow * window ,
MetaGrabOp grab_op ,
int * x ,
int * y )
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
{
2003-10-12 02:25:38 -04:00
MetaRectangle rect ;
/* We may not have done begin_grab_op yet, i.e. may not be in a grab
*/
if ( window = = window - > display - > grab_window & &
window - > display - > grab_wireframe_active )
rect = window - > display - > grab_wireframe_rect ;
else
{
rect = window - > rect ;
meta_window_get_position ( window , & rect . x , & rect . y ) ;
}
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
switch ( grab_op )
{
case META_GRAB_OP_KEYBOARD_MOVING :
case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN :
2003-10-12 02:25:38 -04:00
* x = rect . width / 2 ;
* y = rect . height / 2 ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_S :
2003-10-12 02:25:38 -04:00
* x = rect . width / 2 ;
* y = rect . height ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_N :
2003-10-12 02:25:38 -04:00
* x = rect . width / 2 ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
* y = 0 ;
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_W :
* x = 0 ;
2003-10-12 02:25:38 -04:00
* y = rect . height / 2 ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_E :
2003-10-12 02:25:38 -04:00
* x = rect . width ;
* y = rect . height / 2 ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_SE :
2003-10-12 02:25:38 -04:00
* x = rect . width ;
* y = rect . height ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_NE :
2003-10-12 02:25:38 -04:00
* x = rect . width ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
* y = 0 ;
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_SW :
* x = 0 ;
2003-10-12 02:25:38 -04:00
* y = rect . height ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
break ;
case META_GRAB_OP_KEYBOARD_RESIZING_NW :
* x = 0 ;
* y = 0 ;
break ;
default :
return FALSE ;
}
2003-10-12 02:25:38 -04:00
* x + = rect . x ;
* y + = rect . y ;
2002-10-21 17:44:35 -04:00
meta_error_trap_push_with_return ( window - > display ) ;
2003-10-12 02:25:38 -04:00
meta_topic ( META_DEBUG_WINDOW_OPS ,
" Warping pointer to %d,%d with window at %d,%d \n " ,
* x , * y , rect . x , rect . y ) ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
XWarpPointer ( window - > display - > xdisplay ,
None ,
2003-10-12 02:25:38 -04:00
window - > screen - > xroot ,
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
0 , 0 , 0 , 0 ,
2003-10-12 02:25:38 -04:00
* x , * y ) ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
2002-10-21 17:44:35 -04:00
if ( meta_error_trap_pop_with_return ( window - > display , FALSE ) ! = Success )
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
{
2003-10-12 02:25:38 -04:00
meta_verbose ( " Failed to warp pointer for window %s \n " ,
window - > desc ) ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
return FALSE ;
}
2003-10-12 02:25:38 -04:00
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
return TRUE ;
}
void
meta_window_begin_grab_op ( MetaWindow * window ,
MetaGrabOp op ,
Time timestamp )
{
2003-10-12 02:25:38 -04:00
int x , y ;
gulong grab_start_serial ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
2003-10-12 02:25:38 -04:00
grab_start_serial = XNextRequest ( window - > display - > xdisplay ) ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
meta_window_raise ( window ) ;
2003-10-12 02:25:38 -04:00
warp_grab_pointer ( window ,
op , & x , & y ) ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
meta_display_begin_grab_op ( window - > display ,
window - > screen ,
window ,
op ,
2003-11-24 13:09:47 -05:00
FALSE ,
grab_start_serial /* event_serial */ ,
0 /* button */ ,
0 ,
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
timestamp ,
2003-10-12 02:25:38 -04:00
x , y ) ;
/* We override the one set in display_begin_grab_op since we
* did additional stuff as part of the grabbing process
*/
window - > display - > grab_start_serial = grab_start_serial ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
}
2002-09-24 17:22:06 -04:00
void
2003-10-12 02:25:38 -04:00
meta_window_update_keyboard_resize ( MetaWindow * window ,
gboolean update_cursor )
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
{
2003-10-12 02:25:38 -04:00
int x , y ;
2003-06-12 01:55:06 -04:00
2003-10-12 02:25:38 -04:00
warp_grab_pointer ( window ,
window - > display - > grab_op ,
& x , & y ) ;
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
2003-10-12 02:25:38 -04:00
{
/* As we warped the pointer, we have to reset the anchor state,
* since if the mouse moves we want to use those events to do the
* right thing . Also , this means that the motion notify
* from the pointer warp comes back as a no - op .
*/
int dx , dy ;
dx = x - window - > display - > grab_anchor_root_x ;
dy = y - window - > display - > grab_anchor_root_y ;
window - > display - > grab_anchor_root_x + = dx ;
window - > display - > grab_anchor_root_y + = dy ;
if ( window - > display - > grab_wireframe_active )
{
window - > display - > grab_anchor_window_pos =
window - > display - > grab_wireframe_rect ;
}
else
{
window - > display - > grab_anchor_window_pos = window - > rect ;
meta_window_get_position ( window ,
& window - > display - > grab_anchor_window_pos . x ,
& window - > display - > grab_anchor_window_pos . y ) ;
}
}
2003-06-12 01:55:06 -04:00
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
if ( update_cursor )
{
meta_display_set_grab_op_cursor ( window - > display ,
2002-08-14 12:51:13 -04:00
NULL ,
Patch to provide extra cues to the user when using window menu move and
2002-08-08 Craig Black <blackc@speakeasy.net>
Patch to provide extra cues to the user when using
window menu move and resize, #85724.
* src/common.h: add new cursors
* src/display.c: (grab_op_is_mouse)
(meta_display_create_x_cursor), (xcursor_for_op),
(meta_display_set_grab_op_cursor),
(meta_display_begin_grab_op):
The keyboard move and resize grab ops now also use the mouse.
Allow the grab cursor to be changed during the grab op.
Hold onto the initial grab position in case of reset.
* src/display.h: save the initial grab position
* src/keybindings.c: (process_keyboard_move_grab),
(process_keyboard_resize_grab), (handle_begin_move),
(handle_begin_resize):
The keyboard move and resize grab ops now also use the mouse.
* src/window.c: (meta_window_client_message), (menu_callback),
(update_move), (update_resize),
(meta_window_handle_mouse_grab_op_event), (warp_pointer),
(meta_window_warp_pointer), (meta_window_begin_grab_op),
(meta_window_update_resize_grab_op):
When moving or resizing a window use the last grab position
in computing change increment.
Provide support for warping the mouse pointer.
* src/window.h: new warp pointer and grab op helper functions
2002-08-09 00:27:23 -04:00
window - > display - > grab_op ,
TRUE ,
window - > display - > grab_xwindow ,
meta_display_get_current_time ( window - > display ) ) ;
}
}
2003-10-12 02:25:38 -04:00
void
meta_window_update_keyboard_move ( MetaWindow * window )
{
int x , y ;
warp_grab_pointer ( window ,
window - > display - > grab_op ,
& x , & y ) ;
}
2002-09-24 17:22:06 -04:00
void
meta_window_update_layer ( MetaWindow * window )
{
MetaGroup * group ;
meta_stack_freeze ( window - > screen - > stack ) ;
group = meta_window_get_group ( window ) ;
if ( group )
meta_group_update_layers ( group ) ;
else
meta_stack_update_layer ( window - > screen - > stack , window ) ;
meta_stack_thaw ( window - > screen - > stack ) ;
}
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
2004-08-05 13:48:39 -04:00
/* ensure_mru_position_after ensures that window appears after
* below_this_one in the active_workspace ' s mru_list ( i . e . it treats
* window as having been less recently used than below_this_one )
*/
static void
ensure_mru_position_after ( MetaWindow * window ,
MetaWindow * after_this_one )
{
/* This is sort of slow since it runs through the entire list more
* than once ( especially considering the fact that we expect the
* windows of interest to be the first two elements in the list ) ,
* but it doesn ' t matter while we ' re only using it on new window
* map .
*/
GList * active_mru_list ;
GList * window_position ;
GList * after_this_one_position ;
active_mru_list = window - > screen - > active_workspace - > mru_list ;
window_position = g_list_find ( active_mru_list , window ) ;
after_this_one_position = g_list_find ( active_mru_list , after_this_one ) ;
/* after_this_one_position is NULL when we switch workspaces, but in
* that case we don ' t need to do any MRU shuffling so we can simply
* return .
*/
if ( after_this_one_position = = NULL )
return ;
if ( g_list_length ( window_position ) > g_list_length ( after_this_one_position ) )
{
window - > screen - > active_workspace - > mru_list =
g_list_delete_link ( window - > screen - > active_workspace - > mru_list ,
window_position ) ;
window - > screen - > active_workspace - > mru_list =
g_list_insert_before ( window - > screen - > active_workspace - > mru_list ,
after_this_one_position - > next ,
window ) ;
}
}
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
void
meta_window_stack_just_below ( MetaWindow * window ,
MetaWindow * below_this_one )
{
g_return_if_fail ( window ! = NULL ) ;
g_return_if_fail ( below_this_one ! = NULL ) ;
if ( window - > stack_position > below_this_one - > stack_position )
{
meta_topic ( META_DEBUG_STACK ,
" Setting stack position of window %s to %d (making it below window %s). \n " ,
window - > desc ,
2004-08-27 13:22:54 -04:00
below_this_one - > stack_position ,
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
below_this_one - > desc ) ;
2004-08-27 13:22:54 -04:00
meta_window_set_stack_position ( window , below_this_one - > stack_position ) ;
Add support for _NET_WM_USER_TIME
2004-06-17 Elijah Newren <newren@math.utah.edu>
Add support for _NET_WM_USER_TIME
* src/display.c:
(meta_display_open): Add _NET_WM_USER_TIME to atom_names[],
(event_callback): Manually set _NET_WM_USER_TIME upon KeyPress
(doesn't work since keyboard isn't grabbed) and ButtonPress (does
work), this is just a fallback for applications that don't update
this themselves.
* src/display.h: (struct _MetaDisplay): Add atom_net_wm_user_time field
* src/screen.c: (meta_screen_apply_startup_properties): Check for
TIMESTAMP provided from startup sequence as well.
* src/stack.c:
s/meta_window_set_stack_position/meta_window_set_stack_position_no_sync/,
(meta_window_set_stack_position): New function which calls the
meta_window_set_stack_position_no_sync function followed immediately
by calling meta_stack_sync_to_server.
* src/window-props.c:
(init_net_wm_user_time), (reload_net_wm_user_time): new functions,
(reload_wm_hints): also load atom_net_wm_user_time
* src/window.c:
new XSERVER_TIME_IS_LATER macro (accounts for timestamp wraparound),
(meta_window_new_with_attrs): add timestamp attributes,
(window_takes_focus_on_map): use TIMESTAMP from startup
notification and _NET_WM_USER_TIME to decide whether to focus new
windows,
(meta_window_show): if app doesn't take focus on map, place it
just below the focused window in the stack
(process_property_notify): check for changes to _NET_WM_USRE_TIME,
(meta_window_stack_just_below): new function
* src/window.h:
(_MetaWindow struct): new fields for initial_timestamp,
initial_timestamp_set, net_wm_user_time_set, and net_wm_user_time,
(meta_window_stack_just_below): new function
2004-06-24 11:47:05 -04:00
}
else
{
meta_topic ( META_DEBUG_STACK ,
" Window %s was already below window %s. \n " ,
window - > desc , below_this_one - > desc ) ;
}
}
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
2005-02-20 12:14:16 -05:00
void
meta_window_set_user_time ( MetaWindow * window ,
Time timestamp )
{
/* FIXME: If Soeren's suggestion in bug 151984 is implemented, it will allow
* us to sanity check the timestamp here and ensure it doesn ' t correspond to
* a future time .
*/
/* Only update the time if this timestamp is newer... */
if ( window - > net_wm_user_time_set & &
XSERVER_TIME_IS_BEFORE ( timestamp , window - > net_wm_user_time ) )
{
meta_topic ( META_DEBUG_STARTUP ,
" Window %s _NET_WM_USER_TIME not updated to %lu, because it "
" is less than %lu \n " ,
window - > desc , timestamp , window - > net_wm_user_time ) ;
}
else
{
meta_topic ( META_DEBUG_STARTUP ,
" Window %s has _NET_WM_USER_TIME of %lu \n " ,
window - > desc , timestamp ) ;
window - > net_wm_user_time_set = TRUE ;
window - > net_wm_user_time = timestamp ;
if ( XSERVER_TIME_IS_BEFORE ( window - > display - > last_user_time , timestamp ) )
window - > display - > last_user_time = timestamp ;
}
}