diff --git a/ChangeLog b/ChangeLog index 62509e189..62941bb19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-02-19 Havoc Pennington + + * src/ui.c (meta_ui_init): put in hack to keep Pango from mangling + our server grab and locking up on startup. (hack doesn't work + but I want to fix it on my real computer not this laptop) + + * src/window.c: Implement _NET_WM_STATE_FULLSCREEN + + * src/display.c (meta_display_open): add atoms for + _NET_WM_STATE_FULLSCREEN + 2002-02-16 Kjartan Maraas * src/main.c: Use bind_textdomain_codeset etc. diff --git a/src/display.c b/src/display.c index afda00afa..65a282220 100644 --- a/src/display.c +++ b/src/display.c @@ -146,7 +146,8 @@ meta_display_open (const char *name) "_METACITY_SET_KEYBINDINGS_MESSAGE", "_NET_WM_STATE_HIDDEN", "_NET_WM_WINDOW_TYPE_UTILITY", - "_NET_WM_WINDOW_TYPE_SPLASHSCREEN" + "_NET_WM_WINDOW_TYPE_SPLASHSCREEN", + "_NET_WM_STATE_FULLSCREEN" }; Atom atoms[G_N_ELEMENTS(atom_names)]; @@ -247,6 +248,7 @@ meta_display_open (const char *name) display->atom_net_wm_state_hidden = atoms[49]; display->atom_net_wm_window_type_utility = atoms[50]; display->atom_net_wm_window_type_splashscreen = atoms[51]; + display->atom_net_wm_state_fullscreen = atoms[52]; /* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK, * created in screen_new diff --git a/src/display.h b/src/display.h index 71aa1d906..12c438124 100644 --- a/src/display.h +++ b/src/display.h @@ -111,6 +111,7 @@ struct _MetaDisplay Atom atom_net_wm_state_hidden; Atom atom_net_wm_window_type_utility; Atom atom_net_wm_window_type_splashscreen; + Atom atom_net_wm_state_fullscreen; /* This is the actual window from focus events, * not the one we last set diff --git a/src/screen.c b/src/screen.c index b75ccab27..010413dd2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -78,7 +78,7 @@ set_wm_check_hint (MetaScreen *screen) static int set_supported_hint (MetaScreen *screen) { -#define N_SUPPORTED 26 +#define N_SUPPORTED 27 #define N_WIN_SUPPORTED 1 Atom atoms[N_SUPPORTED]; @@ -108,6 +108,7 @@ set_supported_hint (MetaScreen *screen) atoms[23] = screen->display->atom_net_wm_state_hidden; atoms[24] = screen->display->atom_net_wm_window_type_utility; atoms[25] = screen->display->atom_net_wm_window_type_splashscreen; + atoms[26] = screen->display->atom_net_wm_state_fullscreen; XChangeProperty (screen->display->xdisplay, screen->xroot, screen->display->atom_net_supported, diff --git a/src/ui.c b/src/ui.c index 11f78667e..fdeb5c5bf 100644 --- a/src/ui.c +++ b/src/ui.c @@ -29,6 +29,8 @@ #include "inlinepixbufs.h" +#include + struct _MetaUI { Display *xdisplay; @@ -42,14 +44,13 @@ meta_ui_init (int *argc, char ***argv) if (!gtk_init_check (argc, argv)) meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL)); - { - /* FIXME this is a hackaround for a GTK bug with using menus without - * menubars. we have to use the get_type value since it's G_GNUC_CONST - */ - volatile GType t; - t = gtk_menu_bar_get_type (); - t += 5; - } + /* FIXME hackaround for Pango opening a separate display + * connection and doing a server grab while we have a grab + * on the primary display connection. This forces Pango to + * go ahead and do its font cache before we try to grab + * the server. + */ + pango_x_font_map_for_display (gdk_display); } Display* diff --git a/src/window.c b/src/window.c index 1dbfc1f32..59dc12726 100644 --- a/src/window.c +++ b/src/window.c @@ -309,6 +309,7 @@ meta_window_new (MetaDisplay *display, Window xwindow, window->user_has_move_resized = FALSE; window->maximized = FALSE; + window->fullscreen = FALSE; window->on_all_workspaces = FALSE; window->shaded = FALSE; window->initially_iconic = FALSE; @@ -348,6 +349,8 @@ meta_window_new (MetaDisplay *display, Window xwindow, window->has_resize_func = TRUE; window->has_shade_func = TRUE; + + window->has_fullscreen_func = TRUE; window->wm_state_modal = FALSE; window->wm_state_skip_taskbar = FALSE; @@ -839,6 +842,11 @@ set_net_wm_state (MetaWindow *window) data[i] = window->display->atom_net_wm_state_maximized_vert; ++i; } + if (window->fullscreen) + { + data[i] = window->display->atom_net_wm_state_fullscreen; + ++i; + } if (window->shaded || window->minimized) { data[i] = window->display->atom_net_wm_state_hidden; @@ -1289,6 +1297,7 @@ meta_window_maximize (MetaWindow *window) window->maximized = TRUE; + /* FIXME why did I put this here? */ meta_window_raise (window); /* save size/pos as appropriate args for move_resize */ @@ -1328,6 +1337,57 @@ meta_window_unmaximize (MetaWindow *window) } } + +void +meta_window_make_fullscreen (MetaWindow *window) +{ + if (!window->fullscreen) + { + meta_topic (META_DEBUG_WINDOW_OPS, + "Fullscreening %s\n", window->desc); + + window->fullscreen = TRUE; + + /* FIXME why did I put this here? */ + meta_window_raise (window); + + /* save size/pos as appropriate args for move_resize */ + window->saved_rect = window->rect; + if (window->frame) + { + window->saved_rect.x += window->frame->rect.x; + window->saved_rect.y += window->frame->rect.y; + } + + /* move_resize with new constraints + */ + meta_window_queue_move_resize (window); + + set_net_wm_state (window); + } +} + +void +meta_window_unmake_fullscreen (MetaWindow *window) +{ + if (window->fullscreen) + { + meta_topic (META_DEBUG_WINDOW_OPS, + "Unfullscreening %s\n", window->desc); + + window->fullscreen = FALSE; + + meta_window_move_resize (window, + TRUE, + window->saved_rect.x, + window->saved_rect.y, + window->saved_rect.width, + window->saved_rect.height); + + set_net_wm_state (window); + } +} + void meta_window_shade (MetaWindow *window) { @@ -2825,6 +2885,19 @@ meta_window_client_message (MetaWindow *window, meta_window_unshade (window); } + if (first == display->atom_net_wm_state_fullscreen || + second == display->atom_net_wm_state_fullscreen) + { + gboolean make_fullscreen; + + make_fullscreen = (action == _NET_WM_STATE_ADD || + (action == _NET_WM_STATE_TOGGLE && !window->fullscreen)); + if (make_fullscreen && window->has_fullscreen_func) + meta_window_make_fullscreen (window); + else + meta_window_unmake_fullscreen (window); + } + if (first == display->atom_net_wm_state_maximized_horz || second == display->atom_net_wm_state_maximized_horz || first == display->atom_net_wm_state_maximized_vert || @@ -4517,7 +4590,8 @@ recalc_window_features (MetaWindow *window) window->has_resize_func = window->mwm_has_resize_func; window->has_shade_func = TRUE; - + window->has_fullscreen_func = TRUE; + /* Semantic category overrides the MWM hints */ if (window->type == META_WINDOW_DESKTOP || @@ -4535,6 +4609,7 @@ recalc_window_features (MetaWindow *window) { window->has_minimize_func = FALSE; window->has_maximize_func = FALSE; + window->has_fullscreen_func = FALSE; } /* If min_size == max_size, then don't allow resize */ @@ -4542,9 +4617,12 @@ recalc_window_features (MetaWindow *window) window->size_hints.min_height == window->size_hints.max_height) window->has_resize_func = FALSE; - /* don't allow maximize if we can't resize */ + /* don't allow fullscreen if we can't resize */ if (!window->has_resize_func) - window->has_maximize_func = FALSE; + { + window->has_maximize_func = FALSE; + window->has_fullscreen_func = FALSE; + } /* no shading if not decorated */ if (!window->decorated) @@ -4582,7 +4660,8 @@ constrain_size (MetaWindow *window, meta_window_get_work_area (window, &work_area); /* Get the allowed size ranges, considering maximized, etc. */ - if (window->type == META_WINDOW_DESKTOP || + if (window->fullscreen || + window->type == META_WINDOW_DESKTOP || window->type == META_WINDOW_DOCK) { fullw = window->screen->width; @@ -4594,7 +4673,7 @@ constrain_size (MetaWindow *window, fullh = work_area.height; } - if (window->frame) + if (window->frame && !window->fullscreen) { fullw -= (fgeom->left_width + fgeom->right_width); fullh -= (fgeom->top_height + fgeom->bottom_height); @@ -4708,15 +4787,13 @@ constrain_position (MetaWindow *window, if (!window->placed && window->calc_placement) meta_window_place (window, fgeom, x, y, &x, &y); -#if 0 if (window->fullscreen) { x = 0; y = 0; } -#endif - if (window->type != META_WINDOW_DESKTOP && - window->type != META_WINDOW_DOCK) + else if (window->type != META_WINDOW_DESKTOP && + window->type != META_WINDOW_DOCK) { int nw_x, nw_y; int se_x, se_y; diff --git a/src/window.h b/src/window.h index 2cbf25c2e..c7dde93a7 100644 --- a/src/window.h +++ b/src/window.h @@ -87,6 +87,9 @@ struct _MetaWindow /* Whether we're shaded */ guint shaded : 1; + /* Whether we're fullscreen */ + guint fullscreen : 1; + /* Whether we're sticky in the multi-workspace sense * (vs. the not-scroll-with-viewport sense, we don't * have no stupid viewports) @@ -135,6 +138,7 @@ struct _MetaWindow guint has_shade_func : 1; guint has_move_func : 1; guint has_resize_func : 1; + guint has_fullscreen_func : 1; /* Weird "_NET_WM_STATE_MODAL" flag */ guint wm_state_modal : 1; @@ -253,6 +257,8 @@ void meta_window_unstick (MetaWindow *window); void meta_window_activate (MetaWindow *window, guint32 current_time); +void meta_window_make_fullscreen (MetaWindow *window); +void meta_window_unmake_fullscreen (MetaWindow *window); /* args to move are window pos, not frame pos */ void meta_window_move (MetaWindow *window,