Commit 43a726ef authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington
Browse files

Patch from Keith Packard to handle root window resizes.

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

        Patch from Keith Packard to handle root window resizes.

	* src/screen.c (reload_xinerama_infos): factor out Xinerama code
	(meta_screen_resize): implement this, to be called from display.c
	on screen resize

	* src/display.c (event_callback): handle ConfigureNotify on root
	windows
parent f37245ac
2002-09-28 Havoc Pennington <hp@pobox.com>
Patch from Keith Packard to handle root window resizes.
* src/screen.c (reload_xinerama_infos): factor out Xinerama code
(meta_screen_resize): implement this, to be called from display.c
on screen resize
* src/display.c (event_callback): handle ConfigureNotify on root
windows
2002-09-28 Havoc Pennington <hp@pobox.com>
* src/stack.c (get_standalone_layer): re-enable the FOCUSED_WINDOW
......
......@@ -1388,6 +1388,17 @@ event_callback (XEvent *event,
case ReparentNotify:
break;
case ConfigureNotify:
/* Handle screen resize */
{
MetaScreen *screen;
screen = meta_display_screen_for_root (display,
event->xconfigure.window);
if (screen != NULL)
meta_screen_resize (screen,
event->xconfigure.width,
event->xconfigure.height);
}
break;
case ConfigureRequest:
/* This comment and code is found in both twm and fvwm */
......
......@@ -171,6 +171,180 @@ set_wm_icon_size_hint (MetaScreen *screen)
#undef N_VALS
}
static void
reload_xinerama_infos (MetaScreen *screen)
{
MetaDisplay *display;
display = screen->display;
if (screen->xinerama_infos)
g_free (screen->xinerama_infos);
screen->xinerama_infos = NULL;
screen->n_xinerama_infos = 0;
screen->last_xinerama_index = 0;
screen->display->xinerama_cache_invalidated = TRUE;
#ifdef HAVE_XFREE_XINERAMA
if (XineramaIsActive (display->xdisplay))
{
XineramaScreenInfo *infos;
int n_infos;
int i;
n_infos = 0;
infos = XineramaQueryScreens (display->xdisplay, &n_infos);
meta_topic (META_DEBUG_XINERAMA,
"Found %d Xinerama screens on display %s\n",
n_infos, display->name);
if (n_infos > 0)
{
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, n_infos);
screen->n_xinerama_infos = n_infos;
i = 0;
while (i < n_infos)
{
screen->xinerama_infos[i].number = infos[i].screen_number;
screen->xinerama_infos[i].x_origin = infos[i].x_org;
screen->xinerama_infos[i].y_origin = infos[i].y_org;
screen->xinerama_infos[i].width = infos[i].width;
screen->xinerama_infos[i].height = infos[i].height;
meta_topic (META_DEBUG_XINERAMA,
"Xinerama %d is %d,%d %d x %d\n",
screen->xinerama_infos[i].number,
screen->xinerama_infos[i].x_origin,
screen->xinerama_infos[i].y_origin,
screen->xinerama_infos[i].width,
screen->xinerama_infos[i].height);
++i;
}
}
meta_XFree (infos);
}
else
{
meta_topic (META_DEBUG_XINERAMA,
"No XFree86 Xinerama extension or XFree86 Xinerama inactive on display %s\n",
display->name);
}
#else
meta_topic (META_DEBUG_XINERAMA,
"Metacity compiled without XFree86 Xinerama support\n");
#endif /* HAVE_XFREE_XINERAMA */
#ifdef HAVE_SOLARIS_XINERAMA
/* This code from GDK, Copyright (C) 2002 Sun Microsystems */
if (screen->n_xinerama_infos == 0 &&
XineramaGetState (screen->display->xdisplay,
screen->number))
{
XRectangle monitors[MAXFRAMEBUFFERS];
unsigned char hints[16];
int result;
int n_monitors;
int i;
n_monitors = 0;
result = XineramaGetInfo (screen->xdisplay,
screen->number,
monitors, hints,
&n_monitors);
/* Yes I know it should be Success but the current implementation
* returns the num of monitor
*/
if (result > 0)
{
g_assert (n_monitors > 0);
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, n_monitors);
screen->n_xinerama_infos = n_monitors;
i = 0;
while (i < n_monitors)
{
screen->xinerama_infos[i].number = i;
screen->xinerama_infos[i].x_origin = monitors[i].x;
screen->xinerama_infos[i].y_origin = monitors[i].y;
screen->xinerama_infos[i].width = monitors[i].width;
screen->xinerama_infos[i].height = monitors[i].height;
meta_topic (META_DEBUG_XINERAMA,
"Xinerama %d is %d,%d %d x %d\n",
screen->xinerama_infos[i].number,
screen->xinerama_infos[i].x_origin,
screen->xinerama_infos[i].y_origin,
screen->xinerama_infos[i].width,
screen->xinerama_infos[i].height);
++i;
}
}
}
else if (screen->n_xinerama_infos == 0)
{
meta_topic (META_DEBUG_XINERAMA,
"No Solaris Xinerama extension or Solaris Xinerama inactive on display %s\n",
display->name);
}
#else
meta_topic (META_DEBUG_XINERAMA,
"Metacity compiled without Solaris Xinerama support\n");
#endif /* HAVE_SOLARIS_XINERAMA */
/* If no Xinerama, fill in the single screen info so
* we can use the field unconditionally
*/
if (screen->n_xinerama_infos == 0)
{
if (g_getenv ("METACITY_DEBUG_XINERAMA"))
{
meta_topic (META_DEBUG_XINERAMA,
"Pretending a single monitor has two Xinerama screens\n");
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, 2);
screen->n_xinerama_infos = 2;
screen->xinerama_infos[0].number = 0;
screen->xinerama_infos[0].x_origin = 0;
screen->xinerama_infos[0].y_origin = 0;
screen->xinerama_infos[0].width = screen->width / 2;
screen->xinerama_infos[0].height = screen->height;
screen->xinerama_infos[1].number = 1;
screen->xinerama_infos[1].x_origin = screen->width / 2;
screen->xinerama_infos[1].y_origin = 0;
screen->xinerama_infos[1].width = screen->width / 2 + screen->width % 2;
screen->xinerama_infos[1].height = screen->height;
}
else
{
meta_topic (META_DEBUG_XINERAMA,
"No Xinerama screens, using default screen info\n");
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, 1);
screen->n_xinerama_infos = 1;
screen->xinerama_infos[0].number = 0;
screen->xinerama_infos[0].x_origin = 0;
screen->xinerama_infos[0].y_origin = 0;
screen->xinerama_infos[0].width = screen->width;
screen->xinerama_infos[0].height = screen->height;
}
}
g_assert (screen->n_xinerama_infos > 0);
g_assert (screen->xinerama_infos != NULL);
}
MetaScreen*
meta_screen_new (MetaDisplay *display,
int number)
......@@ -314,7 +488,8 @@ meta_screen_new (MetaDisplay *display,
LeaveWindowMask | EnterWindowMask |
ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask |
FocusChangeMask | attr.your_event_mask);
FocusChangeMask | StructureNotifyMask |
attr.your_event_mask);
if (meta_error_trap_pop (display) != Success)
{
meta_warning (_("Screen %d on display \"%s\" already has a window manager\n"),
......@@ -349,168 +524,12 @@ meta_screen_new (MetaDisplay *display,
screen->rows_of_workspaces = 1;
screen->columns_of_workspaces = -1;
screen->vertical_workspaces = FALSE;
screen->xinerama_infos = NULL;
screen->n_xinerama_infos = 0;
screen->last_xinerama_index = 0;
#ifdef HAVE_XFREE_XINERAMA
if (XineramaIsActive (display->xdisplay))
{
XineramaScreenInfo *infos;
int n_infos;
int i;
n_infos = 0;
infos = XineramaQueryScreens (display->xdisplay, &n_infos);
meta_topic (META_DEBUG_XINERAMA,
"Found %d Xinerama screens on display %s\n",
n_infos, display->name);
if (n_infos > 0)
{
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, n_infos);
screen->n_xinerama_infos = n_infos;
i = 0;
while (i < n_infos)
{
screen->xinerama_infos[i].number = infos[i].screen_number;
screen->xinerama_infos[i].x_origin = infos[i].x_org;
screen->xinerama_infos[i].y_origin = infos[i].y_org;
screen->xinerama_infos[i].width = infos[i].width;
screen->xinerama_infos[i].height = infos[i].height;
meta_topic (META_DEBUG_XINERAMA,
"Xinerama %d is %d,%d %d x %d\n",
screen->xinerama_infos[i].number,
screen->xinerama_infos[i].x_origin,
screen->xinerama_infos[i].y_origin,
screen->xinerama_infos[i].width,
screen->xinerama_infos[i].height);
++i;
}
}
meta_XFree (infos);
}
else
{
meta_topic (META_DEBUG_XINERAMA,
"No XFree86 Xinerama extension or XFree86 Xinerama inactive on display %s\n",
display->name);
}
#else
meta_topic (META_DEBUG_XINERAMA,
"Metacity compiled without XFree86 Xinerama support\n");
#endif /* HAVE_XFREE_XINERAMA */
#ifdef HAVE_SOLARIS_XINERAMA
/* This code from GDK, Copyright (C) 2002 Sun Microsystems */
if (screen->n_xinerama_infos == 0 &&
XineramaGetState (screen->display->xdisplay,
screen->number))
{
XRectangle monitors[MAXFRAMEBUFFERS];
unsigned char hints[16];
int result;
int n_monitors;
int i;
n_monitors = 0;
result = XineramaGetInfo (screen->xdisplay,
screen->number,
monitors, hints,
&n_monitors);
/* Yes I know it should be Success but the current implementation
* returns the num of monitor
*/
if (result > 0)
{
g_assert (n_monitors > 0);
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, n_monitors);
screen->n_xinerama_infos = n_monitors;
i = 0;
while (i < n_monitors)
{
screen->xinerama_infos[i].number = i;
screen->xinerama_infos[i].x_origin = monitors[i].x;
screen->xinerama_infos[i].y_origin = monitors[i].y;
screen->xinerama_infos[i].width = monitors[i].width;
screen->xinerama_infos[i].height = monitors[i].height;
meta_topic (META_DEBUG_XINERAMA,
"Xinerama %d is %d,%d %d x %d\n",
screen->xinerama_infos[i].number,
screen->xinerama_infos[i].x_origin,
screen->xinerama_infos[i].y_origin,
screen->xinerama_infos[i].width,
screen->xinerama_infos[i].height);
++i;
}
}
}
else if (screen->n_xinerama_infos == 0)
{
meta_topic (META_DEBUG_XINERAMA,
"No Solaris Xinerama extension or Solaris Xinerama inactive on display %s\n",
display->name);
}
#else
meta_topic (META_DEBUG_XINERAMA,
"Metacity compiled without Solaris Xinerama support\n");
#endif /* HAVE_SOLARIS_XINERAMA */
/* If no Xinerama, fill in the single screen info so
* we can use the field unconditionally
*/
if (screen->n_xinerama_infos == 0)
{
if (g_getenv ("METACITY_DEBUG_XINERAMA"))
{
meta_topic (META_DEBUG_XINERAMA,
"Pretending a single monitor has two Xinerama screens\n");
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, 2);
screen->n_xinerama_infos = 2;
screen->xinerama_infos[0].number = 0;
screen->xinerama_infos[0].x_origin = 0;
screen->xinerama_infos[0].y_origin = 0;
screen->xinerama_infos[0].width = screen->width / 2;
screen->xinerama_infos[0].height = screen->height;
screen->xinerama_infos[1].number = 1;
screen->xinerama_infos[1].x_origin = screen->width / 2;
screen->xinerama_infos[1].y_origin = 0;
screen->xinerama_infos[1].width = screen->width / 2 + screen->width % 2;
screen->xinerama_infos[1].height = screen->height;
}
else
{
meta_topic (META_DEBUG_XINERAMA,
"No Xinerama screens, using default screen info\n");
screen->xinerama_infos = g_new (MetaXineramaScreenInfo, 1);
screen->n_xinerama_infos = 1;
screen->xinerama_infos[0].number = 0;
screen->xinerama_infos[0].x_origin = 0;
screen->xinerama_infos[0].y_origin = 0;
screen->xinerama_infos[0].width = screen->width;
screen->xinerama_infos[0].height = screen->height;
}
}
g_assert (screen->n_xinerama_infos > 0);
g_assert (screen->xinerama_infos != NULL);
reload_xinerama_infos (screen);
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
......@@ -1468,3 +1487,25 @@ meta_screen_calc_workspace_layout (MetaScreen *screen,
*r = rows;
*c = cols;
}
void
meta_screen_resize_func (MetaScreen *screen,
MetaWindow *window,
void *user_data)
{
meta_window_queue_move_resize (window);
}
void
meta_screen_resize (MetaScreen *screen,
int width,
int height)
{
screen->width = width;
screen->height = height;
reload_xinerama_infos (screen);
/* Queue a resize on all the windows */
meta_screen_foreach_window (screen, meta_screen_resize_func, 0);
}
......@@ -122,4 +122,9 @@ void meta_screen_calc_workspace_layout (MetaScreen *screen,
int *r,
int *c);
void meta_screen_resize (MetaScreen *screen,
int width,
int height);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment