4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef BCWINDOWBASE_H
23 #define BCWINDOWBASE_H
28 #define POPUP_WINDOW 2
30 #ifdef HAVE_LIBXXF86VM
31 #define VIDMODE_SCALED_WINDOW 3
34 #define TOOLTIP_MARGIN 2
35 #define BC_INFINITY 65536
37 #include "arraylist.h"
39 #include "bcbitmap.inc"
40 #include "bcbutton.inc"
41 #include "bccapture.inc"
42 #include "bcclipboard.inc"
43 #include "bccmodels.inc"
44 #include "bcdisplay.inc"
45 #include "bcdragwindow.inc"
46 #include "bcfilebox.inc"
47 #include "bckeyboard.h"
48 #include "bclistbox.inc"
49 #include "bcmenubar.inc"
50 #include "bcmeter.inc"
52 #include "bcpbuffer.inc"
53 #include "bcpixmap.inc"
54 #include "bcpopup.inc"
55 #include "bcpopupmenu.inc"
57 #include "bcprogress.inc"
58 #include "bcrepeater.inc"
59 #include "bcresources.inc"
60 #include "bcscrollbar.inc"
61 #include "bcslider.inc"
62 #include "bcsubwindow.inc"
63 #include "bcsynchronous.inc"
64 #include "bctextbox.inc"
65 #include "bctimer.inc"
66 #include "bctitle.inc"
67 #include "bctoggle.inc"
68 #include "bctrace.inc"
69 #include "bctumble.inc"
70 #include "bcwindow.inc"
71 #include "bcwindowbase.inc"
72 #include "bcwindowevents.inc"
73 #include "condition.inc"
83 #include <X11/Xatom.h>
85 #include <X11/Xft/Xft.h>
88 #include <X11/Xutil.h>
89 #include <X11/keysym.h>
90 #include <X11/cursorfont.h>
91 #ifdef HAVE_LIBXXF86VM
92 #include <X11/extensions/xf86vmode.h>
94 #include <X11/extensions/Xinerama.h>
96 #define GL_GLEXT_PROTOTYPES
101 #define xS(v) (BC_WindowBase::get_resources()->x_scale*(v))
102 #define yS(v) (BC_WindowBase::get_resources()->y_scale*(v))
105 //typedef void* GLXContext;
108 typedef uint32_t wchr_t;
110 static inline size_t wstrlen(const wchr_t *s)
113 while( s[len] ) ++len;
117 static inline wchr_t *wstrncpy(wchr_t *dest, const wchr_t *src, size_t n)
119 for( wchr_t *dp=dest; n>0 && (*dp++=*src++); --n );
127 BC_ResizeCall(int w, int h);
131 typedef XClientMessageEvent xatom_event;
134 class BC_ActiveBitmaps : public List<BC_BitmapImage> {
137 void reque(XEvent *ev);
138 void insert(BC_BitmapImage *image, Drawable pixmap);
139 void remove_buffers(BC_WindowBase *wdw);
146 // Windows, subwindows, popupwindows inherit from this
147 class BC_WindowBase : public trace_info
151 virtual ~BC_WindowBase();
154 friend class BC_BitmapImage;
155 friend class BC_XImage;
156 friend class BC_XShmImage;
157 friend class BC_XvImage;
158 friend class BC_XvShmImage;
159 friend class BC_Bitmap;
160 friend class BC_Button;
161 friend class BC_GenericButton;
162 friend class BC_Capture;
163 friend class BC_Clipboard;
164 friend class BC_Display;
165 friend class BC_DragWindow;
166 friend class BC_FileBox;
167 friend class BC_FullScreen;
168 friend class BC_ListBox;
169 friend class BC_Menu;
170 friend class BC_MenuBar;
171 friend class BC_MenuItem;
172 friend class BC_MenuPopup;
173 friend class BC_Meter;
175 friend class BC_PBuffer;
176 friend class BC_Pixmap;
177 friend class BC_PixmapSW;
178 friend class BC_Popup;
179 friend class BC_PopupMenu;
181 friend class BC_ProgressBar;
182 friend class BC_Repeater;
183 friend class BC_Resources;
184 friend class BC_ScrollBar;
185 friend class BC_Slider;
186 friend class BC_SubWindow;
187 friend class BC_Synchronous;
188 friend class BC_TextBox;
189 friend class BC_Title;
190 friend class BC_Toggle;
191 friend class BC_Tumbler;
192 friend class BC_Window;
193 friend class BC_WindowEvents;
194 friend class Shuttle;
198 // Terminal event dispatchers
199 virtual int close_event();
200 virtual int resize_event(int w, int h);
201 virtual int repeat_event(int64_t duration) { return 0; };
202 virtual int focus_in_event() { return 0; };
203 virtual int focus_out_event() { return 0; };
204 virtual int button_press_event() { return 0; };
205 virtual int button_release_event() { return 0; };
206 virtual int cursor_motion_event() { return 0; };
207 virtual int cursor_leave_event();
208 virtual int cursor_enter_event();
209 virtual int keypress_event();
210 virtual int keyrelease_event() { return 0; };
211 virtual int translation_event() { return 0; };
212 virtual int drag_start_event() { return 0; };
213 virtual int drag_motion_event() { return 0; };
214 virtual int drag_stop_event() { return 0; };
215 virtual int uses_text() { return 0; };
216 virtual int selection_clear_event() { return 0; }
217 // Only if opengl is enabled
218 virtual int expose_event() { return 0; };
219 virtual int handle_ungrab() { return 0; };
220 virtual int grab_event(XEvent *event) { return 0; };
222 virtual void create_objects() { return; };
224 static void init_resources(float scale);
225 static void finit_resources();
226 int get_window_type() { return window_type; }
227 // Wait until event loop is running
229 int is_running() { return window_running; }
230 int is_hidden() { return hidden; }
231 // Check if a hardware accelerated colormodel is available and reserve it
232 int accel_available(int color_model, int lock_it);
233 void get_input_context();
234 void close_input_context();
235 // Get color model adjusted for byte order and pixel size
236 int get_color_model();
237 // return the colormap pixel of the color for all bit depths
238 int get_color(int64_t color);
239 // return the currently selected color
241 virtual int show_window(int flush = 1);
242 virtual int hide_window(int flush = 1);
245 // Shouldn't deference a pointer to delete a window if a parent is
246 // currently being deleted. This returns 1 if any parent is being deleted.
250 //============================= OpenGL functions ===============================
251 // OpenGL functions must be called from inside a BC_Synchronous command.
252 // Create openGL context and bind it to the current window.
253 // If it's called inside start_video/stop_video, the context is bound to the window.
254 // If it's called outside start_video/stop_video, the context is bound to the pixmap.
255 // Must be called at the beginning of any opengl routine to make sure
256 // the context is current.
257 // No locking is performed.
258 void enable_opengl();
259 void disable_opengl();
262 // Calls the BC_Synchronous version of the function
263 int get_shader(unsigned int *handle, const char *vert, const char *frag);
264 void put_shader(unsigned int handle, const char *vert, const char *frag);
265 int get_opengl_server_version();
267 int flash(int x, int y, int w, int h, int flush = 1);
268 int flash(int flush = 1);
271 // Lock out other threads
272 int lock_window(const char *location = 0);
274 int get_window_lock();
277 BC_MenuBar* add_menubar(BC_MenuBar *menu_bar);
278 BC_WindowBase* add_subwindow(BC_WindowBase *subwindow);
279 BC_WindowBase* add_tool(BC_WindowBase *subwindow);
281 // Use this to get events for the popup window.
282 // Events are not propagated to the popup window.
283 BC_WindowBase* add_popup(BC_WindowBase *window);
284 void remove_popup(BC_WindowBase *window);
286 static BC_Resources* get_resources();
287 // User must create synchronous object first
288 static BC_Synchronous* get_synchronous();
289 static int shm_completion_event;
290 // bckeyboard / remote control
291 virtual int keyboard_listener(BC_WindowBase *wp) { return 0; }
292 void add_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
293 void del_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
294 int resend_event(BC_WindowBase *window);
296 virtual int get_w() { return w; }
297 virtual int get_h() { return h; }
298 virtual int get_x() { return x; }
299 virtual int get_y() { return y; }
300 int get_root_w(int lock_display);
301 int get_root_h(int lock_display);
302 XineramaScreenInfo *get_xinerama_info(int screen);
303 void get_fullscreen_geometry(int &wx, int &wy, int &ww, int &wh);
304 int get_screen_w(int lock_display, int screen);
305 int get_screen_h(int lock_display, int screen);
306 int get_screen_x(int lock_display, int screen);
307 int get_screen_y(int lock_display, int screen);
308 // Get current position
309 void get_abs_cursor(int &abs_x, int &abs_y, int lock_window=0);
310 int get_abs_cursor_x(int lock_window=0);
311 int get_abs_cursor_y(int lock_window=0);
312 void get_pop_cursor(int &px, int &py, int lock_window=0);
313 int get_pop_cursor_x(int lock_window=0);
314 int get_pop_cursor_y(int lock_window=0);
315 void get_relative_cursor(int &x, int &y, int lock_window=0);
316 int get_relative_cursor_x(int lock_window=0);
317 int get_relative_cursor_y(int lock_window=0);
318 void get_root_coordinates(int x, int y, int *abs_x, int *abs_y);
319 void get_win_coordinates(int abs_x, int abs_y, int *x, int *y);
320 // Return 1 if cursor is over an unobscured part of this window.
321 // An argument is provided for excluding a drag popup
322 int get_cursor_over_window();
323 // Return 1 if cursor is above/inside window
325 // For traversing windows... return 1 if this or any subwindow is win
326 int match_window(Window win);
328 // 1 or 0 if a button is down
329 int get_button_down();
330 // Number of button pressed 1 - 5
331 int get_buttonpress();
334 wchr_t* get_wkeystring(int *length = 0);
336 int get_keysym() { return keysym; }
337 #ifdef X_HAVE_UTF8_STRING
338 char* get_keypress_utf8();
340 int keysym_lookup(XEvent *event);
341 // Get cursor position of last event
344 // Cursor position of drag start
350 int get_double_click();
351 int get_triple_click();
352 // Bottom right corner
356 void set_bg_color(int color);
357 BC_Pixmap* get_bg_pixmap();
358 int get_text_ascent(int font);
359 int get_text_descent(int font);
360 int get_text_height(int font, const char *text = 0);
361 int get_text_width(int font, const char *text, int length = -1);
362 int get_text_width(int font, const wchr_t *text, int length = -1);
363 // truncate the text with ... & return a new string
364 char *get_truncated_text(int font, const char *text, int max_w);
365 BC_Clipboard* get_clipboard();
366 void set_dragging(int value);
369 BC_WindowBase* get_top_level();
370 BC_WindowBase* get_parent();
371 // Event happened in this window
373 // Event happened either in this window or in the associated tooltip
374 int is_tooltip_event_win();
376 // Deactivate everything and activate this subwindow
377 virtual int activate();
378 // Deactivate this subwindow
379 virtual int deactivate();
380 void set_active_subwindow(BC_WindowBase *subwindow);
381 // Get value of toggle value when dragging a selection
382 int get_toggle_value();
383 // Get if toggle is being dragged
384 int get_toggle_drag();
386 // Set the gc to the color
387 void set_color(int64_t color);
388 void set_line_width(int value);
389 void set_line_dashes(int value);
391 int get_current_font();
392 void set_font(int font);
393 // Set the cursor to a macro from cursors.h
394 // Set override if the caller is enabling hourglass or hiding the cursor
395 void set_cursor(int cursor, int override /* = 0 */, int flush);
396 // Set the cursor to a character in the X cursor library. Used by test.C
397 void set_x_cursor(int cursor);
399 // Shows the cursor after it's hidden by video playback
400 void unhide_cursor();
401 // Called by video updating routines to hide the cursor after a timeout
402 void update_video_cursor();
404 // Entry point for starting hourglass.
405 // Converts all cursors and saves the previous cursor.
406 void start_hourglass();
407 void stop_hourglass();
409 // Recursive part of hourglass commands.
410 void start_hourglass_recursive();
411 void stop_hourglass_recursive();
413 BC_Pixmap *create_pixmap(VFrame *vframe);
416 void copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap = 0);
417 void clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
418 void draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
419 void draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
420 void draw_arc(int x, int y, int w, int h,
421 int start_angle, int angle_length, BC_Pixmap *pixmap = 0);
422 void draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
423 void draw_text(int x, int y, const char *text, int length = -1, BC_Pixmap *pixmap = 0);
424 void draw_utf8_text(int x, int y, const char *text, int length = -1, BC_Pixmap *pixmap = 0);
425 void draw_text_line(int x, int y, const char *text, int len, BC_Pixmap *pixmap = 0);
426 void draw_xft_text(int x, int y, const char *text, int len,
427 BC_Pixmap *pixmap = 0, int is_utf8 = 0);
428 void draw_xft_text(int x, int y, const wchr_t *text,
429 int length, BC_Pixmap *pixmap);
430 int draw_single_text(int draw, int font,
431 int x, int y, const wchr_t *text, int length = -1, BC_Pixmap *pixmap = 0);
432 void draw_center_text(int x, int y, const char *text, int length = -1);
433 void draw_pix(int x, int y, BC_Pixmap *pixmap = 0);
434 void draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap = 0);
435 void draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap = 0);
436 void draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap = 0);
437 void fill_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap = 0);
438 void draw_rectangle(int x, int y, int w, int h);
439 void draw_3segment(int x, int y, int w, int h, BC_Pixmap *left_image,
440 BC_Pixmap *mid_image, BC_Pixmap *right_image, BC_Pixmap *pixmap = 0);
441 void draw_3segment(int x, int y, int w, int h, VFrame *left_image,
442 VFrame *mid_image, VFrame *right_image, BC_Pixmap *pixmap = 0);
443 // For drawing a changing level
444 void draw_3segmenth(int x, int y, int w, int total_x, int total_w,
445 VFrame *image, BC_Pixmap *pixmap);
446 void draw_3segmenth(int x, int y, int w, int total_x, int total_w,
447 BC_Pixmap *src, BC_Pixmap *dst = 0);
448 void draw_3segmentv(int x, int y, int h, int total_y, int total_h,
449 BC_Pixmap *src, BC_Pixmap *dst = 0);
450 void draw_3segmentv(int x, int y, int h, int total_y, int total_h,
451 VFrame *src, BC_Pixmap *dst = 0);
452 // For drawing a single level
453 void draw_3segmenth(int x, int y, int w, VFrame *image, BC_Pixmap *pixmap = 0);
454 void draw_3segmenth(int x, int y, int w, BC_Pixmap *src, BC_Pixmap *dst = 0);
455 void draw_3segmentv(int x, int y, int h, BC_Pixmap *src, BC_Pixmap *dst = 0);
456 void draw_3segmentv(int x, int y, int h, VFrame *src, BC_Pixmap *dst = 0);
457 void draw_9segment(int x, int y, int w, int h, VFrame *src, BC_Pixmap *dst = 0);
458 void draw_9segment(int x, int y, int w, int h, BC_Pixmap *src, BC_Pixmap *dst = 0);
459 void draw_3d_box(int x, int y, int w, int h, int light1, int light2,
460 int middle, int shadow1, int shadow2, BC_Pixmap *pixmap = 0);
461 void draw_3d_box(int x, int y, int w, int h, int is_down, BC_Pixmap *pixmap = 0);
462 void draw_3d_border(int x, int y, int w, int h,
463 int light1, int light2, int shadow1, int shadow2);
464 void draw_3d_border(int x, int y, int w, int h, int is_down);
465 void draw_colored_box(int x, int y, int w, int h, int down, int highlighted);
466 void draw_check(int x, int y);
467 void draw_triangle_down_flat(int x, int y, int w, int h);
468 void draw_triangle_up(int x, int y, int w, int h,
469 int light1, int light2, int middle, int shadow1, int shadow2);
470 void draw_triangle_down(int x, int y, int w, int h,
471 int light1, int light2, int middle, int shadow1, int shadow2);
472 void draw_triangle_left(int x, int y, int w, int h,
473 int light1, int light2, int middle, int shadow1, int shadow2);
474 void draw_triangle_right(int x, int y, int w, int h,
475 int light1, int light2, int middle, int shadow1, int shadow2);
476 // Set the gc to opaque
479 void set_background(VFrame *bitmap);
480 // Change the window title.
481 void put_title(const char *text);
482 void set_title(const char *text, int utf8=1);
483 const char *get_title();
484 // Change the window title. The title is translated internally.
488 void set_done(int return_value);
489 void close(int return_value);
490 // Reroute toplevel events
491 int grab(BC_WindowBase *window);
492 int ungrab(BC_WindowBase *window);
493 int grab_event_count();
494 // Grab button events
496 void ungrab_buttons();
498 void ungrab_cursor();
499 // Get a bitmap to draw on the window with
500 BC_Bitmap* new_bitmap(int w, int h, int color_model = -1);
501 // Draw a bitmap on the window
502 void draw_bitmap(BC_Bitmap *bitmap, int dont_wait,
503 int dest_x = 0, int dest_y = 0, int dest_w = 0, int dest_h = 0,
504 int src_x = 0, int src_y = 0, int src_w = 0, int src_h = 0,
505 BC_Pixmap *pixmap = 0);
506 void draw_pixel(int x, int y, BC_Pixmap *pixmap = 0);
507 // Draw a pixmap on the window
508 void draw_pixmap(BC_Pixmap *pixmap,
509 int dest_x = 0, int dest_y = 0, int dest_w = -1, int dest_h = -1,
510 int src_x = 0, int src_y = 0, BC_Pixmap *dst = 0);
511 // Draw a vframe on the window
512 void draw_vframe(VFrame *frame,
513 int dest_x = 0, int dest_y = 0, int dest_w = -1, int dest_h = -1,
514 int src_x = 0, int src_y = 0, int src_w = 0, int src_h = 0,
515 BC_Pixmap *pixmap = 0);
516 void draw_border(char *text, int x, int y, int w, int h);
517 // Draw a region of the background
518 void draw_top_background(BC_WindowBase *parent_window, int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
519 void draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h);
520 void draw_background(int x, int y, int w, int h);
521 void draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y,
522 int x, int y, int w, int h);
523 void slide_left(int distance);
524 void slide_right(int distance);
525 void slide_up(int distance);
526 void slide_down(int distance);
527 void flicker(int n=3, int ms=66);
529 int wait_viewable(int ms);
531 int cycle_textboxes(int amount);
533 int raise_window(int do_flush = 1);
534 int lower_window(int do_flush = 1);
535 void set_force_tooltip(int v);
536 void set_tooltips(int v);
537 int resize_window(int w, int h);
538 int reposition_window(int x, int y);
539 int reposition_window(int x, int y, int w, int h);
540 int reposition_window_relative(int dx, int dy);
541 int reposition_window_relative(int dx, int dy, int w, int h);
542 // Cause a repeat event to be dispatched every duration.
543 // duration is milliseconds
544 int set_repeat(int64_t duration);
545 // Stop a repeat event from being dispatched.
546 int unset_repeat(int64_t duration);
547 const char *get_tooltip();
548 int set_tooltip(const char *text);
549 virtual int show_tooltip(const char *text, int x=-1, int y=-1, int w = -1, int h = -1);
550 int show_tooltip(int w=-1, int h=-1) { return show_tooltip(0, -1, -1, w, h); }
552 int set_icon(VFrame *data);
553 void set_net_icon(VFrame *data);
554 int load_defaults(BC_Hash *defaults);
555 int save_defaults(BC_Hash *defaults);
557 #ifdef HAVE_LIBXXF86VM
558 // Mode switch methods.
559 void closest_vm(int *vm, int *width, int *height);
560 void scale_vm(int vm);
564 Atom to_clipboard(const char *data, long len, int clipboard_num);
565 long from_clipboard(char *data, long maxlen, int clipboard_num);
566 long clipboard_len(int clipboard_num);
568 // *** CONTEXT_HELP ***
569 void context_help_set_keyword(const char *keyword);
570 const char *context_help_get_keyword();
571 void context_help_show(const char *keyword);
572 void context_help_show();
573 int context_help_check_and_show(const char *keyword);
574 int context_help_check_and_show();
577 char keys_return[KEYPRESSLEN];
582 virtual int create_window(BC_WindowBase *parent_window,
583 const char *title, int x, int y, int w, int h,
584 int minw, int minh, int allow_resize, int private_color,
585 int hide, int bg_color, const char *display_name,
586 int window_type, BC_Pixmap *bg_pixmap, int group_it);
588 static Display* init_display(const char *display_name);
589 // Get display from top level
590 Display* get_display();
592 virtual int initialize();
594 // Function to overload to receive customly defined atoms
595 virtual int receive_custom_xatoms(xatom_event *event);
599 int init_window_shape();
600 static int evaluate_color_model(int client_byte_order, int server_byte_order, int depth);
601 int create_private_colors();
602 int create_color(int color);
603 int create_shared_colors();
604 Cursor create_grab_cursor();
605 // Get width of a single line. Used by get_text_width
606 int get_single_text_width(int font, const char *text, int length);
607 int get_single_text_width(int font, const wchr_t *text, int length);
608 int allocate_color_table();
615 int get_color_rgb8(int color);
616 int64_t get_color_rgb16(int color);
617 int64_t get_color_bgr16(int color);
618 int64_t get_color_bgr24(int color);
619 XFontStruct* get_font_struct(int font);
620 XftFont* get_xft_struct(int font);
621 Cursor get_cursor_struct(int cursor);
622 XFontSet get_fontset(int font);
623 XFontSet get_curr_fontset(void);
624 void set_fontset(int font);
625 int dispatch_event();
627 int get_key_masks(unsigned int key_state);
629 int trigger_tooltip();
630 int untrigger_tooltip();
631 void draw_tooltip(const char *text=0);
632 static XEvent *new_xevent();
633 // delete all repeater opjects for a close
634 int unset_all_repeaters();
636 // Block and get event from common events.
638 // Return number of events in table.
639 int get_event_count();
640 // Put event in common events.
641 void put_event(XEvent *event);
642 // remove events queued for win
643 void dequeue_events(Window win);
645 int do_selection_clear(Atom selection);
647 // Recursive event dispatchers
648 int dispatch_resize_event(int w, int h);
649 int dispatch_flash();
650 int dispatch_focus_in();
651 int dispatch_focus_out();
652 int dispatch_motion_event();
653 int dispatch_keypress_event();
654 int dispatch_keyrelease_event();
655 int dispatch_repeat_event(int64_t duration);
656 int dispatch_repeat_event_master(int64_t duration);
657 int dispatch_button_press();
658 int dispatch_button_release();
659 int dispatch_cursor_leave();
660 int dispatch_cursor_enter();
661 int dispatch_translation_event();
662 int dispatch_drag_start();
663 int dispatch_drag_motion();
664 int dispatch_drag_stop();
665 int dispatch_expose_event();
666 int dispatch_selection_clear();
668 // Get the port ID for a color model or return -1 for failure
669 int grab_port_id(int color_model);
671 int find_next_textbox(BC_WindowBase **first_textbox, BC_WindowBase **next_textbox, int &result);
672 int find_prev_textbox(BC_WindowBase **last_textbox, BC_WindowBase **prev_textbox, int &result);
674 void xft_draw_string(XftColor *xft_color, XftFont *xft_font, int x, int y,
675 const FcChar32 *fc, int len, BC_Pixmap *pixmap=0);
677 void translate_coordinates(Window src_w, Window dest_w,
678 int src_x, int src_y, int *dest_x_return, int *dest_y_return);
680 // Top level window above this window
681 BC_WindowBase* top_level;
682 // Window just above this window
683 BC_WindowBase* parent_window;
684 // list of window bases in this window
685 BC_SubWindowList* subwindows;
686 // list of window bases in this window
687 ArrayList<BC_WindowBase*> popups;
688 // Position of window
691 int light1, light2, medium, dark1, dark2, bg_color;
692 // Type of window defined above
694 // keypress/pointer active grab
695 BC_WindowBase *active_grab, *grab_active;
696 // Pointer to the active menubar in the window.
697 BC_MenuBar* active_menubar;
698 // pointer to the active popup menu in the window
699 BC_PopupMenu* active_popup_menu;
700 // pointer to the active subwindow
701 BC_WindowBase* active_subwindow;
702 // pointer to the window to which to put the current event
703 BC_WindowBase* resend_event_window;
704 // thread id of display locker
705 pthread_t display_lock_owner;
709 int hidden, private_color, bits_per_pixel, color_model;
710 int server_byte_order, client_byte_order;
711 // number of colors in color table
713 // last color found in table
714 int current_color_value, current_color_pixel;
715 // table for every color allocated
716 int color_table[256][2];
717 // Turn on optimization
719 // Event handler completion
720 int done, done_set, window_running;
721 // Enter/Leave notify state
723 // Return value of event handler
725 // Motion event compression
726 int motion_events, last_motion_x, last_motion_y;
727 unsigned int last_motion_state;
728 // window of buffered motion
729 Window last_motion_win;
730 // Resize event compression
731 int resize_events, last_resize_w, last_resize_h;
732 int translation_events, last_translate_x, last_translate_y;
734 // Since the window manager automatically translates the window at boot,
735 // use the first translation event to get correction factors
736 int translation_count;
737 int x_correction, y_correction;
741 int ctrl_mask, shift_mask, alt_mask;
742 // Cursor motion information
743 int cursor_x, cursor_y;
744 // Button status information
745 int button_down, button_number;
746 // When button was pressed and whether it qualifies as a double click
747 int64_t button_time1;
748 int64_t button_time2;
749 int64_t button_time3;
752 // Which button is down. 1, 2, 3, 4, 5
756 int wkey_string_length;
757 wchr_t wkey_string[4];
758 #ifdef X_HAVE_UTF8_STRING
759 char* key_pressed_utf8;
761 // During a selection drag involving toggles, set the same value for each toggle
764 // Whether the window has the focus
767 static BC_Resources *resources;
769 #ifndef SINGLE_THREAD
770 // Array of repeaters for multiple repeating objects.
771 ArrayList<BC_Repeater*> repeaters;
772 int arm_repeat(int64_t duration);
774 // Text for tooltip if one exists
775 const char *tooltip_text;
776 // tooltip forced for this window
778 // If the current window's tooltip is visible
780 // Repeat ID of tooltip
781 // int64_t tooltip_id;
782 // Popup window for tooltip
783 BC_Popup *tooltip_popup;
784 // If this subwindow has already shown a tooltip since the last EnterNotify
789 XFontSet smallfontset, mediumfontset, largefontset, bigfontset, clockfontset;
790 XFontSet curr_fontset;
793 XFontStruct *smallfont, *mediumfont, *largefont, *bigfont, *clockfont;
794 // Must be void so users don't need to include the wrong libpng version.
795 void *smallfont_xft, *mediumfont_xft, *largefont_xft, *bigfont_xft, *clockfont_xft;
796 void *bold_smallfont_xft, *bold_mediumfont_xft, *bold_largefont_xft;
800 int64_t current_color;
801 // Coordinate of drag start
803 // Boundaries the cursor must pass to start a drag
804 int drag_x1, drag_x2, drag_y1, drag_y2;
805 // Dragging is specific to the subwindow
807 // Don't delete the background pixmap
808 int shared_bg_pixmap;
809 char title[BCTEXTLEN];
811 // *** CONTEXT_HELP ***
812 char context_help_keyword[BCTEXTLEN];
814 // X Window parameters
817 // windows previous events happened in
818 Window event_win, drag_win;
820 Atom event_selection;
824 char display_name[BCTEXTLEN];
825 // Display for all synchronous operations
828 int xinerama_screens;
829 XineramaScreenInfo *xinerama_info;
831 int glx_fb_configs(int *attrs, GLXFBConfig *&cfgs);
832 int glx_test_fb_configs(int *attrs, GLXFBConfig *&cfgs,
833 const char *msg, int &msgs);
834 GLXFBConfig *glx_fbcfgs_window, *glx_window_fb_configs();
836 GLXFBConfig *glx_fbcfgs_pbuffer, *glx_pbuffer_fb_configs();
837 int n_fbcfgs_pbuffer;
838 GLXFBConfig *glx_fbcfgs_pixmap, *glx_pixmap_fb_configs();
840 Visual *get_glx_visual(Display *display);
842 void sync_lock(const char *cp);
844 GLXWindow glx_window();
846 // The first context to be created and the one whose texture id
847 // space is shared with the other contexts.
848 GLXContext glx_get_context();
849 bool glx_make_current(GLXDrawable draw);
850 bool glx_make_current(GLXDrawable draw, GLXContext glx_ctxt);
852 GLXFBConfig glx_fb_config;
853 GLXContext glx_win_context;
859 // Depth given by the X Server
866 // Number of times start_hourglass was called
868 // Cursor set by last set_cursor which wasn't an hourglass or transparent.
870 // If hourglass overrides current cursor. Only effective in top level.
872 // If transparent overrides all cursors. Only effective in subwindow.
877 Cursor vseparate_cursor;
878 Cursor hseparate_cursor;
883 Cursor upright_arrow_cursor;
884 Cursor upleft_resize_cursor;
885 Cursor upright_resize_cursor;
886 Cursor downleft_resize_cursor;
887 Cursor downright_resize_cursor;
888 Cursor hourglass_cursor;
889 Cursor transparent_cursor;
890 Cursor grabbed_cursor;
893 ArrayList<BC_ResizeCall*> resize_history;
896 // Background tile if tiled
897 BC_Pixmap *bg_pixmap;
899 BC_Popup *icon_window;
900 BC_Pixmap *icon_pixmap;
901 BC_Pixmap **_7segment_pixmaps;
903 BC_Bitmap *temp_bitmap;
904 BC_ActiveBitmaps active_bitmaps;
906 #ifndef SINGLE_THREAD
907 BC_Clipboard *clipboard;
910 #ifdef HAVE_LIBXXF86VM
911 // Mode switch information.
913 XF86VidModeModeInfo orig_modeline;
919 #ifndef SINGLE_THREAD
920 // Common events coming from X server and repeater.
921 ArrayList<XEvent*> common_events;
922 // Locks for common events
924 // 1) event_condition
927 Condition *event_condition;
928 // Lock that waits until the event handler is running
929 Condition *init_lock;
931 Condition *completion_lock;
936 BC_WindowEvents *event_thread;
938 // Hide cursor when video is enabled
940 // unique ID of window.
943 // Used to communicate with the input method (IM) server
945 // Used for retaining the state, properties, and semantics
946 // of communication with the input method (IM) server
950 Atom create_xatom(const char *atom_name);
951 int send_custom_xatom(xatom_event *event);