Make (modify-frame-parameters nil '((top . 0))) work for all types

of window managers in X.
This commit is contained in:
Jan Djärv 2003-10-05 11:52:47 +00:00
parent f5379f1fc3
commit c1f0671ae9
4 changed files with 81 additions and 24 deletions

View file

@ -1,3 +1,23 @@
2003-10-05 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
* xterm.h (struct x_display_info): New member, wm_type.
(struct x_output): New members, expected_top/left and
check_expected_move.
* xterm.c (handle_one_xevent): Reset wm_type when ReparentNotify
is received.
(handle_one_xevent): x_check_expected_move renamed from
x_check_fullscreen_move
(x_set_offset): Only add WM decoration sizes to modified_top/left
for X_WMTYPE_A. Set check_expected_move when WM type is unknown.
(x_check_expected_move): Renamed from x_check_fullscreen_move.
Removed fullscreen specific code. Use check_expected_move,
expected_left/top instead. Also, set wm_type.
(x_term_init): Initialize wm_type to unknown.
* frame.c (x_fullscreen_move): Remove addition of WM decoration
sizes to move_x/y.
2003-10-03 Kenichi Handa <handa@m17n.org>
* macterm.c (x_load_font): Clear all members of FONTP before start

View file

@ -2607,12 +2607,10 @@ x_fullscreen_move (f, new_top, new_left)
int move_x = new_left;
int move_y = new_top;
#ifdef HAVE_X_WINDOWS
move_x += FRAME_X_OUTPUT (f)->x_pixels_outer_diff;
move_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
#ifndef HAVE_X_WINDOWS
f->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
#endif
f->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
x_set_offset (f, move_x, move_y, 1);
}
}

View file

@ -362,7 +362,7 @@ static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
Lisp_Object *, Lisp_Object *,
unsigned long *));
static void x_check_fullscreen P_ ((struct frame *));
static void x_check_fullscreen_move P_ ((struct frame *));
static void x_check_expected_move P_ ((struct frame *));
static int handle_one_xevent P_ ((struct x_display_info *,
XEvent *,
struct input_event **,
@ -5990,6 +5990,9 @@ handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish)
x_real_positions (f, &x, &y);
f->left_pos = x;
f->top_pos = y;
/* Perhaps reparented due to a WM restart. Reset this. */
FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN;
}
goto OTHER;
break;
@ -6767,7 +6770,7 @@ handle_one_xevent (dpyinfo, eventp, bufp_r, numcharsp, finish)
Convert that to the position of the window manager window. */
x_real_positions (f, &f->left_pos, &f->top_pos);
x_check_fullscreen_move (f);
x_check_expected_move (f);
if (f->want_fullscreen & FULLSCREEN_WAIT)
f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
}
@ -8320,8 +8323,6 @@ x_set_offset (f, xoff, yoff, change_gravity)
modified_left = f->left_pos;
modified_top = f->top_pos;
modified_left += FRAME_X_OUTPUT (f)->x_pixels_outer_diff;
modified_top += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
#if 0 /* Running on psilocin (Debian), and displaying on the NCD X-terminal,
this seems to be unnecessary and incorrect. rms, 4/17/97. */
@ -8334,8 +8335,23 @@ x_set_offset (f, xoff, yoff, change_gravity)
}
#endif
if (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_A)
{
modified_left += FRAME_X_OUTPUT (f)->x_pixels_outer_diff;
modified_top += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
}
XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
modified_left, modified_top);
if (FRAME_VISIBLE_P (f)
&& FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN)
{
FRAME_X_OUTPUT (f)->check_expected_move = 1;
FRAME_X_OUTPUT (f)->expected_top = f->top_pos;
FRAME_X_OUTPUT (f)->expected_left = f->left_pos;
}
UNBLOCK_INPUT;
}
@ -8356,7 +8372,7 @@ x_check_fullscreen (f)
/* We do not need to move the window, it shall be taken care of
when setting WM manager hints.
If the frame is visible already, the position is checked by
x_check_fullscreen_move. */
x_check_expected_move. */
if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
{
change_frame_size (f, height, width, 0, 1, 0);
@ -8370,30 +8386,31 @@ x_check_fullscreen (f)
}
/* If frame parameters are set after the frame is mapped, we need to move
the window. This is done in xfns.c.
the window.
Some window managers moves the window to the right position, some
moves the outer window manager window to the specified position.
Here we check that we are in the right spot. If not, make a second
move, assuming we are dealing with the second kind of window manager. */
static void
x_check_fullscreen_move (f)
x_check_expected_move (f)
struct frame *f;
{
if (f->want_fullscreen & FULLSCREEN_MOVE_WAIT)
if (FRAME_X_OUTPUT (f)->check_expected_move)
{
int expect_top = f->top_pos;
int expect_left = f->left_pos;
if (f->want_fullscreen & FULLSCREEN_HEIGHT)
expect_top = 0;
if (f->want_fullscreen & FULLSCREEN_WIDTH)
expect_left = 0;
int expect_top = FRAME_X_OUTPUT (f)->expected_top;
int expect_left = FRAME_X_OUTPUT (f)->expected_left;
if (expect_top != f->top_pos || expect_left != f->left_pos)
x_set_offset (f, expect_left, expect_top, 1);
{
if (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN)
FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_A;
x_set_offset (f, expect_left, expect_top, 1);
}
else if (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN)
FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_B;
/* Just do this once */
f->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
FRAME_X_OUTPUT (f)->check_expected_move = 0;
}
}
@ -10398,6 +10415,7 @@ x_term_init (display_name, xrm_option, resource_name)
dpyinfo->x_focus_event_frame = 0;
dpyinfo->x_highlight_frame = 0;
dpyinfo->image_cache = make_image_cache ();
dpyinfo->wm_type = X_WMTYPE_UNKNOWN;
/* See if we can construct pixel values from RGB values. */
dpyinfo->red_bits = dpyinfo->blue_bits = dpyinfo->green_bits = 0;

View file

@ -361,10 +361,22 @@ struct x_display_info
XColor *color_cells;
int ncolor_cells;
/* Bits and shifts to use to compose pixel values on Direct and TrueColor
visuals. */
/* Bits and shifts to use to compose pixel values on TrueColor visuals. */
int red_bits, blue_bits, green_bits;
int red_offset, blue_offset, green_offset;
/* The type of window manager we have. If we move FRAME_OUTER_WINDOW
to x/y 0/0, some window managers (type A) puts the window manager
decorations outside the screen and FRAME_OUTER_WINDOW exactly at 0/0.
Other window managers (type B) puts the window including decorations
at 0/0, so FRAME_OUTER_WINDOW is a bit below 0/0.
Record the type of WM in use so we can compensate for type A WMs. */
enum
{
X_WMTYPE_UNKNOWN,
X_WMTYPE_A,
X_WMTYPE_B
} wm_type;
};
#ifdef HAVE_X_I18N
@ -611,6 +623,15 @@ struct x_output
frame, or IMPLICIT if we received an EnterNotify.
FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
int focus_state;
/* The latest move we made to FRAME_OUTER_WINDOW. Saved so we can
compensate for type A WMs (see wm_type in dpyinfo above. */
int expected_top;
int expected_left;
/* Nonzero if we have made a move and needs to check if the WM placed us
at the right position. */
int check_expected_move;
};
#define No_Cursor (None)