initial commit
[goodguy/history.git] / cinelerra-5.0 / guicast / bcpopup.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
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.
10  * 
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.
15  * 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #include "bcpopup.h"
23
24
25 BC_FullScreen::BC_FullScreen(BC_WindowBase *parent_window, int w, int h, 
26                            int bg_color,
27                            int vm_scale,
28                            int hide,
29                            BC_Pixmap *bg_pixmap)
30  : BC_WindowBase()
31 {
32 #ifdef HAVE_LIBXXF86VM
33    if (vm_scale) 
34            create_window(parent_window,
35                            "Fullscreen", 
36                            parent_window->get_screen_x(0, -1),
37                            parent_window->get_screen_y(0, -1),
38                            w, 
39                            h, 
40                            w, 
41                            h, 
42                            0,
43                            parent_window->top_level->private_color,
44                            hide,
45                            bg_color,
46                            NULL,
47                            VIDMODE_SCALED_WINDOW,
48                            bg_pixmap,
49                            0);
50    else
51 #endif
52    create_window(parent_window,
53                            "Fullscreen", 
54                            parent_window->get_screen_x(0, -1),
55                            parent_window->get_screen_y(0, -1),
56                            w, 
57                            h, 
58                            w, 
59                            h, 
60                            0,
61                            parent_window->top_level->private_color, 
62                            hide,
63                            bg_color,
64                            NULL,
65                            POPUP_WINDOW,
66                            bg_pixmap,
67                            0);
68 }
69
70
71 BC_FullScreen::~BC_FullScreen()
72 {
73 }
74
75
76 BC_Popup::BC_Popup(BC_WindowBase *parent_window, 
77                                 int x,
78                                 int y,
79                                 int w, 
80                                 int h, 
81                                 int bg_color,
82                                 int hide,
83                                 BC_Pixmap *bg_pixmap)
84  : BC_WindowBase()
85 {
86         create_window(parent_window,
87                                 "Popup", 
88                                 x,
89                                 y,
90                                 w, 
91                                 h, 
92                                 w, 
93                                 h, 
94                                 0,
95                                 parent_window->top_level->private_color, 
96                                 hide,
97                                 bg_color,
98                                 NULL,
99                                 POPUP_WINDOW,
100                                 bg_pixmap,
101                                 0);
102         grabbed = 0;
103 }
104
105
106 BC_Popup::~BC_Popup()
107 {
108 }
109
110
111 void BC_Popup::grab_keyboard()
112 {
113         if( !grabbed ) {
114                 lock_window("BC_Popup::grab_keyboard");
115                 if( !getenv("NO_KEYBOARD_GRAB") )
116                         XGrabKeyboard(top_level->display, win, False,
117                                 GrabModeAsync, GrabModeAsync, CurrentTime);
118                 else
119                         XSetInputFocus(top_level->display, win, RevertToParent, CurrentTime);
120                 unlock_window();  flush();  //  printf("grabbed\n");
121                 set_active_subwindow(this);
122                 grabbed = 1;
123         }
124 }
125
126 void BC_Popup::ungrab_keyboard()
127 {
128         if( grabbed ) {
129                 lock_window("BC_Popup::ungrab_keyboard");
130                 if( !getenv("NO_KEYBOARD_GRAB") )
131                         XUngrabKeyboard(top_level->display, CurrentTime);
132                 unlock_window();  flush(); //  printf("ungrabbed\n");
133                 set_active_subwindow(0);
134                 grabbed = 0;
135         }
136 }
137