FreeWRL/FreeX3D  3.0.0
fwBareWindow.c
1 /*
2 
3  Create X11 window. Manage events.
4 
5 */
6 
7 /****************************************************************************
8  This file is part of the FreeWRL/FreeX3D Distribution.
9 
10  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
11 
12  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
13  it under the terms of the GNU Lesser Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
24 ****************************************************************************/
25 
26 #include <config.h>
27 
28 // OLD_IPHONE_AQUA #if !(defined(IPHONE) || defined(_ANDROID) || defined(AQUA))
29 #if !defined(_ANDROID)
30 
31 #include <system.h>
32 #include <display.h>
33 #include <internal.h>
34 
35 #include <libFreeWRL.h>
36 
37 #include "fwBareWindow.h"
38 
39 XTextProperty windowName;
40 Window Pwin;
41 
42 /* we have no buttons; just make these functions do nothing */
43 void frontendUpdateButtons() {}
44 /* void setMenuButton_collision (int val) {} */
45 /* void setMenuButton_headlight (int val) {} */
46 /* void setMenuButton_navModes (int type) {} */
47 /* void setMenuButton_texSize (int size) {} */
48 
49 void getBareWindowedGLwin (Window *win)
50 {
51  GLwin = Xwin;
52 }
53 
54 void openBareMainWindow (int argc, char **argv)
55 {
56  /* get a connection */
57  Xdpy = XOpenDisplay(0);
58  if (!Xdpy) { fprintf(stderr, "No display!\n");exit(-1);}
59 }
60 
61 int fv_create_main_window(freewrl_params_t * params) //int argc, char *argv[])
62 {
63  /* Window root_ret; */
64  /* Window child_ret; */
65  /* int root_x_ret; */
66  /* int root_y_ret; */
67  /* unsigned int mask_ret; */
68 
69  attr.background_pixel = 0;
70  attr.border_pixel = 0;
71  attr.colormap = colormap;
72 
73  attr.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | LeaveWindowMask | MapNotify | ButtonPressMask | ButtonReleaseMask | FocusChangeMask;
74 
75  if (params->fullscreen) {
76  mask = CWBackPixel | CWColormap | CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWEventMask;
77  attr.override_redirect = true;
78  attr.backing_store = NotUseful;
79  attr.save_under = false;
80  } else {
81  mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
82  }
83 
84  Xwin = XCreateWindow(Xdpy, Xroot_window, 0, 0,
85  params->width, params->height,
86  0, Xvi->depth, InputOutput, Xvi->visual, mask, &attr);
87 
88  /* FIXME: Caller / front-end should reparent FreeWRL window itself */
89  /* Roberto Gerson */
90  /* If -d is setted, so reparent the window */
91  if (params->winToEmbedInto != INT_ID_UNDEFINED) {
92  DEBUG_MSG("create_main_window: reparent %ld to %ld\n",
93  Xwin,
94  params->winToEmbedInto);
95  XReparentWindow(Xdpy, Xwin, (Window) params->winToEmbedInto, 0, 0);
96  }
97 
98 
99  if (!RUNNINGASPLUGIN) {
100  XMapWindow(Xdpy, Xwin);
101  XFlush(Xdpy);
102  }
103 
104  if (params->fullscreen) {
105  XMoveWindow(Xdpy, Xwin, 0, 0);
106  XRaiseWindow(Xdpy, Xwin);
107  XFlush(Xdpy);
108 #ifdef HAVE_XF86_VMODE
109  XF86VidModeSetViewPort(Xdpy, Xscreen, 0, 0);
110 #endif
111  XGrabPointer(Xdpy, Xwin, TRUE, 0, GrabModeAsync, GrabModeAsync, Xwin, None, CurrentTime);
112  XGrabKeyboard(Xdpy, Xwin, TRUE, GrabModeAsync, GrabModeAsync, CurrentTime);
113  } else {
114  WM_DELETE_WINDOW = XInternAtom(Xdpy, "WM_DELETE_WINDOW", FALSE);
115  XSetWMProtocols(Xdpy, Xwin, &WM_DELETE_WINDOW, 1);
116  }
117 
118  /* XQueryPointer(Xdpy, Xwin, &root_ret, &child_ret, &root_x_ret, &root_y_ret, */
119  /* &mouse_x, &mouse_y, &mask_ret); */
120 
121  GLwin = Xwin;
122 
123  XFlush(Xdpy);
124 
125  return TRUE;
126 }
127 
128 #endif /* IPHONE */
129 
130 /* Local Variables: */
131 /* c-basic-offset: 8 */
132 /* End: */
Initialization.
Definition: libFreeWRL.h:71