4
* Copyright (C) 1997 Rasca Gmelch, Berlin
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
* This file contains routines for setting up and handling the selection
22
* rectangle. Both Xt and GTK2 versions are in here now.
26
#include "../config.h" //autoconf output
28
#include <X11/Intrinsic.h>
29
#include <X11/StringDefs.h>
30
#include <X11/Shell.h>
31
#include "Xw/Toggle.h"
42
top, left, right, bottom, blind = None;
43
extern XRectangle XVC_frame_rectangle;
44
extern int XVC_frame_lock;
45
extern Widget toplevel;
51
* XVC_CREATEFRAME SETS UP THE FRAME ... THE REST IS DONE BY THE GUI CALLBACKS
52
* CAN BE FOUND IN CONTROL.H ... OR XT_CONTROL.C
64
* handle the capture frame, e.g. move, unmap, etc.
67
MoveFrameEH(Widget parent, XtPointer xtp, XEvent *ev, Boolean *boo) {
71
printf("MoveFrameEH() event type = %d\n", ev->type);
73
if (ev->type == ConfigureNotify) {
74
if (!XVC_frame_lock) {
84
y += pheight + FRAME_OFFSET;
85
ChangeFrame(x, y, XVC_frame_rectangle.width, XVC_frame_rectangle.height, FALSE);
86
} else if ( ev->type == UnmapNotify ) {
88
XtUnmanageChild(bottom);
89
XtUnmanageChild(left);
90
XtUnmanageChild(right);
92
XtUnmanageChild(blind);
93
} else if ( ev->type == MapNotify ) {
95
XtManageChild(bottom);
100
} else if ( ev->type == FocusIn ) {
101
XRaiseWindow(XtDisplay(top), XtWindow(top));
102
XRaiseWindow(XtDisplay(top), XtWindow(bottom));
103
XRaiseWindow(XtDisplay(top), XtWindow(left));
104
XRaiseWindow(XtDisplay(top), XtWindow(right));
106
XRaiseWindow(XtDisplay(top), XtWindow(blind));
118
* change the position and the dimension of the capture frame
121
ChangeFrame(int x, int y, int width, int height, Boolean reposition_control) {
122
int frame_width = FRAME_WIDTH;
123
int max_width, max_height;
124
Window topwin, ignore;
125
int pwidth, pheight, px, py, pborder_width, pdepth;
128
Job *job = job_ptr();
130
if ( ! (job->flags & FLG_NOGUI ) ) {
131
dpy = XtDisplay(toplevel);
132
max_width = WidthOfScreen(XtScreen(top));
133
max_height= HeightOfScreen(XtScreen(top));
135
dpy = XOpenDisplay(NULL);
136
max_width = WidthOfScreen(DefaultScreenOfDisplay(dpy));
137
max_height = HeightOfScreen(DefaultScreenOfDisplay(dpy));
140
/* we have to adjust it to viewable areas
143
printf("ChangeFrame() screen = %dx%d selection=%dx%d\n",
144
max_width, max_height, width, height);
148
if (width > max_width)
150
if (x + width > max_width)
151
x = max_width - width;
153
if (height > max_height)
155
if (y + height > max_height)
156
y = max_height - height;
160
if ( ! ( job->flags & FLG_NOGUI ) ) {
162
XtNx, x - frame_width,
163
XtNy, y - frame_width,
164
XtNwidth, width + 2 * frame_width,
165
XtNheight, frame_width,
167
XtVaSetValues(bottom,
168
XtNx, x - frame_width,
170
XtNwidth, width + 2 * frame_width,
171
XtNheight, frame_width,
174
XtNx, x - frame_width,
175
XtNy, y - frame_width,
176
XtNwidth, frame_width,
177
XtNheight, height + 2 * frame_width,
181
XtNy, y - frame_width,
182
XtNwidth, frame_width,
183
XtNheight, height + 2 * frame_width,
193
XVC_frame_rectangle.x = x;
194
XVC_frame_rectangle.y = y;
195
XVC_frame_rectangle.width = width;
196
XVC_frame_rectangle.height= height;
198
if (!IsFrameLocked() && ( ! (job->flags & FLG_NOGUI)) && reposition_control ) {
199
topwin = XtWindow( toplevel );
200
XGetGeometry(dpy, topwin, &ignore, &px, &py, &pwidth, &pheight, &pborder_width,
202
pwidth += FRAME_OFFSET;
203
pheight += FRAME_OFFSET;
205
if ( ( y - pheight - 30 ) >= 0 ) {
206
// FIXME: find out how to determine the title bar height, if possible
207
// don*t know real title bar height ...
208
// If I knew, I perhaps didn*t absolutely need to unlock the frame
209
// if a position is given ...
210
XtVaSetValues(toplevel, XtNx, x, XtNy, ( y - pheight - 30 ), NULL);
212
if ( ( y + pheight + height ) < max_height ) {
213
XtVaSetValues(toplevel, XtNx, x, XtNy, ( y + height + FRAME_OFFSET ), NULL);
216
XtVaSetValues(toplevel, XtNx, ( x - pwidth), XtNy, y, NULL);
218
if ( ( x + width + pwidth ) < max_width ) {
219
XtVaSetValues(toplevel, XtNx, ( x + width + FRAME_OFFSET ), XtNy, y, NULL);
221
// ansonsten lass das GUI wo es ist ...
226
if ( job->flags & FLG_NOGUI ) {
233
* create the video frame
236
CreateFrame(Widget parent, int width, int height, int flags) {
238
Dimension pwidth, pheight;
242
printf("CreateFrame() %d %d\n", width, height);
244
XtVaGetValues(parent, XtNx, &x, XtNy, &y, XtNwidth, &pwidth, XtNheight, &pheight, NULL);
247
y += pheight + FRAME_OFFSET;
250
XVC_frame_rectangle.width = width;
251
XVC_frame_rectangle.height= height;
252
XVC_frame_rectangle.x = x;
253
XVC_frame_rectangle.y = y;
255
if ( ! ( flags & FLG_NOGUI ) ) {
256
top = XtVaCreatePopupShell("top", overrideShellWidgetClass, parent,
259
XtNwidth, width+2*FRAME_WIDTH,
260
XtNheight, FRAME_WIDTH,
262
bottom = XtVaCreatePopupShell("bottom", overrideShellWidgetClass, parent,
265
XtNwidth, width+2*FRAME_WIDTH,
266
XtNheight, FRAME_WIDTH,
268
left= XtVaCreatePopupShell("left", overrideShellWidgetClass, parent,
271
XtNwidth, FRAME_WIDTH,
272
XtNheight, height+2*FRAME_WIDTH,
274
right= XtVaCreatePopupShell("right", overrideShellWidgetClass, parent,
277
XtNwidth, FRAME_WIDTH,
278
XtNheight, height+2*FRAME_WIDTH,
280
if (flags & FLG_USE_V4L) {
281
blind = XtVaCreatePopupShell("blind", overrideShellWidgetClass, parent,
287
XtVaCreateManagedWidget("text", xwLabelWidgetClass, blind,
288
XtNlabel, "Source: Video4Linux", NULL);
289
XtPopup(blind, XtGrabNone);
292
XtPopup(top, XtGrabNone);
293
XtPopup(bottom, XtGrabNone);
294
XtPopup(left, XtGrabNone);
295
XtPopup(right, XtGrabNone);
296
XtAddEventHandler(parent,
297
StructureNotifyMask|FocusChangeMask|ExposureMask,
298
False, MoveFrameEH, NULL);