mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
...
This commit is contained in:
parent
1785975f38
commit
ebb2b489b0
@ -61,6 +61,7 @@ meta_display_open (const char *name)
|
|||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
GSList *screens;
|
GSList *screens;
|
||||||
|
GSList *tmp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
meta_verbose ("Opening display '%s'\n", XDisplayName (name));
|
meta_verbose ("Opening display '%s'\n", XDisplayName (name));
|
||||||
@ -74,6 +75,9 @@ meta_display_open (const char *name)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (meta_is_syncing ())
|
||||||
|
XSynchronize (xdisplay, True);
|
||||||
|
|
||||||
display = g_new (MetaDisplay, 1);
|
display = g_new (MetaDisplay, 1);
|
||||||
|
|
||||||
display->name = g_strdup (XDisplayName (name));
|
display->name = g_strdup (XDisplayName (name));
|
||||||
@ -115,6 +119,16 @@ meta_display_open (const char *name)
|
|||||||
display);
|
display);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
display->server_grab_count = 0;
|
||||||
|
|
||||||
|
/* Now manage all existing windows */
|
||||||
|
tmp = display->screens;
|
||||||
|
while (tmp != NULL)
|
||||||
|
{
|
||||||
|
meta_screen_manage_all_windows (tmp->data);
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -176,6 +190,33 @@ meta_display_screen_for_root (MetaDisplay *display,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Grab/ungrab routines taken from fvwm */
|
||||||
|
void
|
||||||
|
meta_display_grab (MetaDisplay *display)
|
||||||
|
{
|
||||||
|
if (display->server_grab_count == 0)
|
||||||
|
{
|
||||||
|
XSync (display->xdisplay, False);
|
||||||
|
XGrabServer (display->xdisplay);
|
||||||
|
}
|
||||||
|
XSync (display->xdisplay, False);
|
||||||
|
display->server_grab_count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_display_ungrab (MetaDisplay *display)
|
||||||
|
{
|
||||||
|
if (display->server_grab_count == 0)
|
||||||
|
meta_bug ("Ungrabbed non-grabbed server\n");
|
||||||
|
|
||||||
|
display->server_grab_count -= 1;
|
||||||
|
if (display->server_grab_count == 0)
|
||||||
|
{
|
||||||
|
XUngrabServer (display->xdisplay);
|
||||||
|
}
|
||||||
|
XSync (display->xdisplay, False);
|
||||||
|
}
|
||||||
|
|
||||||
MetaDisplay*
|
MetaDisplay*
|
||||||
meta_display_for_x_display (Display *xdisplay)
|
meta_display_for_x_display (Display *xdisplay)
|
||||||
{
|
{
|
||||||
@ -195,6 +236,12 @@ meta_display_for_x_display (Display *xdisplay)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GSList*
|
||||||
|
meta_displays_list (void)
|
||||||
|
{
|
||||||
|
return all_displays;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean dump_events = TRUE;
|
static gboolean dump_events = TRUE;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -204,18 +251,26 @@ event_queue_callback (MetaEventQueue *queue,
|
|||||||
{
|
{
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
|
gboolean is_root;
|
||||||
|
|
||||||
display = data;
|
display = data;
|
||||||
|
|
||||||
if (dump_events)
|
if (dump_events)
|
||||||
meta_spew_event (display, event);
|
meta_spew_event (display, event);
|
||||||
|
|
||||||
window = meta_display_lookup_window (display, event->xany.window);
|
is_root = meta_display_screen_for_root (display, event->xany.window) != NULL;
|
||||||
|
window = NULL;
|
||||||
if (window)
|
|
||||||
|
if (!is_root)
|
||||||
{
|
{
|
||||||
if (meta_window_event (window, event))
|
if (window == NULL)
|
||||||
return;
|
window = meta_display_lookup_x_window (display, event->xany.window);
|
||||||
|
|
||||||
|
if (window != NULL)
|
||||||
|
{
|
||||||
|
if (meta_window_event (window, event))
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
@ -257,6 +312,16 @@ event_queue_callback (MetaEventQueue *queue,
|
|||||||
case MapNotify:
|
case MapNotify:
|
||||||
break;
|
break;
|
||||||
case MapRequest:
|
case MapRequest:
|
||||||
|
if (is_root && !event->xmap.override_redirect)
|
||||||
|
{
|
||||||
|
/* Window requested mapping. Manage it if we haven't. Note that
|
||||||
|
* meta_window_new() can return NULL
|
||||||
|
*/
|
||||||
|
window = meta_display_lookup_x_window (display,
|
||||||
|
event->xmaprequest.window);
|
||||||
|
if (window == NULL)
|
||||||
|
window = meta_window_new (display, event->xmaprequest.window);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ReparentNotify:
|
case ReparentNotify:
|
||||||
break;
|
break;
|
||||||
@ -430,17 +495,27 @@ meta_spew_event (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaWindow*
|
MetaWindow*
|
||||||
meta_display_lookup_window (MetaDisplay *display,
|
meta_display_lookup_x_window (MetaDisplay *display,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
{
|
{
|
||||||
return g_hash_table_lookup (display->window_ids, &xwindow);
|
return g_hash_table_lookup (display->window_ids, &xwindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_display_register_window (MetaDisplay *display,
|
meta_display_register_x_window (MetaDisplay *display,
|
||||||
MetaWindow *window)
|
Window *xwindowp,
|
||||||
|
MetaWindow *window)
|
||||||
{
|
{
|
||||||
g_return_if_fail (g_hash_table_lookup (display->window_ids, &window->xwindow) == NULL);
|
g_return_if_fail (g_hash_table_lookup (display->window_ids, xwindowp) == NULL);
|
||||||
|
|
||||||
g_hash_table_insert (display->window_ids, &window->xwindow, window);
|
g_hash_table_insert (display->window_ids, xwindowp, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_display_unregister_x_window (MetaDisplay *display,
|
||||||
|
Window xwindow)
|
||||||
|
{
|
||||||
|
g_return_if_fail (g_hash_table_lookup (display->window_ids, &xwindow) != NULL);
|
||||||
|
|
||||||
|
g_hash_table_remove (display->window_ids, &xwindow);
|
||||||
}
|
}
|
||||||
|
@ -26,32 +26,44 @@
|
|||||||
#include <Xlib.h>
|
#include <Xlib.h>
|
||||||
#include "eventqueue.h"
|
#include "eventqueue.h"
|
||||||
|
|
||||||
typedef struct _MetaWindow MetaWindow;
|
|
||||||
typedef struct _MetaScreen MetaScreen;
|
|
||||||
typedef struct _MetaDisplay MetaDisplay;
|
typedef struct _MetaDisplay MetaDisplay;
|
||||||
|
typedef struct _MetaFrame MetaFrame;
|
||||||
|
typedef struct _MetaScreen MetaScreen;
|
||||||
|
typedef struct _MetaWindow MetaWindow;
|
||||||
|
|
||||||
struct _MetaDisplay
|
struct _MetaDisplay
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
MetaEventQueue *events;
|
MetaEventQueue *events;
|
||||||
GSList *screens;
|
GSList *screens;
|
||||||
GHashTable *window_ids;
|
GHashTable *window_ids;
|
||||||
GSList *error_traps;
|
GSList *error_traps;
|
||||||
|
int server_grab_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean meta_display_open (const char *name);
|
gboolean meta_display_open (const char *name);
|
||||||
void meta_display_close (MetaDisplay *display);
|
void meta_display_close (MetaDisplay *display);
|
||||||
MetaScreen* meta_display_screen_for_root (MetaDisplay *display,
|
MetaScreen* meta_display_screen_for_root (MetaDisplay *display,
|
||||||
Window xroot);
|
Window xroot);
|
||||||
|
void meta_display_grab (MetaDisplay *display);
|
||||||
|
void meta_display_ungrab (MetaDisplay *display);
|
||||||
|
|
||||||
|
/* A given MetaWindow may have various X windows that "belong"
|
||||||
|
* to it, such as the frame window.
|
||||||
|
*/
|
||||||
|
MetaWindow* meta_display_lookup_x_window (MetaDisplay *display,
|
||||||
|
Window xwindow);
|
||||||
|
void meta_display_register_x_window (MetaDisplay *display,
|
||||||
|
Window *xwindowp,
|
||||||
|
MetaWindow *window);
|
||||||
|
void meta_display_unregister_x_window (MetaDisplay *display,
|
||||||
|
Window xwindow);
|
||||||
|
|
||||||
|
|
||||||
MetaWindow* meta_display_lookup_window (MetaDisplay *display,
|
|
||||||
Window xwindow);
|
|
||||||
void meta_display_register_window (MetaDisplay *display,
|
|
||||||
MetaWindow *window);
|
|
||||||
|
|
||||||
MetaDisplay* meta_display_for_x_display (Display *xdisplay);
|
MetaDisplay* meta_display_for_x_display (Display *xdisplay);
|
||||||
|
GSList* meta_displays_list (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
src/errors.c
12
src/errors.c
@ -73,6 +73,16 @@ meta_error_trap_pop (MetaDisplay *display)
|
|||||||
display->error_traps = next;
|
display->error_traps = next;
|
||||||
|
|
||||||
g_free (et);
|
g_free (et);
|
||||||
|
|
||||||
|
if (result != Success)
|
||||||
|
{
|
||||||
|
gchar buf[64];
|
||||||
|
|
||||||
|
XGetErrorText (display->xdisplay, result, buf, 63);
|
||||||
|
|
||||||
|
meta_verbose ("Popping error code %d (%s)\n",
|
||||||
|
result, buf);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -127,7 +137,7 @@ x_io_error_handler (Display *xdisplay)
|
|||||||
display = meta_display_for_x_display (xdisplay);
|
display = meta_display_for_x_display (xdisplay);
|
||||||
|
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
meta_bug ("Error received for unknown display?\n");
|
meta_bug ("IO error received for unknown display?\n");
|
||||||
|
|
||||||
if (errno == EPIPE)
|
if (errno == EPIPE)
|
||||||
{
|
{
|
||||||
|
283
src/frame.c
Normal file
283
src/frame.c
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
/* Metacity X window decorations */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2001 Havoc Pennington
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "frame.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_window_ensure_frame (MetaWindow *window)
|
||||||
|
{
|
||||||
|
MetaFrame *frame;
|
||||||
|
int child_x, child_y;
|
||||||
|
unsigned long background_pixel;
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
|
||||||
|
if (window->frame)
|
||||||
|
return;
|
||||||
|
|
||||||
|
frame = g_new (MetaFrame, 1);
|
||||||
|
|
||||||
|
frame->window = window;
|
||||||
|
|
||||||
|
/* FIXME de-hardcode */
|
||||||
|
child_x = 5;
|
||||||
|
child_y = 5;
|
||||||
|
|
||||||
|
frame->rect.width = window->rect.width + 10;
|
||||||
|
frame->rect.height = window->rect.height + 10;
|
||||||
|
|
||||||
|
background_pixel = BlackPixel (window->display, window->screen->number);
|
||||||
|
|
||||||
|
switch (window->win_gravity)
|
||||||
|
{
|
||||||
|
case NorthWestGravity:
|
||||||
|
frame->rect.x = window->rect.x;
|
||||||
|
frame->rect.y = window->rect.y;
|
||||||
|
break;
|
||||||
|
case NorthGravity:
|
||||||
|
frame->rect.x = window->rect.x - frame->rect.width / 2;
|
||||||
|
frame->rect.y = window->rect.y;
|
||||||
|
break;
|
||||||
|
case NorthEastGravity:
|
||||||
|
frame->rect.x = window->rect.x - frame->rect.width;
|
||||||
|
frame->rect.y = window->rect.y;
|
||||||
|
break;
|
||||||
|
case WestGravity:
|
||||||
|
frame->rect.x = window->rect.x;
|
||||||
|
frame->rect.y = window->rect.y - frame->rect.height / 2;
|
||||||
|
break;
|
||||||
|
case CenterGravity:
|
||||||
|
frame->rect.x = window->rect.x - frame->rect.width / 2;
|
||||||
|
frame->rect.y = window->rect.y - frame->rect.height / 2;
|
||||||
|
break;
|
||||||
|
case EastGravity:
|
||||||
|
frame->rect.x = window->rect.x - frame->rect.width;
|
||||||
|
frame->rect.y = window->rect.y - frame->rect.height / 2;
|
||||||
|
break;
|
||||||
|
case SouthWestGravity:
|
||||||
|
frame->rect.x = window->rect.x;
|
||||||
|
frame->rect.y = window->rect.y - frame->rect.height;
|
||||||
|
break;
|
||||||
|
case SouthGravity:
|
||||||
|
frame->rect.x = window->rect.x - frame->rect.width / 2;
|
||||||
|
frame->rect.y = window->rect.y - frame->rect.height;
|
||||||
|
break;
|
||||||
|
case SouthEastGravity:
|
||||||
|
frame->rect.x = window->rect.x - frame->rect.width;
|
||||||
|
frame->rect.y = window->rect.y - frame->rect.height;
|
||||||
|
break;
|
||||||
|
case StaticGravity:
|
||||||
|
default:
|
||||||
|
frame->rect.x = window->rect.x - child_x;
|
||||||
|
frame->rect.y = window->rect.y - child_y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_verbose ("Creating frame %d,%d %dx%d around window 0x%lx %d,%d %dx%d with child position inside frame %d,%d\n",
|
||||||
|
frame->rect.x, frame->rect.y,
|
||||||
|
frame->rect.width, frame->rect.height,
|
||||||
|
window->xwindow,
|
||||||
|
window->rect.x, window->rect.y,
|
||||||
|
window->rect.width, window->rect.height,
|
||||||
|
child_x, child_y);
|
||||||
|
|
||||||
|
attrs.background_pixel = background_pixel;
|
||||||
|
attrs.event_mask =
|
||||||
|
StructureNotifyMask | ExposureMask |
|
||||||
|
ButtonPressMask | ButtonReleaseMask;
|
||||||
|
|
||||||
|
frame->xwindow = XCreateWindow (window->display->xdisplay,
|
||||||
|
window->screen->xroot,
|
||||||
|
frame->rect.x,
|
||||||
|
frame->rect.y,
|
||||||
|
frame->rect.width,
|
||||||
|
frame->rect.height,
|
||||||
|
0,
|
||||||
|
window->depth,
|
||||||
|
InputOutput,
|
||||||
|
window->xvisual,
|
||||||
|
CWBackPixel | CWEventMask,
|
||||||
|
&attrs);
|
||||||
|
|
||||||
|
meta_display_register_x_window (window->display, &frame->xwindow, window);
|
||||||
|
|
||||||
|
/* Reparent the client window; it may be destroyed,
|
||||||
|
* thus the error trap. We'll get a destroy notify later
|
||||||
|
* and free everything. Comment in FVWM source code says
|
||||||
|
* we need the server grab or the child can get its MapNotify
|
||||||
|
* before we've finished reparenting and getting the decoration
|
||||||
|
* window onscreen.
|
||||||
|
*/
|
||||||
|
meta_display_grab (window->display);
|
||||||
|
|
||||||
|
meta_error_trap_push (window->display);
|
||||||
|
XReparentWindow (window->display->xdisplay,
|
||||||
|
window->xwindow,
|
||||||
|
frame->xwindow,
|
||||||
|
child_x,
|
||||||
|
child_y);
|
||||||
|
meta_error_trap_pop (window->display);
|
||||||
|
|
||||||
|
/* Show windows */
|
||||||
|
XMapWindow (window->display->xdisplay, frame->xwindow);
|
||||||
|
XMapWindow (window->display->xdisplay, window->xwindow);
|
||||||
|
|
||||||
|
/* stick frame to the window */
|
||||||
|
window->frame = frame;
|
||||||
|
|
||||||
|
/* Ungrab server */
|
||||||
|
meta_display_ungrab (window->display);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_window_destroy_frame (MetaWindow *window)
|
||||||
|
{
|
||||||
|
MetaFrame *frame;
|
||||||
|
|
||||||
|
if (window->frame == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
frame = window->frame;
|
||||||
|
|
||||||
|
/* Unparent the client window; it may be destroyed,
|
||||||
|
* thus the error trap.
|
||||||
|
*/
|
||||||
|
meta_error_trap_push (window->display);
|
||||||
|
XReparentWindow (window->display->xdisplay,
|
||||||
|
window->xwindow,
|
||||||
|
window->screen->xroot,
|
||||||
|
/* FIXME where to put it back depends on the gravity */
|
||||||
|
window->frame->rect.x,
|
||||||
|
window->frame->rect.y);
|
||||||
|
meta_error_trap_pop (window->display);
|
||||||
|
|
||||||
|
meta_display_unregister_x_window (window->display,
|
||||||
|
frame->xwindow);
|
||||||
|
|
||||||
|
window->frame = NULL;
|
||||||
|
|
||||||
|
/* should we push an error trap? */
|
||||||
|
XDestroyWindow (window->display->xdisplay, frame->xwindow);
|
||||||
|
|
||||||
|
g_free (frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_frame_show (MetaFrame *frame)
|
||||||
|
{
|
||||||
|
XMapWindow (frame->window->display->xdisplay, frame->xwindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_frame_hide (MetaFrame *frame)
|
||||||
|
{
|
||||||
|
XUnmapWindow (frame->window->display->xdisplay, frame->xwindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_frame_event (MetaFrame *frame,
|
||||||
|
XEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case KeyPress:
|
||||||
|
break;
|
||||||
|
case KeyRelease:
|
||||||
|
break;
|
||||||
|
case ButtonPress:
|
||||||
|
break;
|
||||||
|
case ButtonRelease:
|
||||||
|
break;
|
||||||
|
case MotionNotify:
|
||||||
|
break;
|
||||||
|
case EnterNotify:
|
||||||
|
break;
|
||||||
|
case LeaveNotify:
|
||||||
|
break;
|
||||||
|
case FocusIn:
|
||||||
|
break;
|
||||||
|
case FocusOut:
|
||||||
|
break;
|
||||||
|
case KeymapNotify:
|
||||||
|
break;
|
||||||
|
case Expose:
|
||||||
|
break;
|
||||||
|
case GraphicsExpose:
|
||||||
|
break;
|
||||||
|
case NoExpose:
|
||||||
|
break;
|
||||||
|
case VisibilityNotify:
|
||||||
|
break;
|
||||||
|
case CreateNotify:
|
||||||
|
break;
|
||||||
|
case DestroyNotify:
|
||||||
|
meta_warning ("Unexpected destruction of frame 0x%lx, not sure if this should silently fail or be considered a bug\n", frame->xwindow);
|
||||||
|
meta_error_trap_push (frame->window->display);
|
||||||
|
meta_window_destroy_frame (frame->window);
|
||||||
|
meta_error_trap_pop (frame->window->display);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
case UnmapNotify:
|
||||||
|
break;
|
||||||
|
case MapNotify:
|
||||||
|
break;
|
||||||
|
case MapRequest:
|
||||||
|
break;
|
||||||
|
case ReparentNotify:
|
||||||
|
break;
|
||||||
|
case ConfigureNotify:
|
||||||
|
frame->rect.x = event->xconfigure.x;
|
||||||
|
frame->rect.y = event->xconfigure.y;
|
||||||
|
frame->rect.width = event->xconfigure.width;
|
||||||
|
frame->rect.height = event->xconfigure.height;
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
case ConfigureRequest:
|
||||||
|
break;
|
||||||
|
case GravityNotify:
|
||||||
|
break;
|
||||||
|
case ResizeRequest:
|
||||||
|
break;
|
||||||
|
case CirculateNotify:
|
||||||
|
break;
|
||||||
|
case CirculateRequest:
|
||||||
|
break;
|
||||||
|
case PropertyNotify:
|
||||||
|
break;
|
||||||
|
case SelectionClear:
|
||||||
|
break;
|
||||||
|
case SelectionRequest:
|
||||||
|
break;
|
||||||
|
case SelectionNotify:
|
||||||
|
break;
|
||||||
|
case ColormapNotify:
|
||||||
|
break;
|
||||||
|
case ClientMessage:
|
||||||
|
break;
|
||||||
|
case MappingNotify:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
48
src/frame.h
Normal file
48
src/frame.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* Metacity X window decorations */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2001 Havoc Pennington
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_FRAME_H
|
||||||
|
#define META_FRAME_H
|
||||||
|
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
|
struct _MetaFrame
|
||||||
|
{
|
||||||
|
/* window we frame */
|
||||||
|
MetaWindow *window;
|
||||||
|
|
||||||
|
/* reparent window */
|
||||||
|
Window xwindow;
|
||||||
|
|
||||||
|
MetaRectangle rect;
|
||||||
|
};
|
||||||
|
|
||||||
|
void meta_window_ensure_frame (MetaWindow *window);
|
||||||
|
void meta_window_destroy_frame (MetaWindow *window);
|
||||||
|
|
||||||
|
void meta_frame_show (MetaFrame *frame);
|
||||||
|
void meta_frame_hide (MetaFrame *frame);
|
||||||
|
|
||||||
|
gboolean meta_frame_event (MetaFrame *frame,
|
||||||
|
XEvent *event);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -34,6 +34,10 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
meta_main_loop = g_main_loop_new (NULL, FALSE);
|
meta_main_loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
|
meta_set_verbose (TRUE);
|
||||||
|
meta_set_debugging (TRUE);
|
||||||
|
meta_set_syncing (g_getenv ("METACITY_SYNC") != NULL);
|
||||||
|
|
||||||
meta_errors_init ();
|
meta_errors_init ();
|
||||||
|
|
||||||
if (!meta_display_open (NULL))
|
if (!meta_display_open (NULL))
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
Xnest :1 -scrns 2 -geometry 200x200 &
|
Xnest :1 -scrns 2 -geometry 200x200 &
|
||||||
sleep 1
|
sleep 1
|
||||||
DISPLAY=:1 unst ./metacity
|
DISPLAY=:1 unst $1 ./metacity
|
||||||
|
killall Xnest
|
||||||
|
50
src/screen.c
50
src/screen.c
@ -18,9 +18,12 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
* 02111-1307, USA.
|
* 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
#include "window.h"
|
||||||
|
#include <cursorfont.h>
|
||||||
|
|
||||||
MetaScreen*
|
MetaScreen*
|
||||||
meta_screen_new (MetaDisplay *display,
|
meta_screen_new (MetaDisplay *display,
|
||||||
@ -29,7 +32,8 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
Window xroot;
|
Window xroot;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
Cursor cursor;
|
||||||
|
|
||||||
/* Only display->name, display->xdisplay, and display->error_traps
|
/* Only display->name, display->xdisplay, and display->error_traps
|
||||||
* can really be used in this function, since normally screens are
|
* can really be used in this function, since normally screens are
|
||||||
* created from the MetaDisplay constructor
|
* created from the MetaDisplay constructor
|
||||||
@ -66,13 +70,20 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
number, display->name);
|
number, display->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursor = XCreateFontCursor (display->xdisplay, XC_left_ptr);
|
||||||
|
XDefineCursor (display->xdisplay, xroot, cursor);
|
||||||
|
XFreeCursor (display->xdisplay, cursor);
|
||||||
|
|
||||||
screen = g_new (MetaScreen, 1);
|
screen = g_new (MetaScreen, 1);
|
||||||
|
|
||||||
screen->display = NULL;
|
screen->display = display;
|
||||||
screen->number = number;
|
screen->number = number;
|
||||||
screen->xscreen = ScreenOfDisplay (xdisplay, number);
|
screen->xscreen = ScreenOfDisplay (xdisplay, number);
|
||||||
screen->xroot = xroot;
|
screen->xroot = xroot;
|
||||||
|
|
||||||
|
meta_verbose ("Added screen %d on display '%s' root 0x%lx\n",
|
||||||
|
screen->number, screen->display->name, screen->xroot);
|
||||||
|
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
@ -83,4 +94,39 @@ meta_screen_free (MetaScreen *screen)
|
|||||||
g_free (screen);
|
g_free (screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_screen_manage_all_windows (MetaScreen *screen)
|
||||||
|
{
|
||||||
|
Window ignored1, ignored2;
|
||||||
|
Window *children;
|
||||||
|
unsigned int n_children;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Must grab server to avoid obvious race condition */
|
||||||
|
meta_display_grab (screen->display);
|
||||||
|
|
||||||
|
meta_error_trap_push (screen->display);
|
||||||
|
|
||||||
|
XQueryTree (screen->display->xdisplay,
|
||||||
|
screen->xroot,
|
||||||
|
&ignored1, &ignored2, &children, &n_children);
|
||||||
|
|
||||||
|
if (meta_error_trap_pop (screen->display))
|
||||||
|
{
|
||||||
|
meta_display_ungrab (screen->display);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < n_children)
|
||||||
|
{
|
||||||
|
meta_window_new (screen->display, children[i]);
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_display_ungrab (screen->display);
|
||||||
|
|
||||||
|
if (children)
|
||||||
|
XFree (children);
|
||||||
|
}
|
||||||
|
@ -32,8 +32,9 @@ struct _MetaScreen
|
|||||||
Window xroot;
|
Window xroot;
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaScreen* meta_screen_new (MetaDisplay *display,
|
MetaScreen* meta_screen_new (MetaDisplay *display,
|
||||||
int number);
|
int number);
|
||||||
void meta_screen_free (MetaScreen *screen);
|
void meta_screen_free (MetaScreen *screen);
|
||||||
|
void meta_screen_manage_all_windows (MetaScreen *screen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
45
src/util.c
45
src/util.c
@ -21,11 +21,14 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static gboolean is_verbose = TRUE;
|
static gboolean is_verbose = FALSE;
|
||||||
|
static gboolean is_debugging = FALSE;
|
||||||
|
static gboolean is_syncing = FALSE;
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_is_verbose (void)
|
meta_is_verbose (void)
|
||||||
@ -39,6 +42,44 @@ meta_set_verbose (gboolean setting)
|
|||||||
is_verbose = setting;
|
is_verbose = setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_is_debugging (void)
|
||||||
|
{
|
||||||
|
return is_debugging;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_set_debugging (gboolean setting)
|
||||||
|
{
|
||||||
|
is_debugging = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_is_syncing (void)
|
||||||
|
{
|
||||||
|
return is_syncing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_set_syncing (gboolean setting)
|
||||||
|
{
|
||||||
|
if (setting != is_syncing)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
is_syncing = setting;
|
||||||
|
|
||||||
|
tmp = meta_displays_list ();
|
||||||
|
while (tmp != NULL)
|
||||||
|
{
|
||||||
|
MetaDisplay *display = tmp->data;
|
||||||
|
XSynchronize (display->xdisplay, is_syncing);
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_debug_spew (const char *format, ...)
|
meta_debug_spew (const char *format, ...)
|
||||||
{
|
{
|
||||||
@ -47,7 +88,7 @@ meta_debug_spew (const char *format, ...)
|
|||||||
|
|
||||||
g_return_if_fail (format != NULL);
|
g_return_if_fail (format != NULL);
|
||||||
|
|
||||||
if (!is_verbose)
|
if (!is_debugging)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
|
15
src/util.h
15
src/util.h
@ -24,8 +24,23 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
typedef struct _MetaRectangle MetaRectangle;
|
||||||
|
|
||||||
|
struct _MetaRectangle
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
gboolean meta_is_verbose (void);
|
gboolean meta_is_verbose (void);
|
||||||
void meta_set_verbose (gboolean setting);
|
void meta_set_verbose (gboolean setting);
|
||||||
|
gboolean meta_is_debugging (void);
|
||||||
|
void meta_set_debugging (gboolean setting);
|
||||||
|
gboolean meta_is_syncing (void);
|
||||||
|
void meta_set_syncing (gboolean setting);
|
||||||
|
|
||||||
|
|
||||||
void meta_debug_spew (const char *format,
|
void meta_debug_spew (const char *format,
|
||||||
...) G_GNUC_PRINTF (1, 2);
|
...) G_GNUC_PRINTF (1, 2);
|
||||||
|
151
src/window.c
151
src/window.c
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "frame.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
MetaWindow*
|
MetaWindow*
|
||||||
meta_window_new (MetaDisplay *display, Window xwindow)
|
meta_window_new (MetaDisplay *display, Window xwindow)
|
||||||
@ -29,9 +31,28 @@ meta_window_new (MetaDisplay *display, Window xwindow)
|
|||||||
XWindowAttributes attrs;
|
XWindowAttributes attrs;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
|
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
||||||
|
|
||||||
/* round trip */
|
/* round trip */
|
||||||
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
if (XGetWindowAttributes (display->xdisplay,
|
if (XGetWindowAttributes (display->xdisplay,
|
||||||
xwindow, &attrs) != Success)
|
xwindow, &attrs) == Success &&
|
||||||
|
attrs.override_redirect)
|
||||||
|
{
|
||||||
|
/* Oops. Probably attempted to manage override redirect window
|
||||||
|
* in initial screen_manage_all_windows() call.
|
||||||
|
*/
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
XAddToSaveSet (display->xdisplay, xwindow);
|
||||||
|
|
||||||
|
XSelectInput (display->xdisplay, xwindow,
|
||||||
|
StructureNotifyMask);
|
||||||
|
|
||||||
|
if (meta_error_trap_pop (display) != Success)
|
||||||
{
|
{
|
||||||
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
|
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
|
||||||
xwindow);
|
xwindow);
|
||||||
@ -42,6 +63,11 @@ meta_window_new (MetaDisplay *display, Window xwindow)
|
|||||||
window = g_new (MetaWindow, 1);
|
window = g_new (MetaWindow, 1);
|
||||||
|
|
||||||
window->xwindow = xwindow;
|
window->xwindow = xwindow;
|
||||||
|
|
||||||
|
/* this is in window->screen->display, but that's too annoying to
|
||||||
|
* type
|
||||||
|
*/
|
||||||
|
window->display = display;
|
||||||
|
|
||||||
window->screen = NULL;
|
window->screen = NULL;
|
||||||
tmp = display->screens;
|
tmp = display->screens;
|
||||||
@ -57,13 +83,33 @@ meta_window_new (MetaDisplay *display, Window xwindow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_assert (window->screen);
|
g_assert (window->screen);
|
||||||
|
|
||||||
|
window->rect.x = attrs.x;
|
||||||
|
window->rect.y = attrs.y;
|
||||||
|
window->rect.width = attrs.width;
|
||||||
|
window->rect.height = attrs.height;
|
||||||
|
window->border_width = attrs.border_width;
|
||||||
|
window->win_gravity = attrs.win_gravity;
|
||||||
|
window->depth = attrs.depth;
|
||||||
|
window->xvisual = attrs.visual;
|
||||||
|
|
||||||
|
meta_display_register_x_window (display, &window->xwindow, window);
|
||||||
|
|
||||||
|
window->frame = NULL;
|
||||||
|
meta_window_ensure_frame (window);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_free (MetaWindow *window)
|
meta_window_free (MetaWindow *window)
|
||||||
{
|
{
|
||||||
|
meta_verbose ("Unmanaging 0x%lx\n", window->xwindow);
|
||||||
|
|
||||||
|
meta_display_unregister_x_window (window->display, window->xwindow);
|
||||||
|
|
||||||
|
meta_window_destroy_frame (window);
|
||||||
|
|
||||||
g_free (window);
|
g_free (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +117,106 @@ gboolean
|
|||||||
meta_window_event (MetaWindow *window,
|
meta_window_event (MetaWindow *window,
|
||||||
XEvent *event)
|
XEvent *event)
|
||||||
{
|
{
|
||||||
|
if (window->frame &&
|
||||||
|
event->xany.window == window->frame->xwindow)
|
||||||
|
return meta_frame_event (window->frame, event);
|
||||||
|
|
||||||
/* consumed this event */
|
if (event->xany.window != window->xwindow)
|
||||||
return TRUE;
|
return FALSE;
|
||||||
|
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case KeyPress:
|
||||||
|
break;
|
||||||
|
case KeyRelease:
|
||||||
|
break;
|
||||||
|
case ButtonPress:
|
||||||
|
break;
|
||||||
|
case ButtonRelease:
|
||||||
|
break;
|
||||||
|
case MotionNotify:
|
||||||
|
break;
|
||||||
|
case EnterNotify:
|
||||||
|
break;
|
||||||
|
case LeaveNotify:
|
||||||
|
break;
|
||||||
|
case FocusIn:
|
||||||
|
break;
|
||||||
|
case FocusOut:
|
||||||
|
break;
|
||||||
|
case KeymapNotify:
|
||||||
|
break;
|
||||||
|
case Expose:
|
||||||
|
break;
|
||||||
|
case GraphicsExpose:
|
||||||
|
break;
|
||||||
|
case NoExpose:
|
||||||
|
break;
|
||||||
|
case VisibilityNotify:
|
||||||
|
break;
|
||||||
|
case CreateNotify:
|
||||||
|
break;
|
||||||
|
case DestroyNotify:
|
||||||
|
meta_window_free (window);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
case UnmapNotify:
|
||||||
|
if (window->frame)
|
||||||
|
meta_frame_hide (window->frame);
|
||||||
|
break;
|
||||||
|
case MapNotify:
|
||||||
|
if (window->frame)
|
||||||
|
meta_frame_show (window->frame);
|
||||||
|
break;
|
||||||
|
case MapRequest:
|
||||||
|
break;
|
||||||
|
case ReparentNotify:
|
||||||
|
break;
|
||||||
|
case ConfigureNotify:
|
||||||
|
if (event->xconfigure.override_redirect)
|
||||||
|
{
|
||||||
|
/* Unmanage it */
|
||||||
|
meta_window_free (window);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window->rect.x = event->xconfigure.x;
|
||||||
|
window->rect.y = event->xconfigure.y;
|
||||||
|
window->rect.width = event->xconfigure.width;
|
||||||
|
window->rect.height = event->xconfigure.height;
|
||||||
|
window->border_width = event->xconfigure.border_width;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ConfigureRequest:
|
||||||
|
break;
|
||||||
|
case GravityNotify:
|
||||||
|
break;
|
||||||
|
case ResizeRequest:
|
||||||
|
break;
|
||||||
|
case CirculateNotify:
|
||||||
|
break;
|
||||||
|
case CirculateRequest:
|
||||||
|
break;
|
||||||
|
case PropertyNotify:
|
||||||
|
break;
|
||||||
|
case SelectionClear:
|
||||||
|
break;
|
||||||
|
case SelectionRequest:
|
||||||
|
break;
|
||||||
|
case SelectionNotify:
|
||||||
|
break;
|
||||||
|
case ColormapNotify:
|
||||||
|
break;
|
||||||
|
case ClientMessage:
|
||||||
|
break;
|
||||||
|
case MappingNotify:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Didn't use this event */
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,20 @@
|
|||||||
#define META_WINDOW_H
|
#define META_WINDOW_H
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct _MetaWindow
|
struct _MetaWindow
|
||||||
{
|
{
|
||||||
|
MetaDisplay *display;
|
||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
Window xwindow;
|
Window xwindow;
|
||||||
|
/* may be NULL! not all windows get decorated */
|
||||||
|
MetaFrame *frame;
|
||||||
|
MetaRectangle rect;
|
||||||
|
int border_width;
|
||||||
|
int win_gravity;
|
||||||
|
int depth;
|
||||||
|
Visual *xvisual;
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaWindow* meta_window_new (MetaDisplay *display,
|
MetaWindow* meta_window_new (MetaDisplay *display,
|
||||||
|
Loading…
Reference in New Issue
Block a user