This commit is contained in:
rhp 2001-06-20 03:01:26 +00:00
parent 5fd26a273d
commit ca69bef032
13 changed files with 220 additions and 50 deletions

View File

@ -72,7 +72,6 @@ meta_core_queue_frame_resize (Display *xdisplay,
if (window == NULL || window->frame == NULL) if (window == NULL || window->frame == NULL)
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow); meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
meta_window_queue_move_resize (window);
g_warning ("FIXME");
} }

View File

@ -31,11 +31,14 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <string.h> #include <string.h>
#define USE_GDK_DISPLAY
static GSList *all_displays = NULL; static GSList *all_displays = NULL;
static void meta_spew_event (MetaDisplay *display, static void meta_spew_event (MetaDisplay *display,
XEvent *event); XEvent *event);
static void event_queue_callback (MetaEventQueue *queue, static void event_queue_callback (XEvent *event,
XEvent *event, gpointer data);
static gboolean event_callback (XEvent *event,
gpointer data); gpointer data);
static Window event_get_modified_window (MetaDisplay *display, static Window event_get_modified_window (MetaDisplay *display,
XEvent *event); XEvent *event);
@ -127,7 +130,11 @@ meta_display_open (const char *name)
meta_verbose ("Opening display '%s'\n", XDisplayName (name)); meta_verbose ("Opening display '%s'\n", XDisplayName (name));
#ifdef USE_GDK_DISPLAY
xdisplay = meta_ui_get_display (name);
#else
xdisplay = XOpenDisplay (name); xdisplay = XOpenDisplay (name);
#endif
if (xdisplay == NULL) if (xdisplay == NULL)
{ {
@ -225,7 +232,9 @@ meta_display_open (const char *name)
/* This would typically happen because all the screens already /* This would typically happen because all the screens already
* have window managers * have window managers
*/ */
#ifndef USE_GDK_DISPLAY
XCloseDisplay (xdisplay); XCloseDisplay (xdisplay);
#endif
all_displays = g_slist_remove (all_displays, display); all_displays = g_slist_remove (all_displays, display);
g_free (display->name); g_free (display->name);
g_free (display); g_free (display);
@ -234,9 +243,18 @@ meta_display_open (const char *name)
display->screens = screens; display->screens = screens;
#ifdef USE_GDK_DISPLAY
display->events = NULL;
/* Get events */
meta_ui_add_event_func (display->xdisplay,
event_callback,
display);
#else
display->events = meta_event_queue_new (display->xdisplay, display->events = meta_event_queue_new (display->xdisplay,
event_queue_callback, event_queue_callback,
display); display);
#endif
display->window_ids = g_hash_table_new (unsigned_long_hash, unsigned_long_equal); display->window_ids = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
@ -312,6 +330,13 @@ meta_display_close (MetaDisplay *display)
g_slist_free (winlist); g_slist_free (winlist);
meta_display_ungrab (display); meta_display_ungrab (display);
#ifdef USE_GDK_DISPLAY
/* Stop caring about events */
meta_ui_remove_event_func (display->xdisplay,
event_callback,
display);
#endif
/* Must be after all calls to meta_window_free() since they /* Must be after all calls to meta_window_free() since they
* unregister windows * unregister windows
*/ */
@ -320,8 +345,10 @@ meta_display_close (MetaDisplay *display)
if (display->leader_window != None) if (display->leader_window != None)
XDestroyWindow (display->xdisplay, display->leader_window); XDestroyWindow (display->xdisplay, display->leader_window);
#ifndef USE_GDK_DISPLAY
meta_event_queue_free (display->events); meta_event_queue_free (display->events);
XCloseDisplay (display->xdisplay); XCloseDisplay (display->xdisplay);
#endif
g_free (display->name); g_free (display->name);
all_displays = g_slist_remove (all_displays, display); all_displays = g_slist_remove (all_displays, display);
@ -444,9 +471,16 @@ meta_display_is_double_click (MetaDisplay *display)
static gboolean dump_events = TRUE; static gboolean dump_events = TRUE;
static void static void
event_queue_callback (MetaEventQueue *queue, event_queue_callback (XEvent *event,
XEvent *event, gpointer data)
{
event_callback (event, data);
}
static gboolean
event_callback (XEvent *event,
gpointer data) gpointer data)
{ {
MetaWindow *window; MetaWindow *window;
@ -490,7 +524,7 @@ event_queue_callback (MetaEventQueue *queue,
modified == window->frame->xwindow) modified == window->frame->xwindow)
{ {
meta_frame_event (window->frame, event); meta_frame_event (window->frame, event);
return; return FALSE;
} }
switch (event->type) switch (event->type)
@ -677,6 +711,8 @@ event_queue_callback (MetaEventQueue *queue,
default: default:
break; break;
} }
return FALSE;
} }
/* Return the window this has to do with, if any, rather /* Return the window this has to do with, if any, rather

View File

@ -151,7 +151,7 @@ eq_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
event = g_queue_pop_head (eq->events); event = g_queue_pop_head (eq->events);
func = (MetaEventQueueFunc) callback; func = (MetaEventQueueFunc) callback;
(* func) (eq, event, user_data); (* func) (event, user_data);
g_free (event); g_free (event);
} }

View File

@ -27,8 +27,7 @@
typedef struct _MetaEventQueue MetaEventQueue; typedef struct _MetaEventQueue MetaEventQueue;
typedef void (* MetaEventQueueFunc) (MetaEventQueue *queue, typedef void (* MetaEventQueueFunc) (XEvent *event,
XEvent *event,
gpointer data); gpointer data);
MetaEventQueue* meta_event_queue_new (Display *display, MetaEventQueue* meta_event_queue_new (Display *display,

View File

@ -22,6 +22,13 @@
#include "frame.h" #include "frame.h"
#include "errors.h" #include "errors.h"
#define EVENT_MASK (SubstructureRedirectMask | \
StructureNotifyMask | SubstructureNotifyMask | \
ExposureMask | \
ButtonPressMask | ButtonReleaseMask | \
PointerMotionMask | PointerMotionHintMask | \
EnterWindowMask | LeaveWindowMask)
void void
meta_window_ensure_frame (MetaWindow *window) meta_window_ensure_frame (MetaWindow *window)
{ {
@ -46,9 +53,7 @@ meta_window_ensure_frame (MetaWindow *window)
frame->mapped = FALSE; frame->mapped = FALSE;
attrs.event_mask = SubstructureRedirectMask | attrs.event_mask = EVENT_MASK;
StructureNotifyMask | SubstructureNotifyMask |
EnterWindowMask | LeaveWindowMask;
frame->xwindow = XCreateWindow (window->display->xdisplay, frame->xwindow = XCreateWindow (window->display->xdisplay,
window->screen->xroot, window->screen->xroot,
@ -92,10 +97,15 @@ meta_window_ensure_frame (MetaWindow *window)
window->rect.y); window->rect.y);
meta_error_trap_pop (window->display); meta_error_trap_pop (window->display);
meta_ui_add_frame (window->screen->ui, frame->xwindow);
/* stick frame to the window */ /* stick frame to the window */
window->frame = frame; window->frame = frame;
meta_ui_add_frame (window->screen->ui, frame->xwindow);
if (window->title)
meta_ui_set_frame_title (window->screen->ui,
window->frame->xwindow,
window->title);
} }
void void

View File

@ -34,17 +34,6 @@ struct _MetaFrameActionGrab
/* button doing the dragging */ /* button doing the dragging */
int start_button; int start_button;
}; };
/* This lacks ButtonReleaseMask to avoid the auto-grab
* since it breaks our popup menu
*/
#define EVENT_MASK (SubstructureRedirectMask | \
StructureNotifyMask | SubstructureNotifyMask | \
ExposureMask | \
ButtonPressMask | ButtonReleaseMask | \
PointerMotionMask | PointerMotionHintMask | \
EnterWindowMask | LeaveWindowMask)
#endif #endif
struct _MetaUIFrame struct _MetaUIFrame
@ -232,7 +221,7 @@ meta_frames_get_type (void)
(GtkClassInitFunc) NULL, (GtkClassInitFunc) NULL,
}; };
frames_type = gtk_type_unique (GTK_TYPE_WIDGET, &frames_info); frames_type = gtk_type_unique (GTK_TYPE_WINDOW, &frames_info);
} }
return frames_type; return frames_type;
@ -494,7 +483,7 @@ meta_frames_style_set (GtkWidget *widget,
g_object_unref (G_OBJECT (font)); g_object_unref (G_OBJECT (font));
frames->text_height = metrics.ascent + metrics.descent; frames->text_height = PANGO_PIXELS (metrics.ascent + metrics.descent);
} }
/* Queue a draw/resize on all frames */ /* Queue a draw/resize on all frames */
@ -695,6 +684,8 @@ meta_frames_manage_window (MetaFrames *frames,
gdk_window_set_user_data (frame->window, frames); gdk_window_set_user_data (frame->window, frames);
#if 0
/* Add events in frame.c */
gdk_window_set_events (frame->window, gdk_window_set_events (frame->window,
GDK_EXPOSURE_MASK | GDK_EXPOSURE_MASK |
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK |
@ -702,6 +693,7 @@ meta_frames_manage_window (MetaFrames *frames,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_STRUCTURE_MASK); GDK_STRUCTURE_MASK);
#endif
/* This shouldn't be required if we don't select for button /* This shouldn't be required if we don't select for button
* press in frame.c? * press in frame.c?
@ -1025,6 +1017,8 @@ meta_frames_expose_event (GtkWidget *widget,
fgeom.title_rect.height); fgeom.title_rect.height);
} }
if (frame->layout)
{
gdk_gc_set_clip_rectangle (layout_gc, &clip); gdk_gc_set_clip_rectangle (layout_gc, &clip);
gdk_draw_layout (frame->window, gdk_draw_layout (frame->window,
layout_gc, layout_gc,
@ -1033,6 +1027,7 @@ meta_frames_expose_event (GtkWidget *widget,
frame->layout); frame->layout);
gdk_gc_set_clip_rectangle (layout_gc, NULL); gdk_gc_set_clip_rectangle (layout_gc, NULL);
} }
}
inner = frames->props->inner_button_border; inner = frames->props->inner_button_border;

View File

@ -25,7 +25,7 @@
#include "errors.h" #include "errors.h"
#include "ui.h" #include "ui.h"
#include <glib.h> #include <glib-object.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -14,7 +14,7 @@ if test -z "$CLIENTS"; then
fi fi
if test -z "$ONLY_WM"; then if test -z "$ONLY_WM"; then
Xnest :1 -scrns $SCREENS -geometry 640x480 -bw 15 & Xnest -ac :1 -scrns $SCREENS -geometry 640x480 -bw 15 &
usleep 50000 usleep 50000
if test $CLIENTS != 0; then if test $CLIENTS != 0; then

View File

@ -349,6 +349,17 @@ meta_screen_queue_frame_redraws (MetaScreen *screen)
meta_screen_foreach_window (screen, queue_draw, NULL); meta_screen_foreach_window (screen, queue_draw, NULL);
} }
static void
queue_resize (MetaScreen *screen, MetaWindow *window, gpointer data)
{
meta_window_queue_move_resize (window);
}
void
meta_screen_queue_window_resizes (MetaScreen *screen)
{
meta_screen_foreach_window (screen, queue_resize, NULL);
}
int int
meta_screen_get_n_workspaces (MetaScreen *screen) meta_screen_get_n_workspaces (MetaScreen *screen)

View File

@ -52,6 +52,7 @@ void meta_screen_foreach_window (MetaScreen *scree
MetaScreenWindowFunc func, MetaScreenWindowFunc func,
gpointer data); gpointer data);
void meta_screen_queue_frame_redraws (MetaScreen *screen); void meta_screen_queue_frame_redraws (MetaScreen *screen);
void meta_screen_queue_window_resizes (MetaScreen *screen);
int meta_screen_get_n_workspaces (MetaScreen *screen); int meta_screen_get_n_workspaces (MetaScreen *screen);

View File

@ -37,6 +37,68 @@ meta_ui_init (int *argc, char ***argv)
meta_fatal ("Unable to open X display %s\n", gdk_display_name); meta_fatal ("Unable to open X display %s\n", gdk_display_name);
} }
Display*
meta_ui_get_display (const char *name)
{
if (name == NULL)
return gdk_display;
else
return NULL;
}
typedef struct _EventFunc EventFunc;
struct _EventFunc
{
MetaEventFunc func;
gpointer data;
};
static GdkFilterReturn
filter_func (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
{
EventFunc *ef;
ef = data;
if ((* ef->func) (xevent, ef->data))
return GDK_FILTER_REMOVE;
else
return GDK_FILTER_CONTINUE;
}
static EventFunc *ef = NULL;
void
meta_ui_add_event_func (Display *xdisplay,
MetaEventFunc func,
gpointer data)
{
g_return_if_fail (ef == NULL);
ef = g_new (EventFunc, 1);
ef->func = func;
ef->data = data;
gdk_window_add_filter (NULL, filter_func, ef);
}
/* removal is by data due to proxy function */
void
meta_ui_remove_event_func (Display *xdisplay,
MetaEventFunc func,
gpointer data)
{
g_return_if_fail (ef != NULL);
gdk_window_remove_filter (NULL, filter_func, ef);
g_free (ef);
ef = NULL;
}
MetaUI* MetaUI*
meta_ui_new (Display *xdisplay, meta_ui_new (Display *xdisplay,
Screen *screen) Screen *screen)
@ -88,6 +150,30 @@ meta_ui_remove_frame (MetaUI *ui,
meta_frames_unmanage_window (ui->frames, xwindow); meta_frames_unmanage_window (ui->frames, xwindow);
} }
void
meta_ui_map_frame (MetaUI *ui,
Window xwindow)
{
GdkWindow *window;
window = gdk_xid_table_lookup (xwindow);
if (window)
gdk_x11_window_map (window);
}
void
meta_ui_unmap_frame (MetaUI *ui,
Window xwindow)
{
GdkWindow *window;
window = gdk_xid_table_lookup (xwindow);
if (window)
gdk_window_hide (window);
}
void void
meta_ui_reset_frame_bg (MetaUI *ui, meta_ui_reset_frame_bg (MetaUI *ui,
Window xwindow) Window xwindow)
@ -103,4 +189,12 @@ meta_ui_queue_frame_draw (MetaUI *ui,
} }
void
meta_ui_set_frame_title (MetaUI *ui,
Window xwindow,
const char *title)
{
meta_frames_set_title (ui->frames, xwindow, title);
}

View File

@ -24,11 +24,24 @@
/* Don't include gtk.h here */ /* Don't include gtk.h here */
#include "common.h" #include "common.h"
#include <X11/Xlib.h>
#include <glib.h>
typedef struct _MetaUI MetaUI; typedef struct _MetaUI MetaUI;
typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data);
void meta_ui_init (int *argc, char ***argv); void meta_ui_init (int *argc, char ***argv);
Display* meta_ui_get_display (const char *name);
void meta_ui_add_event_func (Display *xdisplay,
MetaEventFunc func,
gpointer data);
void meta_ui_remove_event_func (Display *xdisplay,
MetaEventFunc func,
gpointer data);
MetaUI* meta_ui_new (Display *xdisplay, MetaUI* meta_ui_new (Display *xdisplay,
Screen *screen); Screen *screen);
void meta_ui_free (MetaUI *ui); void meta_ui_free (MetaUI *ui);
@ -42,6 +55,11 @@ void meta_ui_add_frame (MetaUI *ui,
void meta_ui_remove_frame (MetaUI *ui, void meta_ui_remove_frame (MetaUI *ui,
Window xwindow); Window xwindow);
/* GDK insists on tracking map/unmap */
void meta_ui_map_frame (MetaUI *ui,
Window xwindow);
void meta_ui_unmap_frame (MetaUI *ui,
Window xwindow);
void meta_ui_reset_frame_bg (MetaUI *ui, void meta_ui_reset_frame_bg (MetaUI *ui,
Window xwindow); Window xwindow);
@ -49,4 +67,8 @@ void meta_ui_reset_frame_bg (MetaUI *ui,
void meta_ui_queue_frame_draw (MetaUI *ui, void meta_ui_queue_frame_draw (MetaUI *ui,
Window xwindow); Window xwindow);
void meta_ui_set_frame_title (MetaUI *ui,
Window xwindow,
const char *title);
#endif #endif

View File

@ -479,7 +479,7 @@ meta_window_show (MetaWindow *window)
{ {
meta_verbose ("Frame actually needs map\n"); meta_verbose ("Frame actually needs map\n");
window->frame->mapped = TRUE; window->frame->mapped = TRUE;
XMapWindow (window->display->xdisplay, window->frame->xwindow); meta_ui_map_frame (window->screen->ui, window->frame->xwindow);
} }
if (window->shaded) if (window->shaded)
@ -528,7 +528,7 @@ meta_window_hide (MetaWindow *window)
{ {
meta_verbose ("Frame actually needs unmap\n"); meta_verbose ("Frame actually needs unmap\n");
window->frame->mapped = FALSE; window->frame->mapped = FALSE;
XUnmapWindow (window->display->xdisplay, window->frame->xwindow); meta_ui_unmap_frame (window->screen->ui, window->frame->xwindow);
} }
if (window->mapped) if (window->mapped)
@ -1422,8 +1422,6 @@ process_property_notify (MetaWindow *window,
event->atom == window->display->atom_net_wm_name) event->atom == window->display->atom_net_wm_name)
{ {
update_title (window); update_title (window);
meta_window_queue_move_resize (window);
} }
else if (event->atom == XA_WM_NORMAL_HINTS) else if (event->atom == XA_WM_NORMAL_HINTS)
{ {
@ -1789,6 +1787,11 @@ update_title (MetaWindow *window)
g_free (window->desc); g_free (window->desc);
window->desc = g_strdup_printf ("0x%lx (%.10s)", window->xwindow, window->title); window->desc = g_strdup_printf ("0x%lx (%.10s)", window->xwindow, window->title);
if (window->frame)
meta_ui_set_frame_title (window->screen->ui,
window->frame->xwindow,
window->title);
return meta_error_trap_pop (window->display); return meta_error_trap_pop (window->display);
} }