This commit is contained in:
rhp 2001-07-28 06:35:19 +00:00
parent 46d224f5ae
commit b1d438922a
8 changed files with 157 additions and 35 deletions

48
HACKING Normal file
View File

@ -0,0 +1,48 @@
The script src/run-metacity.sh is useful to hack on the window manager.
It runs metacity in an Xnest. e.g.:
CLIENTS=3 ./run-metacity.sh
or
DEBUG=memprof ./run-metacity.sh
or whatever.
src/window.c is where all the guts of the window manager live. This is
basically the only remotely scary file.
src/frames.c is the GtkWidget that handles drawing window frames.
src/core.h defines the interface used by the GTK portion of the window
manager to talk to the other portions. There's some cruft in here
that's unused, since nearly all window operations have moved out of
this file so frameless apps can have window operations.
src/ui.h defines the interface the plain Xlib portion of the window
manager uses to talk to the GTK portion.
Files that include gdk.h or gtk.h are not supposed to include
display.h or window.h or other core files.
Files in the core (display.[hc], window.[hc]) are not supposed to
include gdk.h or gtk.h.
When hacking, remember that you can have multiple screens. The code is
also written to support multiple displays, but this is useless, since
you can just run two copies of the WM. Also, an XKillClient() or
shutdown on any display causes Xlib to exit the app, so it would be
broken. So the multi-display thing is mostly just for code
cleanliness. Multi-screen on the other hand is important for some
people.
Remember that strings stored in X properties are not in UTF-8, and
they have to end up in UTF-8 before we try putting them through Pango.
If you make any X request involving a client window, you have to
meta_error_trap_push() around the call; this is not necessary for
X requests on the frame windows.
Remember that not all windows have frames, and window->frame can
be NULL.
The code could use cleanup in a lot of places, feel free to do so.

View File

@ -1,3 +1,4 @@
SUBDIRS=src SUBDIRS=src
EXTRA_DIST=HACKING

2
README
View File

@ -23,6 +23,8 @@ sometime probably.
Feel free to send patches too; Metacity is really small and simple, so Feel free to send patches too; Metacity is really small and simple, so
if you find a bug or want to add a feature it should be pretty easy. if you find a bug or want to add a feature it should be pretty easy.
See the HACKING file for some notes on hacking Metacity.
METACITY FEATURES METACITY FEATURES
=== ===

View File

@ -1555,24 +1555,26 @@ meta_display_grab_window_buttons (MetaDisplay *display,
meta_warning ("Failed to grab button %d with Mod1Mask for frame 0x%lx error code %d\n", meta_warning ("Failed to grab button %d with Mod1Mask for frame 0x%lx error code %d\n",
i, xwindow, result); i, xwindow, result);
#if 1
/* This is just for debugging, since I end up moving if (g_getenv ("METACITY_DEBUG_BUTTON_GRABS"))
* the Xnest otherwise ;-) {
*/ /* This is just for debugging, since I end up moving
meta_error_trap_push (display); * the Xnest otherwise ;-)
result = XGrabButton (display->xdisplay, i, ControlMask, */
xwindow, False, meta_error_trap_push (display);
ButtonPressMask | ButtonReleaseMask | result = XGrabButton (display->xdisplay, i, ControlMask,
PointerMotionMask | PointerMotionHintMask, xwindow, False,
GrabModeAsync, GrabModeAsync, ButtonPressMask | ButtonReleaseMask |
False, None); PointerMotionMask | PointerMotionHintMask,
XSync (display->xdisplay, False); GrabModeAsync, GrabModeAsync,
result = meta_error_trap_pop (display); False, None);
XSync (display->xdisplay, False);
if (result != Success) result = meta_error_trap_pop (display);
meta_warning ("Failed to grab button %d with ControlMask for frame 0x%lx error code %d\n",
i, xwindow, result); if (result != Success)
#endif meta_warning ("Failed to grab button %d with ControlMask for frame 0x%lx error code %d\n",
i, xwindow, result);
}
++i; ++i;
} }

View File

@ -185,6 +185,11 @@ find_next_cascade (MetaWindow *window,
/* Find the leftmost, then topmost, empty area on the workspace /* Find the leftmost, then topmost, empty area on the workspace
* that can contain the new window. * that can contain the new window.
*
* Cool feature to have: if we can't fit the current window size,
* try shrinking the window (within geometry constraints). But
* beware windows such as Emacs with no sane minimum size, we
* don't want to create a 1x1 Emacs.
*/ */
static gboolean static gboolean
find_first_fit (MetaWindow *window, find_first_fit (MetaWindow *window,
@ -196,7 +201,7 @@ find_first_fit (MetaWindow *window,
int *new_x, int *new_x,
int *new_y) int *new_y)
{ {
/* FIXME */
} }
void void

View File

@ -525,6 +525,10 @@ set_clone_restart_commands (void)
SmcSetProperties (session_connection, 3, props); SmcSetProperties (session_connection, 3, props);
g_free (prop1.vals);
g_free (prop2.vals);
g_free (prop3.vals);
g_free (session_file); g_free (session_file);
} }

View File

@ -70,13 +70,22 @@ static gboolean process_property_notify (MetaWindow *window,
static void meta_window_show (MetaWindow *window); static void meta_window_show (MetaWindow *window);
static void meta_window_hide (MetaWindow *window); static void meta_window_hide (MetaWindow *window);
static void meta_window_move_resize_internal (MetaWindow *window, static void adjust_for_gravity (MetaWindow *window,
gboolean is_configure_request, MetaFrameGeometry *fgeom,
int resize_gravity, gboolean coords_assume_border,
int root_x_nw, int x,
int root_y_nw, int y,
int w, int *xp,
int h); int *yp);
static void meta_window_move_resize_internal (MetaWindow *window,
gboolean is_configure_request,
gboolean do_gravity_adjust,
int resize_gravity,
int root_x_nw,
int root_y_nw,
int w,
int h);
void meta_window_move_resize_now (MetaWindow *window); void meta_window_move_resize_now (MetaWindow *window);
@ -446,7 +455,7 @@ meta_window_new (MetaDisplay *display, Window xwindow,
* passing TRUE for is_configure_request, ICCCM says * passing TRUE for is_configure_request, ICCCM says
* initial map is handled same as configure request * initial map is handled same as configure request
*/ */
meta_window_move_resize_internal (window, TRUE, meta_window_move_resize_internal (window, TRUE, FALSE,
NorthWestGravity, NorthWestGravity,
window->size_hints.x, window->size_hints.x,
window->size_hints.y, window->size_hints.y,
@ -522,7 +531,7 @@ meta_window_apply_session_info (MetaWindow *window,
* indeed valid, so we know we'll go right back to one. * indeed valid, so we know we'll go right back to one.
*/ */
while (window->workspaces) while (window->workspaces)
meta_workspace_remove_window (window->workspaces->next->data, window); meta_workspace_remove_window (window->workspaces->data, window);
tmp = spaces; tmp = spaces;
while (tmp != NULL) while (tmp != NULL)
@ -543,6 +552,32 @@ meta_window_apply_session_info (MetaWindow *window,
g_slist_free (spaces); g_slist_free (spaces);
} }
} }
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;
meta_verbose ("Restoring pos %d,%d size %d x %d for %s\n",
x, y, w, h, window->desc);
meta_window_move_resize_internal (window,
FALSE, TRUE,
NorthWestGravity,
x, y, w, h);
}
} }
void void
@ -1020,7 +1055,7 @@ meta_window_unshade (MetaWindow *window)
/* returns values suitable for meta_window_move */ /* returns values suitable for meta_window_move */
void static void
adjust_for_gravity (MetaWindow *window, adjust_for_gravity (MetaWindow *window,
MetaFrameGeometry *fgeom, MetaFrameGeometry *fgeom,
gboolean coords_assume_border, gboolean coords_assume_border,
@ -1155,6 +1190,8 @@ adjust_for_gravity (MetaWindow *window,
static void static void
meta_window_move_resize_internal (MetaWindow *window, meta_window_move_resize_internal (MetaWindow *window,
gboolean is_configure_request, gboolean is_configure_request,
/* only relevant if !is_configure_request */
gboolean do_gravity_adjust,
int resize_gravity, int resize_gravity,
int root_x_nw, int root_x_nw,
int root_y_nw, int root_y_nw,
@ -1233,7 +1270,7 @@ meta_window_move_resize_internal (MetaWindow *window,
frame_size_dy = 0; frame_size_dy = 0;
} }
if (is_configure_request) if (is_configure_request || do_gravity_adjust)
{ {
adjust_for_gravity (window, adjust_for_gravity (window,
window->frame ? &fgeom : NULL, window->frame ? &fgeom : NULL,
@ -1424,7 +1461,7 @@ meta_window_resize (MetaWindow *window,
meta_window_get_position (window, &x, &y); meta_window_get_position (window, &x, &y);
meta_window_move_resize_internal (window, FALSE, meta_window_move_resize_internal (window, FALSE, FALSE,
NorthWestGravity, NorthWestGravity,
x, y, w, h); x, y, w, h);
} }
@ -1434,7 +1471,7 @@ meta_window_move (MetaWindow *window,
int root_x_nw, int root_x_nw,
int root_y_nw) int root_y_nw)
{ {
meta_window_move_resize_internal (window, FALSE, meta_window_move_resize_internal (window, FALSE, FALSE,
NorthWestGravity, NorthWestGravity,
root_x_nw, root_y_nw, root_x_nw, root_y_nw,
window->rect.width, window->rect.width,
@ -1448,7 +1485,7 @@ meta_window_move_resize (MetaWindow *window,
int w, int w,
int h) int h)
{ {
meta_window_move_resize_internal (window, FALSE, meta_window_move_resize_internal (window, FALSE, FALSE,
NorthWestGravity, NorthWestGravity,
root_x_nw, root_y_nw, root_x_nw, root_y_nw,
w, h); w, h);
@ -1464,7 +1501,7 @@ meta_window_resize_with_gravity (MetaWindow *window,
meta_window_get_position (window, &x, &y); meta_window_get_position (window, &x, &y);
meta_window_move_resize_internal (window, FALSE, meta_window_move_resize_internal (window, FALSE, FALSE,
gravity, gravity,
x, y, w, h); x, y, w, h);
} }
@ -1579,6 +1616,21 @@ meta_window_get_gravity_position (MetaWindow *window,
*root_y = y; *root_y = y;
} }
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;
}
void void
meta_window_get_outer_rect (MetaWindow *window, meta_window_get_outer_rect (MetaWindow *window,
MetaRectangle *rect) MetaRectangle *rect)
@ -1874,7 +1926,7 @@ meta_window_configure_request (MetaWindow *window,
window->size_hints.width = width; window->size_hints.width = width;
window->size_hints.height = height; window->size_hints.height = height;
meta_window_move_resize_internal (window, TRUE, meta_window_move_resize_internal (window, TRUE, FALSE,
NorthWestGravity, NorthWestGravity,
window->size_hints.x, window->size_hints.x,
window->size_hints.y, window->size_hints.y,

View File

@ -257,6 +257,14 @@ void meta_window_get_position (MetaWindow *window,
void meta_window_get_gravity_position (MetaWindow *window, void meta_window_get_gravity_position (MetaWindow *window,
int *x, int *x,
int *y); int *y);
/* Get geometry for saving in the session; x/y are gravity
* position, and w/h are in resize inc above the base size.
*/
void meta_window_get_geometry (MetaWindow *window,
int *x,
int *y,
int *width,
int *height);
void meta_window_get_outer_rect (MetaWindow *window, void meta_window_get_outer_rect (MetaWindow *window,
MetaRectangle *rect); MetaRectangle *rect);
void meta_window_delete (MetaWindow *window, void meta_window_delete (MetaWindow *window,