don't leak X resources.
2006-06-30 Sven Neumann <sven@gimp.org> * plug-ins/common/screenshot.c (select_window_x11): don't leak X resources.
This commit is contained in:

committed by
Sven Neumann

parent
435303b6d9
commit
d00f0c76e3
@ -1,3 +1,8 @@
|
|||||||
|
2006-06-30 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/common/screenshot.c (select_window_x11): don't leak X
|
||||||
|
resources.
|
||||||
|
|
||||||
2006-06-30 Simon Budig <simon@gimp.org>
|
2006-06-30 Simon Budig <simon@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimpstrokeeditor.c: unref the old StrokeOptions
|
* app/widgets/gimpstrokeeditor.c: unref the old StrokeOptions
|
||||||
|
@ -376,58 +376,21 @@ run (const gchar *name,
|
|||||||
static GdkNativeWindow
|
static GdkNativeWindow
|
||||||
select_window_x11 (GdkScreen *screen)
|
select_window_x11 (GdkScreen *screen)
|
||||||
{
|
{
|
||||||
Display *x_dpy;
|
Display *x_dpy = GDK_SCREEN_XDISPLAY (screen);
|
||||||
Cursor x_cursor;
|
gint x_scr = GDK_SCREEN_XNUMBER (screen);
|
||||||
XEvent x_event;
|
Window x_root = RootWindow (x_dpy, x_scr);
|
||||||
Window x_win;
|
Window x_win = None;
|
||||||
Window x_root;
|
GC x_gc = None;
|
||||||
XGCValues gc_values;
|
Cursor x_cursor = XCreateFontCursor (x_dpy, GDK_CROSSHAIR);
|
||||||
GC gc = NULL;
|
|
||||||
GdkKeymapKey *keys = NULL;
|
GdkKeymapKey *keys = NULL;
|
||||||
gint x_scr;
|
|
||||||
gint status;
|
gint status;
|
||||||
gint buttons;
|
gint i, num_keys;
|
||||||
|
gint buttons = 0;
|
||||||
gint mask = ButtonPressMask | ButtonReleaseMask;
|
gint mask = ButtonPressMask | ButtonReleaseMask;
|
||||||
gint x, y, w, h;
|
|
||||||
gint num_keys;
|
|
||||||
gint i;
|
|
||||||
gboolean cancel = FALSE;
|
gboolean cancel = FALSE;
|
||||||
|
|
||||||
x_dpy = GDK_SCREEN_XDISPLAY (screen);
|
|
||||||
x_scr = GDK_SCREEN_XNUMBER (screen);
|
|
||||||
|
|
||||||
x_win = None;
|
|
||||||
x_root = RootWindow (x_dpy, x_scr);
|
|
||||||
x_cursor = XCreateFontCursor (x_dpy, GDK_CROSSHAIR);
|
|
||||||
buttons = 0;
|
|
||||||
|
|
||||||
if (shootvals.shoot_type == SHOOT_REGION)
|
if (shootvals.shoot_type == SHOOT_REGION)
|
||||||
{
|
mask |= PointerMotionMask;
|
||||||
mask |= PointerMotionMask;
|
|
||||||
|
|
||||||
gc_values.function = GXxor;
|
|
||||||
gc_values.plane_mask = AllPlanes;
|
|
||||||
gc_values.foreground = WhitePixel (x_dpy, x_scr);
|
|
||||||
gc_values.background = BlackPixel (x_dpy, x_scr);
|
|
||||||
gc_values.line_width = 0;
|
|
||||||
gc_values.line_style = LineSolid;
|
|
||||||
gc_values.fill_style = FillSolid;
|
|
||||||
gc_values.cap_style = CapButt;
|
|
||||||
gc_values.join_style = JoinMiter;
|
|
||||||
gc_values.graphics_exposures = FALSE;
|
|
||||||
gc_values.clip_x_origin = 0;
|
|
||||||
gc_values.clip_y_origin = 0;
|
|
||||||
gc_values.clip_mask = None;
|
|
||||||
gc_values.subwindow_mode = IncludeInferiors;
|
|
||||||
|
|
||||||
gc = XCreateGC (x_dpy, x_root,
|
|
||||||
GCFunction | GCPlaneMask | GCForeground | GCLineWidth |
|
|
||||||
GCLineStyle | GCCapStyle | GCJoinStyle |
|
|
||||||
GCGraphicsExposures | GCBackground | GCFillStyle |
|
|
||||||
GCClipXOrigin | GCClipYOrigin | GCClipMask |
|
|
||||||
GCSubwindowMode,
|
|
||||||
&gc_values);
|
|
||||||
}
|
|
||||||
|
|
||||||
status = XGrabPointer (x_dpy, x_root, False,
|
status = XGrabPointer (x_dpy, x_root, False,
|
||||||
mask, GrabModeSync, GrabModeAsync,
|
mask, GrabModeSync, GrabModeAsync,
|
||||||
@ -436,9 +399,39 @@ select_window_x11 (GdkScreen *screen)
|
|||||||
if (status != GrabSuccess)
|
if (status != GrabSuccess)
|
||||||
{
|
{
|
||||||
g_message (_("Error grabbing the pointer"));
|
g_message (_("Error grabbing the pointer"));
|
||||||
|
|
||||||
|
XFreeCursor (x_dpy, x_cursor);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shootvals.shoot_type == SHOOT_REGION)
|
||||||
|
{
|
||||||
|
XGCValues gc_values;
|
||||||
|
|
||||||
|
gc_values.function = GXxor;
|
||||||
|
gc_values.plane_mask = AllPlanes;
|
||||||
|
gc_values.foreground = WhitePixel (x_dpy, x_scr);
|
||||||
|
gc_values.background = BlackPixel (x_dpy, x_scr);
|
||||||
|
gc_values.line_width = 0;
|
||||||
|
gc_values.line_style = LineSolid;
|
||||||
|
gc_values.fill_style = FillSolid;
|
||||||
|
gc_values.cap_style = CapButt;
|
||||||
|
gc_values.join_style = JoinMiter;
|
||||||
|
gc_values.graphics_exposures = FALSE;
|
||||||
|
gc_values.clip_x_origin = 0;
|
||||||
|
gc_values.clip_y_origin = 0;
|
||||||
|
gc_values.clip_mask = None;
|
||||||
|
gc_values.subwindow_mode = IncludeInferiors;
|
||||||
|
|
||||||
|
x_gc = XCreateGC (x_dpy, x_root,
|
||||||
|
GCFunction | GCPlaneMask | GCForeground | GCLineWidth |
|
||||||
|
GCLineStyle | GCCapStyle | GCJoinStyle |
|
||||||
|
GCGraphicsExposures | GCBackground | GCFillStyle |
|
||||||
|
GCClipXOrigin | GCClipYOrigin | GCClipMask |
|
||||||
|
GCSubwindowMode,
|
||||||
|
&gc_values);
|
||||||
|
}
|
||||||
|
|
||||||
if (gdk_keymap_get_entries_for_keyval (NULL, GDK_Escape, &keys, &num_keys))
|
if (gdk_keymap_get_entries_for_keyval (NULL, GDK_Escape, &keys, &num_keys))
|
||||||
{
|
{
|
||||||
gdk_error_trap_push ();
|
gdk_error_trap_push ();
|
||||||
@ -467,6 +460,9 @@ select_window_x11 (GdkScreen *screen)
|
|||||||
|
|
||||||
while (! cancel && ((x_win == None) || (buttons != 0)))
|
while (! cancel && ((x_win == None) || (buttons != 0)))
|
||||||
{
|
{
|
||||||
|
XEvent x_event;
|
||||||
|
gint x, y, w, h;
|
||||||
|
|
||||||
XAllowEvents (x_dpy, SyncPointer, CurrentTime);
|
XAllowEvents (x_dpy, SyncPointer, CurrentTime);
|
||||||
XWindowEvent (x_dpy, x_root, mask | KeyPressMask, &x_event);
|
XWindowEvent (x_dpy, x_root, mask | KeyPressMask, &x_event);
|
||||||
|
|
||||||
@ -502,7 +498,7 @@ select_window_x11 (GdkScreen *screen)
|
|||||||
h = ABS (shootvals.y2 - shootvals.y1);
|
h = ABS (shootvals.y2 - shootvals.y1);
|
||||||
|
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
XDrawRectangle (x_dpy, x_root, gc, x, y, w, h);
|
XDrawRectangle (x_dpy, x_root, x_gc, x, y, w, h);
|
||||||
|
|
||||||
shootvals.x2 = x_event.xbutton.x_root;
|
shootvals.x2 = x_event.xbutton.x_root;
|
||||||
shootvals.y2 = x_event.xbutton.y_root;
|
shootvals.y2 = x_event.xbutton.y_root;
|
||||||
@ -518,7 +514,7 @@ select_window_x11 (GdkScreen *screen)
|
|||||||
h = ABS (shootvals.y2 - shootvals.y1);
|
h = ABS (shootvals.y2 - shootvals.y1);
|
||||||
|
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
XDrawRectangle (x_dpy, x_root, gc, x, y, w, h);
|
XDrawRectangle (x_dpy, x_root, x_gc, x, y, w, h);
|
||||||
|
|
||||||
shootvals.x2 = x_event.xmotion.x_root;
|
shootvals.x2 = x_event.xmotion.x_root;
|
||||||
shootvals.y2 = x_event.xmotion.y_root;
|
shootvals.y2 = x_event.xmotion.y_root;
|
||||||
@ -529,7 +525,7 @@ select_window_x11 (GdkScreen *screen)
|
|||||||
h = ABS (shootvals.y2 - shootvals.y1);
|
h = ABS (shootvals.y2 - shootvals.y1);
|
||||||
|
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
XDrawRectangle (x_dpy, x_root, gc, x, y, w, h);
|
XDrawRectangle (x_dpy, x_root, x_gc, x, y, w, h);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -579,7 +575,10 @@ select_window_x11 (GdkScreen *screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
XUngrabPointer (x_dpy, CurrentTime);
|
XUngrabPointer (x_dpy, CurrentTime);
|
||||||
|
|
||||||
XFreeCursor (x_dpy, x_cursor);
|
XFreeCursor (x_dpy, x_cursor);
|
||||||
|
if (x_gc != None)
|
||||||
|
XFreeGC (x_dpy, x_gc);
|
||||||
|
|
||||||
return x_win;
|
return x_win;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user