Commit 337812d5 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington
Browse files

workspaces are all per-screen now, fix accordingly

2002-10-16  Havoc Pennington  <hp@redhat.com>

	* src/workspace.c: workspaces are all per-screen now, fix
	accordingly

	* src/core.c: fix multihead workspace stuff

	* src/keybindings.c: multihead-rama

	* src/screen.c (meta_screen_show_desktop): new functions to
	replace display equivalents

	* src/display.c (meta_display_get_workspace_by_screen_index): get
	rid of this
	(meta_display_get_workspace_by_index): get rid of this
	(event_callback): handle _NET_SHOWING_DESKTOP message per-screen

	* src/screen.c (meta_screen_get_workspace_by_index): new function

	* src/screen.h (struct _MetaScreen): move workspace list, and
	showing_desktop flag, to be per-screen

	* src/window.c (window_query_root_pointer): return whether pointer
	is on window's screen
	(meta_window_handle_mouse_grab_op_event): don't use coordinates
	from other screens when updating a window operation on the current
	screen. I can't believe no one has reported this...
parent 17ac646f
2002-10-16 Havoc Pennington <hp@redhat.com>
* src/workspace.c: workspaces are all per-screen now, fix
accordingly
* src/core.c: fix multihead workspace stuff
* src/keybindings.c: multihead-rama
* src/screen.c (meta_screen_show_desktop): new functions to
replace display equivalents
* src/display.c (meta_display_get_workspace_by_screen_index): get
rid of this
(meta_display_get_workspace_by_index): get rid of this
(event_callback): handle _NET_SHOWING_DESKTOP message per-screen
* src/screen.c (meta_screen_get_workspace_by_index): new function
* src/screen.h (struct _MetaScreen): move workspace list, and
showing_desktop flag, to be per-screen
* src/window.c (window_query_root_pointer): return whether pointer
is on window's screen
(meta_window_handle_mouse_grab_op_event): don't use coordinates
from other screens when updating a window operation on the current
screen. I can't believe no one has reported this...
2002-10-16 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_client_message): update window layer
......
......@@ -434,9 +434,8 @@ meta_core_change_workspace (Display *xdisplay,
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
meta_window_change_workspace (window,
meta_display_get_workspace_by_screen_index (display,
window->screen,
new_workspace));
meta_screen_get_workspace_by_index (window->screen,
new_workspace));
}
int
......@@ -456,7 +455,7 @@ meta_core_get_active_workspace (Screen *xscreen)
screen = meta_screen_for_x_screen (xscreen);
return meta_workspace_screen_index (screen->active_workspace);
return meta_workspace_index (screen->active_workspace);
}
int
......@@ -624,13 +623,17 @@ meta_core_get_menu_accelerator (MetaMenuOp menu_op,
char *
meta_core_get_workspace_name_with_index (Display *xdisplay,
int index)
Window xroot,
int index)
{
MetaDisplay *display;
MetaScreen *screen;
MetaWorkspace *workspace;
display = meta_display_for_x_display (xdisplay);
workspace = meta_display_get_workspace_by_index (display, index);
screen = meta_display_screen_for_root (display, xroot);
g_assert (screen != NULL);
workspace = meta_screen_get_workspace_by_index (screen, index);
return (workspace != NULL) ? workspace->name : NULL;
}
......
......@@ -101,7 +101,8 @@ int meta_core_get_active_workspace (Screen *xscreen);
int meta_core_get_frame_workspace (Display *xdisplay,
Window frame_xwindow);
char* meta_core_get_workspace_name_with_index (Display *xdisplay,
int index);
Window xroot,
int index);
void meta_core_get_frame_extents (Display *xdisplay,
Window frame_xwindow,
......
......@@ -261,7 +261,6 @@ meta_display_open (const char *name)
display->error_traps = 0;
display->error_trap_handler = NULL;
display->server_grab_count = 0;
display->workspaces = NULL;
display->pending_pings = NULL;
display->autoraise_timeout_id = 0;
......@@ -269,8 +268,6 @@ meta_display_open (const char *name)
display->expected_focus_window = NULL;
display->mru_list = NULL;
display->showing_desktop = FALSE;
/* FIXME copy the checks from GDK probably */
display->static_gravity_works = g_getenv ("METACITY_USE_STATIC_GRAVITY") != NULL;
......@@ -1539,9 +1536,8 @@ event_callback (XEvent *event,
space);
workspace =
meta_display_get_workspace_by_screen_index (display,
screen,
space);
meta_screen_get_workspace_by_index (screen,
space);
if (workspace)
meta_workspace_activate (workspace);
......@@ -1569,9 +1565,9 @@ event_callback (XEvent *event,
meta_verbose ("Request to %s desktop\n", showing_desktop ? "show" : "hide");
if (showing_desktop)
meta_display_show_desktop (display);
meta_screen_show_desktop (screen);
else
meta_display_unshow_desktop (display);
meta_screen_unshow_desktop (screen);
}
else if (event->xclient.message_type ==
display->atom_metacity_restart_message)
......@@ -2145,56 +2141,6 @@ meta_display_unregister_x_window (MetaDisplay *display,
remove_pending_pings_for_window (display, xwindow);
}
MetaWorkspace*
meta_display_get_workspace_by_index (MetaDisplay *display,
int idx)
{
GList *tmp;
/* should be robust, index is maybe from an app */
if (idx < 0)
return NULL;
tmp = g_list_nth (display->workspaces, idx);
if (tmp == NULL)
return NULL;
else
return tmp->data;
}
MetaWorkspace*
meta_display_get_workspace_by_screen_index (MetaDisplay *display,
MetaScreen *screen,
int idx)
{
GList *tmp;
int i;
/* should be robust, idx is maybe from an app */
if (idx < 0)
return NULL;
i = 0;
tmp = display->workspaces;
while (tmp != NULL)
{
MetaWorkspace *w = tmp->data;
if (w->screen == screen)
{
if (i == idx)
return w;
else
++i;
}
tmp = tmp->next;
}
return NULL;
}
Cursor
meta_display_create_x_cursor (MetaDisplay *display,
MetaCursor cursor)
......@@ -2712,31 +2658,6 @@ meta_display_increment_event_serial (MetaDisplay *display)
display->atom_motif_wm_hints);
}
static void
meta_display_update_showing_desktop_hint (MetaDisplay *display)
{
GSList *tmp;
unsigned long data[1];
data[0] = display->showing_desktop ? 1 : 0;
tmp = display->screens;
while (tmp != NULL)
{
MetaScreen *screen = tmp->data;
meta_error_trap_push (display);
XChangeProperty (display->xdisplay, screen->xroot,
display->atom_net_showing_desktop,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (display);
tmp = tmp->next;
}
}
void
meta_display_update_active_window_hint (MetaDisplay *display)
{
......@@ -2766,62 +2687,6 @@ meta_display_update_active_window_hint (MetaDisplay *display)
}
}
static void
queue_windows_showing (MetaDisplay *display)
{
GSList *windows;
GSList *tmp;
windows = meta_display_list_windows (display);
tmp = windows;
while (tmp != NULL)
{
meta_window_queue_calc_showing (tmp->data);
tmp = tmp->next;
}
g_slist_free (windows);
}
void
meta_display_show_desktop (MetaDisplay *display)
{
if (display->showing_desktop)
return;
display->showing_desktop = TRUE;
queue_windows_showing (display);
meta_display_update_showing_desktop_hint (display);
}
void
meta_display_unshow_desktop (MetaDisplay *display)
{
GSList *tmp;
if (!display->showing_desktop)
return;
display->showing_desktop = FALSE;
queue_windows_showing (display);
meta_display_update_showing_desktop_hint (display);
tmp = display->screens;
while (tmp != NULL)
{
MetaScreen *screen = tmp->data;
meta_screen_focus_top_window (screen, NULL);
tmp = tmp->next;
}
}
void
meta_display_queue_retheme_all_windows (MetaDisplay *display)
{
......
......@@ -162,11 +162,8 @@ struct _MetaDisplay
/* Most recently focused list. Always contains all
* live windows.
*/
GList *mru_list;
GList *workspaces;
GList *mru_list;
guint showing_desktop : 1;
guint static_gravity_works : 1;
/*< private-ish >*/
......@@ -288,12 +285,6 @@ GSList* meta_display_list_windows (MetaDisplay *display);
MetaDisplay* meta_display_for_x_display (Display *xdisplay);
GSList* meta_displays_list (void);
MetaWorkspace* meta_display_get_workspace_by_index (MetaDisplay *display,
int index);
MetaWorkspace* meta_display_get_workspace_by_screen_index (MetaDisplay *display,
MetaScreen *screen,
int index);
Cursor meta_display_create_x_cursor (MetaDisplay *display,
MetaCursor cursor);
......@@ -332,10 +323,6 @@ void meta_display_increment_event_serial (MetaDisplay *display);
void meta_display_update_active_window_hint (MetaDisplay *display);
/* Show/hide the desktop (temporarily hide all windows) */
void meta_display_show_desktop (MetaDisplay *display);
void meta_display_unshow_desktop (MetaDisplay *display);
guint32 meta_display_get_current_time (MetaDisplay *display);
/* utility goo */
......
This diff is collapsed.
......@@ -133,12 +133,13 @@ activate_cb (GtkWidget *menuitem, gpointer data)
*/
static char *
get_workspace_name_with_accel (Display *display,
int index)
Window xroot,
int index)
{
char *name;
unsigned int number;
name = meta_core_get_workspace_name_with_index (display, index);
name = meta_core_get_workspace_name_with_index (display, xroot, index);
/*
* If the name is of the form "Workspace x" where x is an unsigned
......@@ -312,9 +313,22 @@ meta_window_menu_new (MetaFrames *frames,
{
GtkWidget *mi;
Display *display;
Window xroot;
display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
display = gdk_x11_drawable_get_xdisplay(GTK_WIDGET(frames)->window);
#ifdef HAVE_GTK_MULTIHEAD
{
GdkScreen *screen;
screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
}
#else
{
xroot = gdk_x11_get_default_root_xwindow ();
}
#endif
i = 0;
while (i < n_workspaces)
{
......@@ -327,7 +341,7 @@ meta_window_menu_new (MetaFrames *frames,
i + 1,
&key, &mods);
name = get_workspace_name_with_accel (display, i);
name = get_workspace_name_with_accel (display, xroot, i);
if (ops & META_MENU_OP_UNSTICK)
label = g_strdup_printf (_("Only on %s"), name);
else
......
......@@ -56,7 +56,9 @@ if test -z "$ONLY_WM"; then
echo "Launching clients"
if test -n "$TEST_CLIENT"; then
DISPLAY=$CLIENT_DISPLAY $TEST_CLIENT &
for I in `seq 0 $SCREENS`; do
DISPLAY=$CLIENT_DISPLAY.$I $TEST_CLIENT &
done
fi
if test $CLIENTS != 0; then
......@@ -79,7 +81,9 @@ if test -z "$ONLY_WM"; then
usleep 50000
DISPLAY=$CLIENT_DISPLAY xsetroot -solid royalblue3
for I in `seq 0 $SCREENS`; do
DISPLAY=$CLIENT_DISPLAY.$I xsetroot -solid royalblue3
done
fi
if test -z "$ONLY_SETUP"; then
......
......@@ -523,15 +523,18 @@ meta_screen_new (MetaDisplay *display,
screen->work_area_idle = 0;
screen->active_workspace = NULL;
screen->workspaces = NULL;
screen->rows_of_workspaces = 1;
screen->columns_of_workspaces = -1;
screen->vertical_workspaces = FALSE;
screen->starting_corner = META_SCREEN_TOPLEFT;
screen->showing_desktop = FALSE;
screen->xinerama_infos = NULL;
screen->n_xinerama_infos = 0;
screen->last_xinerama_index = 0;
reload_xinerama_infos (screen);
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
......@@ -810,23 +813,35 @@ meta_screen_queue_window_resizes (MetaScreen *screen)
int
meta_screen_get_n_workspaces (MetaScreen *screen)
{
return g_list_length (screen->workspaces);
}
MetaWorkspace*
meta_screen_get_workspace_by_index (MetaScreen *screen,
int idx)
{
GList *tmp;
int i;
/* should be robust, idx is maybe from an app */
if (idx < 0)
return NULL;
i = 0;
tmp = screen->display->workspaces;
tmp = screen->workspaces;
while (tmp != NULL)
{
MetaWorkspace *w = tmp->data;
if (w->screen == screen)
++i;
if (i == idx)
return w;
++i;
tmp = tmp->next;
}
return i;
return NULL;
}
static int
......@@ -867,21 +882,17 @@ update_num_workspaces (MetaScreen *screen)
last_remaining = NULL;
extras = NULL;
i = 0;
tmp = screen->display->workspaces;
tmp = screen->workspaces;
while (tmp != NULL)
{
MetaWorkspace *w = tmp->data;
if (w->screen == screen)
{
++i;
if (i > new_num)
extras = g_list_prepend (extras, w);
else
last_remaining = w;
}
if (i > new_num)
extras = g_list_prepend (extras, w);
else
last_remaining = w;
++i;
tmp = tmp->next;
}
......@@ -1078,7 +1089,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
if (k >= len)
break;
workspace = meta_display_get_workspace_by_index (screen->display, k);
workspace = meta_screen_get_workspace_by_index (screen, k);
g_assert (workspace);
entries[iter].key = (MetaTabEntryKey) workspace;
......@@ -1096,7 +1107,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
{
MetaWorkspace *workspace;
workspace = meta_display_get_workspace_by_index (screen->display, i);
workspace = meta_screen_get_workspace_by_index (screen, i);
g_assert (workspace);
......@@ -1362,17 +1373,14 @@ meta_screen_update_workspace_names (MetaScreen *screen)
}
i = 0;
tmp = screen->display->workspaces;
tmp = screen->workspaces;
while (tmp != NULL && i < n_names)
{
MetaWorkspace *w = tmp->data;
if (w->screen == screen)
{
meta_workspace_set_name (w, names[i]);
meta_workspace_set_name (w, names[i]);
++i;
}
++i;
tmp = tmp->next;
}
......@@ -1413,7 +1421,7 @@ set_work_area_hint (MetaScreen *screen)
num_workspaces = meta_screen_get_n_workspaces (screen);
data = g_new (unsigned long, num_workspaces * 4);
tmp_list = screen->display->workspaces;
tmp_list = screen->workspaces;
tmp = data;
while (tmp_list != NULL)
......@@ -1543,3 +1551,68 @@ meta_screen_resize (MetaScreen *screen,
/* Queue a resize on all the windows */
meta_screen_foreach_window (screen, meta_screen_resize_func, 0);
}
static void
update_showing_desktop_hint (MetaScreen *screen)
{
unsigned long data[1];
data[0] = screen->showing_desktop ? 1 : 0;
meta_error_trap_push (screen->display);
XChangeProperty (screen->display->xdisplay, screen->xroot,
screen->display->atom_net_showing_desktop,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1);
meta_error_trap_pop (screen->display);
}
static void
queue_windows_showing (MetaScreen *screen)
{
GSList *windows;
GSList *tmp;
windows = meta_display_list_windows (screen->display);
tmp = windows;
while (tmp != NULL)
{
MetaWindow *w = tmp->data;
if (w->screen == screen)
meta_window_queue_calc_showing (w);
tmp = tmp->next;
}
g_slist_free (windows);
}
void
meta_screen_show_desktop (MetaScreen *screen)
{
if (screen->showing_desktop)
return;
screen->showing_desktop = TRUE;
queue_windows_showing (screen);
update_showing_desktop_hint (screen);
}
void
meta_screen_unshow_desktop (MetaScreen *screen)
{
if (!screen->showing_desktop)
return;
screen->showing_desktop = FALSE;
queue_windows_showing (screen);
update_showing_desktop_hint (screen);
meta_screen_focus_top_window (screen, NULL);
}
......@@ -64,6 +64,8 @@ struct _MetaScreen
MetaWorkspace *active_workspace;
GList *workspaces;
MetaStack *stack;
MetaCursor current_cursor;
......@@ -87,7 +89,8 @@ struct _MetaScreen
guint keys_grabbed : 1;
guint all_keys_grabbed : 1;
guint showing_desktop : 1;
int closing;
};
......@@ -104,6 +107,9 @@ void meta_screen_queue_window_resizes (MetaScreen *scre
int meta_screen_get_n_workspaces (MetaScreen *screen);
MetaWorkspace* meta_screen_get_workspace_by_index (MetaScreen *screen,
int index);
void meta_screen_set_cursor (MetaScreen *screen,
MetaCursor cursor);
......@@ -136,4 +142,9 @@ void meta_screen_resize (MetaScreen *screen,
int height);
/* Show/hide the desktop (temporarily hide all windows) */
void meta_screen_show_desktop (MetaScreen *screen);
void meta_screen_unshow_desktop (MetaScreen *screen);
#endif
......@@ -1008,7 +1008,7 @@ save_state (void)
while (w != NULL)
{
<