This commit is contained in:
rhp 2001-06-08 02:17:48 +00:00
parent 0feac37c5b
commit a6b2edc467
7 changed files with 278 additions and 98 deletions

View File

@ -158,6 +158,12 @@ meta_display_open (const char *name)
display->atom_wm_state = atoms[4]; display->atom_wm_state = atoms[4];
display->atom_net_close_window = atoms[5]; display->atom_net_close_window = atoms[5];
display->double_click_time = 250;
display->last_button_time = 0;
display->last_button_xwindow = None;
display->last_button_num = 0;
display->is_double_click = FALSE;
/* Now manage all existing windows */ /* Now manage all existing windows */
tmp = display->screens; tmp = display->screens;
while (tmp != NULL) while (tmp != NULL)
@ -335,6 +341,12 @@ meta_displays_list (void)
return all_displays; return all_displays;
} }
gboolean
meta_display_is_double_click (MetaDisplay *display)
{
return display->is_double_click;
}
static gboolean dump_events = TRUE; static gboolean dump_events = TRUE;
static void static void
@ -351,6 +363,26 @@ event_queue_callback (MetaEventQueue *queue,
if (dump_events) if (dump_events)
meta_spew_event (display, event); meta_spew_event (display, event);
/* mark double click events, kind of a hack, oh well. */
if (event->type == ButtonPress)
{
if (event->xbutton.button == display->last_button_num &&
event->xbutton.window == display->last_button_xwindow &&
event->xbutton.time < (display->last_button_time + display->double_click_time))
{
display->is_double_click = TRUE;
meta_verbose ("This was the second click of a double click\n");
}
else
{
display->is_double_click = FALSE;
}
display->last_button_num = event->xbutton.button;
display->last_button_xwindow = event->xbutton.window;
display->last_button_time = event->xbutton.time;
}
modified = event_get_modified_window (display, event); modified = event_get_modified_window (display, event);
if (modified != None) if (modified != None)

View File

@ -59,6 +59,13 @@ struct _MetaDisplay
GHashTable *window_ids; GHashTable *window_ids;
GSList *error_traps; GSList *error_traps;
int server_grab_count; int server_grab_count;
/* for double click */
int double_click_time;
Time last_button_time;
Window last_button_xwindow;
int last_button_num;
guint is_double_click : 1;
}; };
gboolean meta_display_open (const char *name); gboolean meta_display_open (const char *name);
@ -70,6 +77,7 @@ MetaScreen* meta_display_screen_for_x_screen (MetaDisplay *display,
void meta_display_grab (MetaDisplay *display); void meta_display_grab (MetaDisplay *display);
void meta_display_ungrab (MetaDisplay *display); void meta_display_ungrab (MetaDisplay *display);
PangoContext* meta_display_get_pango_context (MetaDisplay *display); PangoContext* meta_display_get_pango_context (MetaDisplay *display);
gboolean meta_display_is_double_click (MetaDisplay *display);
/* A given MetaWindow may have various X windows that "belong" /* A given MetaWindow may have various X windows that "belong"
* to it, such as the frame window. * to it, such as the frame window.

View File

@ -44,7 +44,6 @@ struct _MetaFrameActionGrab
PointerMotionMask | PointerMotionHintMask | \ PointerMotionMask | PointerMotionHintMask | \
EnterWindowMask | LeaveWindowMask) EnterWindowMask | LeaveWindowMask)
static void clear_tip (MetaFrame *frame); static void clear_tip (MetaFrame *frame);
static void static void
@ -59,6 +58,9 @@ meta_frame_init_info (MetaFrame *frame,
if (frame->window->has_focus) if (frame->window->has_focus)
info->flags |= META_FRAME_HAS_FOCUS; info->flags |= META_FRAME_HAS_FOCUS;
if (frame->window->shaded)
info->flags |= META_FRAME_SHADED;
info->drawable = None; info->drawable = None;
info->xoffset = 0; info->xoffset = 0;
info->yoffset = 0; info->yoffset = 0;
@ -147,6 +149,10 @@ meta_frame_calc_geometry (MetaFrame *frame,
window = frame->window; window = frame->window;
frame->rect.width = child_width; frame->rect.width = child_width;
if (window->shaded)
frame->rect.height = 0;
else
frame->rect.height = child_height; frame->rect.height = child_height;
meta_frame_init_info (frame, &info); meta_frame_init_info (frame, &info);
@ -194,6 +200,7 @@ set_background_none (MetaFrame *frame)
CWBackPixmap, CWBackPixmap,
&attrs); &attrs);
#if 0
meta_debug_spew ("Frame size %d,%d %dx%d window size %d,%d %dx%d window pos %d,%d\n", meta_debug_spew ("Frame size %d,%d %dx%d window size %d,%d %dx%d window pos %d,%d\n",
frame->rect.x, frame->rect.x,
frame->rect.y, frame->rect.y,
@ -205,6 +212,7 @@ set_background_none (MetaFrame *frame)
frame->window->rect.height, frame->window->rect.height,
frame->child_x, frame->child_x,
frame->child_y); frame->child_y);
#endif
} }
static void static void
@ -768,7 +776,23 @@ meta_frame_event (MetaFrame *frame,
MetaFrameControl control; MetaFrameControl control;
control = frame->current_control; control = frame->current_control;
if (((control == META_FRAME_CONTROL_TITLE || if (control == META_FRAME_CONTROL_TITLE &&
event->xbutton.button == 1 &&
meta_display_is_double_click (frame->window->display))
{
meta_verbose ("Double click on title\n");
/* FIXME this catches double click that starts elsewhere
* with the second click on title, maybe no one will
* ever notice
*/
if (frame->window->shaded)
meta_window_unshade (frame->window);
else
meta_window_shade (frame->window);
}
else if (((control == META_FRAME_CONTROL_TITLE ||
control == META_FRAME_CONTROL_NONE) && control == META_FRAME_CONTROL_NONE) &&
event->xbutton.button == 1) || event->xbutton.button == 1) ||
event->xbutton.button == 2) event->xbutton.button == 2)

View File

@ -191,12 +191,19 @@ calc_geometry (MetaFrameInfo *info,
int x; int x;
int button_y; int button_y;
int title_right_edge; int title_right_edge;
gboolean shaded;
shaded = (info->flags & META_FRAME_SHADED) != 0;
fgeom->top_height = MAX (d->layout_height + VERTICAL_TEXT_PAD * 2 + ABOVE_TITLE_PAD + BELOW_TITLE_PAD, fgeom->top_height = MAX (d->layout_height + VERTICAL_TEXT_PAD * 2 + ABOVE_TITLE_PAD + BELOW_TITLE_PAD,
BUTTON_HEIGHT + BUTTON_PAD * 2); BUTTON_HEIGHT + BUTTON_PAD * 2);
fgeom->left_width = LEFT_WIDTH; fgeom->left_width = LEFT_WIDTH;
fgeom->right_width = RIGHT_WIDTH; fgeom->right_width = RIGHT_WIDTH;
if (shaded)
fgeom->bottom_height = 0;
else
fgeom->bottom_height = BOTTOM_HEIGHT; fgeom->bottom_height = BOTTOM_HEIGHT;
x = info->width - fgeom->right_width; x = info->width - fgeom->right_width;

View File

@ -41,7 +41,8 @@ typedef enum
META_FRAME_ALLOWS_MAXIMIZE = 1 << 3, META_FRAME_ALLOWS_MAXIMIZE = 1 << 3,
META_FRAME_ALLOWS_RESIZE = 1 << 4, META_FRAME_ALLOWS_RESIZE = 1 << 4,
META_FRAME_TRANSIENT = 1 << 5, META_FRAME_TRANSIENT = 1 << 5,
META_FRAME_HAS_FOCUS = 1 << 6 META_FRAME_HAS_FOCUS = 1 << 6,
META_FRAME_SHADED = 1 << 7
} MetaFrameFlags; } MetaFrameFlags;
typedef enum typedef enum

View File

@ -143,6 +143,7 @@ meta_window_new (MetaDisplay *display, Window xwindow)
window->has_focus = FALSE; window->has_focus = FALSE;
window->maximized = FALSE; window->maximized = FALSE;
window->shaded = FALSE;
window->initially_iconic = FALSE; window->initially_iconic = FALSE;
window->minimized = FALSE; window->minimized = FALSE;
window->iconic = FALSE; window->iconic = FALSE;
@ -281,18 +282,29 @@ meta_window_queue_calc_showing (MetaWindow *window)
void void
meta_window_show (MetaWindow *window) meta_window_show (MetaWindow *window)
{ {
meta_verbose ("Showing window %s\n", window->desc); meta_verbose ("Showing window %s, shaded: %d iconic: %d\n",
window->desc, window->shaded, window->iconic);
/* Shaded means the frame is mapped but the window is not */
if (window->frame) if (window->frame)
XMapWindow (window->display->xdisplay, window->frame->xwindow); XMapWindow (window->display->xdisplay, window->frame->xwindow);
XMapWindow (window->display->xdisplay, window->xwindow);
/* These flags aren't always in sync, iconic if (window->shaded)
* is set only here in show/hide, mapped {
* can be set in a couple other places where window->mapped = FALSE;
* we map/unmap. So that's why both flags exist. XUnmapWindow (window->display->xdisplay, window->xwindow);
*/
if (!window->iconic)
{
window->iconic = TRUE;
set_wm_state (window, IconicState);
}
}
else
{
window->mapped = TRUE; window->mapped = TRUE;
XMapWindow (window->display->xdisplay, window->xwindow);
if (window->iconic) if (window->iconic)
{ {
@ -300,6 +312,7 @@ meta_window_show (MetaWindow *window)
set_wm_state (window, NormalState); set_wm_state (window, NormalState);
} }
} }
}
void void
meta_window_hide (MetaWindow *window) meta_window_hide (MetaWindow *window)
@ -348,7 +361,7 @@ meta_window_maximize (MetaWindow *window)
window->maximized = TRUE; window->maximized = TRUE;
/* save size */ /* save size/pos */
window->saved_rect = window->rect; window->saved_rect = window->rect;
if (window->frame) if (window->frame)
{ {
@ -356,11 +369,7 @@ meta_window_maximize (MetaWindow *window)
window->saved_rect.y += window->frame->rect.y; window->saved_rect.y += window->frame->rect.y;
} }
/* resize to current size with new maximization constraint */ /* find top left corner */
meta_window_resize (window,
window->rect.width, window->rect.height);
/* move to top left corner */
x = window->screen->active_workspace->workarea.x; x = window->screen->active_workspace->workarea.x;
y = window->screen->active_workspace->workarea.y; y = window->screen->active_workspace->workarea.y;
if (window->frame) if (window->frame)
@ -369,7 +378,13 @@ meta_window_maximize (MetaWindow *window)
y += window->frame->child_y; y += window->frame->child_y;
} }
meta_window_move (window, x, y);
/* resize to current size with new maximization constraint,
* and move to top-left corner
*/
meta_window_move_resize (window, x, y,
window->rect.width, window->rect.height);
} }
} }
@ -378,49 +393,68 @@ meta_window_unmaximize (MetaWindow *window)
{ {
if (window->maximized) if (window->maximized)
{ {
int x, y;
window->maximized = FALSE; window->maximized = FALSE;
meta_window_resize (window, meta_window_move_resize (window,
window->saved_rect.x,
window->saved_rect.y,
window->saved_rect.width, window->saved_rect.width,
window->saved_rect.height); window->saved_rect.height);
meta_window_move (window,
window->saved_rect.x,
window->saved_rect.y);
} }
} }
void void
meta_window_resize (MetaWindow *window, meta_window_shade (MetaWindow *window)
{
if (!window->shaded)
{
window->shaded = TRUE;
if (window->frame)
meta_frame_queue_recalc (window->frame);
meta_window_queue_calc_showing (window);
}
}
void
meta_window_unshade (MetaWindow *window)
{
if (window->shaded)
{
window->shaded = FALSE;
if (window->frame)
meta_frame_queue_recalc (window->frame);
meta_window_queue_calc_showing (window);
}
}
static void
meta_window_move_resize_internal (MetaWindow *window,
gboolean move,
gboolean resize,
int root_x_nw,
int root_y_nw,
int w, int w,
int h) int h)
{ {
if (resize)
meta_verbose ("Resizing %s to %d x %d\n", window->desc, w, h); meta_verbose ("Resizing %s to %d x %d\n", window->desc, w, h);
if (move)
meta_verbose ("Moving %s to %d,%d\n", window->desc,
root_x_nw, root_y_nw);
if (resize)
{
constrain_size (window, w, h, &w, &h); constrain_size (window, w, h, &w, &h);
meta_verbose ("Constrained resize of %s to %d x %d\n", window->desc, w, h); meta_verbose ("Constrained resize of %s to %d x %d\n", window->desc, w, h);
if (w == window->rect.width &&
h == window->rect.height)
resize = FALSE;
if (w != window->rect.width ||
h != window->rect.height)
{
meta_error_trap_push (window->display);
XResizeWindow (window->display->xdisplay,
window->xwindow,
w, h);
meta_error_trap_pop (window->display);
window->rect.width = w; window->rect.width = w;
window->rect.height = h; window->rect.height = h;
if (window->frame)
meta_frame_queue_recalc (window->frame);
}
} }
void if (move)
meta_window_move (MetaWindow *window,
int root_x_nw,
int root_y_nw)
{ {
if (window->frame) if (window->frame)
{ {
@ -429,37 +463,97 @@ meta_window_move (MetaWindow *window,
new_x = root_x_nw - window->frame->child_x; new_x = root_x_nw - window->frame->child_x;
new_y = root_y_nw - window->frame->child_y; new_y = root_y_nw - window->frame->child_y;
if (new_x != window->frame->rect.x || if (new_x == window->frame->rect.x &&
new_y != window->frame->rect.y) new_y == window->frame->rect.y)
{ move = FALSE;
window->frame->rect.x = new_x; window->frame->rect.x = new_x;
window->frame->rect.y = new_y; window->frame->rect.y = new_y;
/* window->rect.x, window->rect.y remain relative to frame, /* window->rect.x, window->rect.y remain relative to frame,
* remember they are the server coords * remember they are the server coords
*/ */
}
else
{
if (root_x_nw == window->rect.x &&
root_y_nw == window->rect.y)
move = FALSE;
window->rect.x = root_x_nw;
window->rect.y = root_y_nw;
}
}
/* Sync our new size/pos with X as efficiently as possible */
if (move && window->frame)
{
XMoveWindow (window->display->xdisplay, XMoveWindow (window->display->xdisplay,
window->frame->xwindow, window->frame->xwindow,
window->frame->rect.x, window->frame->rect.x,
window->frame->rect.y); window->frame->rect.y);
} }
}
else
{
if (root_x_nw != window->rect.x ||
root_y_nw != window->rect.y)
{
window->rect.x = root_x_nw;
window->rect.y = root_y_nw;
meta_error_trap_push (window->display);
if ((move && window->frame == NULL) && resize)
{
XMoveResizeWindow (window->display->xdisplay,
window->xwindow,
window->rect.x,
window->rect.y,
window->rect.width,
window->rect.height);
}
else if (move && window->frame == NULL)
{
XMoveWindow (window->display->xdisplay, XMoveWindow (window->display->xdisplay,
window->xwindow, window->xwindow,
window->rect.x, window->rect.x,
window->rect.y); window->rect.y);
} }
else if (resize)
{
XResizeWindow (window->display->xdisplay,
window->xwindow,
w, h);
}
meta_error_trap_pop (window->display);
if (move)
send_configure_notify (window);
if (window->frame && resize)
meta_frame_queue_recalc (window->frame);
} }
send_configure_notify (window); void
meta_window_resize (MetaWindow *window,
int w,
int h)
{
meta_window_move_resize_internal (window, FALSE, TRUE, -1, -1, w, h);
}
void
meta_window_move (MetaWindow *window,
int root_x_nw,
int root_y_nw)
{
meta_window_move_resize_internal (window, TRUE, FALSE,
root_x_nw, root_y_nw, -1, -1);
}
void
meta_window_move_resize (MetaWindow *window,
int root_x_nw,
int root_y_nw,
int w,
int h)
{
meta_window_move_resize_internal (window, TRUE, TRUE,
root_x_nw, root_y_nw,
w, h);
} }
void void

View File

@ -41,14 +41,20 @@ struct _MetaWindow
/* Whether we're maximized */ /* Whether we're maximized */
guint maximized : 1; guint maximized : 1;
/* Whether we're shaded */
guint shaded : 1;
/* Mapped is what we think the mapped state should be; /* Mapped is what we think the mapped state should be;
* so if we get UnmapNotify and mapped == TRUE then * so if we get UnmapNotify and mapped == TRUE then
* it's a withdraw, if mapped == FALSE the UnmapNotify * it's a withdraw, if mapped == FALSE the UnmapNotify
* is caused by us. * is caused by us.
*/ */
guint mapped : 1 ; guint mapped : 1 ;
/* Minimize is the state controlled by the minimize button */ /* Minimize is the state controlled by the minimize button */
guint minimized : 1; guint minimized : 1;
/* Iconic is the state in WM_STATE; happens for workspaces/shading /* Iconic is the state in WM_STATE; happens for workspaces/shading
* in addition to minimize * in addition to minimize
*/ */
@ -96,16 +102,24 @@ void meta_window_calc_showing (MetaWindow *window);
void meta_window_queue_calc_showing (MetaWindow *window); void meta_window_queue_calc_showing (MetaWindow *window);
void meta_window_minimize (MetaWindow *window); void meta_window_minimize (MetaWindow *window);
void meta_window_unminimize (MetaWindow *window); void meta_window_unminimize (MetaWindow *window);
void meta_window_resize (MetaWindow *window,
int w,
int h);
void meta_window_maximize (MetaWindow *window); void meta_window_maximize (MetaWindow *window);
void meta_window_unmaximize (MetaWindow *window); void meta_window_unmaximize (MetaWindow *window);
void meta_window_shade (MetaWindow *window);
void meta_window_unshade (MetaWindow *window);
/* args to move are window pos, not frame pos */ /* args to move are window pos, not frame pos */
void meta_window_move (MetaWindow *window, void meta_window_move (MetaWindow *window,
int root_x_nw, int root_x_nw,
int root_y_nw); int root_y_nw);
void meta_window_resize (MetaWindow *window,
int w,
int h);
void meta_window_move_resize (MetaWindow *window,
int root_x_nw,
int root_y_nw,
int w,
int h);
void meta_window_delete (MetaWindow *window, void meta_window_delete (MetaWindow *window,
Time timestamp); Time timestamp);
void meta_window_focus (MetaWindow *window, void meta_window_focus (MetaWindow *window,