+/* Check if we need to resize the frame due to a fullscreen request.
+ If so needed, resize the frame. */
+static void
+x_check_fullscreen (f)
+ struct frame *f;
+{
+ if (f->output_data.x->want_fullscreen & FULLSCREEN_BOTH)
+ {
+ int width, height, ign;
+
+ x_real_positions (f, &f->output_data.x->left_pos,
+ &f->output_data.x->top_pos);
+
+ x_fullscreen_adjust (f, &width, &height, &ign, &ign);
+
+ /* 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. */
+ if (f->width != width || f->height != height)
+ {
+ change_frame_size (f, height, width, 0, 1, 0);
+ SET_FRAME_GARBAGED (f);
+ cancel_mouse_face (f);
+
+ /* Wait for the change of frame size to occur */
+ f->output_data.x->want_fullscreen |= FULLSCREEN_WAIT;
+
+ }
+ }
+}
+
+/* If frame parameters are set after the frame is mapped, we need to move
+ the window. This is done in xfns.c.
+ 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)
+ struct frame *f;
+{
+ if (f->output_data.x->want_fullscreen & FULLSCREEN_MOVE_WAIT)
+ {
+ int expect_top = f->output_data.x->top_pos;
+ int expect_left = f->output_data.x->left_pos;
+
+ if (f->output_data.x->want_fullscreen & FULLSCREEN_HEIGHT)
+ expect_top = 0;
+ if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
+ expect_left = 0;
+
+ if (expect_top != f->output_data.x->top_pos
+ || expect_left != f->output_data.x->left_pos)
+ x_set_offset (f, expect_left, expect_top, 1);
+
+ /* Just do this once */
+ f->output_data.x->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
+ }
+}
+
+
+/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
+ wanted positions of the WM window (not emacs window).
+ Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
+ window (FRAME_X_WINDOW).
+ */
+void
+x_fullscreen_adjust (f, width, height, top_pos, left_pos)
+ struct frame *f;
+ int *width;
+ int *height;
+ int *top_pos;
+ int *left_pos;
+{
+ int newwidth = f->width, newheight = f->height;
+
+ *top_pos = f->output_data.x->top_pos;
+ *left_pos = f->output_data.x->left_pos;
+
+ if (f->output_data.x->want_fullscreen & FULLSCREEN_HEIGHT)
+ {
+ int ph;
+
+ ph = FRAME_X_DISPLAY_INFO (f)->height;
+ newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
+ ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
+ - f->output_data.x->y_pixels_diff;
+ newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
+ *top_pos = 0;
+ }
+
+ if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
+ {
+ int pw;
+
+ pw = FRAME_X_DISPLAY_INFO (f)->width;
+ newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
+ pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
+ - f->output_data.x->x_pixels_diff;
+ newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
+ *left_pos = 0;
+ }
+
+ *width = newwidth;
+ *height = newheight;
+}
+