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
103 //typedef void* GLXContext;
109 BC_ResizeCall(int w, int h);
113 typedef XClientMessageEvent xatom_event;
116 class BC_ActiveBitmaps : public List<BC_BitmapImage> {
119 void reque(XEvent *ev);
120 void insert(BC_BitmapImage *image, Drawable pixmap);
121 void remove_buffers(BC_WindowBase *wdw);
128 // Windows, subwindows, popupwindows inherit from this
129 class BC_WindowBase : public trace_info
133 virtual ~BC_WindowBase();
136 friend class BC_BitmapImage;
137 friend class BC_XImage;
138 friend class BC_XShmImage;
139 friend class BC_XvImage;
140 friend class BC_XvShmImage;
141 friend class BC_Bitmap;
142 friend class BC_Button;
143 friend class BC_GenericButton;
144 friend class BC_Capture;
145 friend class BC_Clipboard;
146 friend class BC_Display;
147 friend class BC_DragWindow;
148 friend class BC_FileBox;
149 friend class BC_FullScreen;
150 friend class BC_ListBox;
151 friend class BC_Menu;
152 friend class BC_MenuBar;
153 friend class BC_MenuItem;
154 friend class BC_MenuPopup;
155 friend class BC_Meter;
157 friend class BC_PBuffer;
158 friend class BC_Pixmap;
159 friend class BC_PixmapSW;
160 friend class BC_Popup;
161 friend class BC_PopupMenu;
163 friend class BC_ProgressBar;
164 friend class BC_Repeater;
165 friend class BC_Resources;
166 friend class BC_ScrollBar;
167 friend class BC_Slider;
168 friend class BC_SubWindow;
169 friend class BC_Synchronous;
170 friend class BC_TextBox;
171 friend class BC_Title;
172 friend class BC_Toggle;
173 friend class BC_Tumbler;
174 friend class BC_Window;
175 friend class BC_WindowEvents;
176 friend class Shuttle;
180 // Terminal event dispatchers
181 virtual int close_event();
182 virtual int resize_event(int w, int h);
183 virtual int repeat_event(int64_t duration) { return 0; };
184 virtual int focus_in_event() { return 0; };
185 virtual int focus_out_event() { return 0; };
186 virtual int button_press_event() { return 0; };
187 virtual int button_release_event() { return 0; };
188 virtual int cursor_motion_event() { return 0; };
189 virtual int cursor_leave_event();
190 virtual int cursor_enter_event();
191 virtual int keypress_event() { return 0; };
192 virtual int keyrelease_event() { return 0; };
193 virtual int translation_event() { return 0; };
194 virtual int drag_start_event() { return 0; };
195 virtual int drag_motion_event() { return 0; };
196 virtual int drag_stop_event() { return 0; };
197 virtual int uses_text() { return 0; };
198 virtual int selection_clear_event() { return 0; }
199 // Only if opengl is enabled
200 virtual int expose_event() { return 0; };
201 virtual int grab_event(XEvent *event) { return 0; };
202 virtual void create_objects() { return; };
204 int get_window_type() { return window_type; }
205 // Wait until event loop is running
207 int is_running() { return window_running; }
208 int is_hidden() { return hidden; }
209 // Check if a hardware accelerated colormodel is available and reserve it
210 int accel_available(int color_model, int lock_it);
211 void get_input_context();
212 void close_input_context();
213 // Get color model adjusted for byte order and pixel size
214 int get_color_model();
215 // return the colormap pixel of the color for all bit depths
216 int get_color(int64_t color);
217 // return the currently selected color
219 virtual int show_window(int flush = 1);
220 virtual int hide_window(int flush = 1);
223 // Shouldn't deference a pointer to delete a window if a parent is
224 // currently being deleted. This returns 1 if any parent is being deleted.
228 //============================= OpenGL functions ===============================
229 // OpenGL functions must be called from inside a BC_Synchronous command.
230 // Create openGL context and bind it to the current window.
231 // If it's called inside start_video/stop_video, the context is bound to the window.
232 // If it's called outside start_video/stop_video, the context is bound to the pixmap.
233 // Must be called at the beginning of any opengl routine to make sure
234 // the context is current.
235 // No locking is performed.
236 void enable_opengl();
237 void disable_opengl();
240 // Calls the BC_Synchronous version of the function with the window_id.
241 // Not run in OpenGL thread because it has its own lock.
242 unsigned int get_shader(char *title, int *got_it);
243 void put_shader(unsigned int handle, char *title);
244 int get_opengl_server_version();
246 int flash(int x, int y, int w, int h, int flush = 1);
247 int flash(int flush = 1);
250 // Lock out other threads
251 int lock_window(const char *location = 0);
253 int get_window_lock();
255 BC_MenuBar* add_menubar(BC_MenuBar *menu_bar);
256 BC_WindowBase* add_subwindow(BC_WindowBase *subwindow);
257 BC_WindowBase* add_tool(BC_WindowBase *subwindow);
259 // Use this to get events for the popup window.
260 // Events are not propagated to the popup window.
261 BC_WindowBase* add_popup(BC_WindowBase *window);
262 void remove_popup(BC_WindowBase *window);
264 static BC_Resources* get_resources();
265 // User must create synchronous object first
266 static BC_Synchronous* get_synchronous();
267 static int shm_completion_event;
268 // bckeyboard / remote control
269 virtual int keyboard_listener(BC_WindowBase *wp) { return 0; }
270 void add_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
271 void del_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
272 int resend_event(BC_WindowBase *window);
274 virtual int get_w() { return w; }
275 virtual int get_h() { return h; }
276 virtual int get_x() { return x; }
277 virtual int get_y() { return y; }
278 int get_root_w(int lock_display);
279 int get_root_h(int lock_display);
280 XineramaScreenInfo *get_xinerama_info(int screen);
281 void get_fullscreen_geometry(int &wx, int &wy, int &ww, int &wh);
282 int get_screen_w(int lock_display, int screen);
283 int get_screen_h(int lock_display, int screen);
284 int get_screen_x(int lock_display, int screen);
285 int get_screen_y(int lock_display, int screen);
286 // Get current position
287 void get_abs_cursor(int &abs_x, int &abs_y, int lock_window=0);
288 int get_abs_cursor_x(int lock_window=0);
289 int get_abs_cursor_y(int lock_window=0);
290 void get_pop_cursor(int &px, int &py, int lock_window=0);
291 int get_pop_cursor_x(int lock_window=0);
292 int get_pop_cursor_y(int lock_window=0);
293 void get_relative_cursor(int &x, int &y, int lock_window=0);
294 int get_relative_cursor_x(int lock_window=0);
295 int get_relative_cursor_y(int lock_window=0);
296 void get_root_coordinates(int x, int y, int *abs_x, int *abs_y);
297 void get_win_coordinates(int abs_x, int abs_y, int *x, int *y);
298 // Return 1 if cursor is over an unobscured part of this window.
299 // An argument is provided for excluding a drag popup
300 int get_cursor_over_window();
301 // Return 1 if cursor is above/inside window
303 // For traversing windows... return 1 if this or any subwindow is win
304 int match_window(Window win);
306 // 1 or 0 if a button is down
307 int get_button_down();
308 // Number of button pressed 1 - 5
309 int get_buttonpress();
312 wchar_t* get_wkeystring(int *length = 0);
314 int get_keysym() { return keysym; }
315 #ifdef X_HAVE_UTF8_STRING
316 char* get_keypress_utf8();
318 int keysym_lookup(XEvent *event);
319 // Get cursor position of last event
322 // Cursor position of drag start
328 int get_double_click();
329 int get_triple_click();
330 // Bottom right corner
334 void set_bg_color(int color);
335 BC_Pixmap* get_bg_pixmap();
336 int get_text_ascent(int font);
337 int get_text_descent(int font);
338 int get_text_height(int font, const char *text = 0);
339 int get_text_width(int font, const char *text, int length = -1);
340 int get_text_width(int font, const wchar_t *text, int length = -1);
341 BC_Clipboard* get_clipboard();
342 void set_dragging(int value);
345 BC_WindowBase* get_top_level();
346 BC_WindowBase* get_parent();
347 // Event happened in this window
350 // Deactivate everything and activate this subwindow
351 virtual int activate();
352 // Deactivate this subwindow
353 virtual int deactivate();
354 void set_active_subwindow(BC_WindowBase *subwindow);
355 // Get value of toggle value when dragging a selection
356 int get_toggle_value();
357 // Get if toggle is being dragged
358 int get_toggle_drag();
360 // Set the gc to the color
361 void set_color(int64_t color);
362 void set_line_width(int value);
363 void set_line_dashes(int value);
365 int get_current_font();
366 void set_font(int font);
367 // Set the cursor to a macro from cursors.h
368 // Set override if the caller is enabling hourglass or hiding the cursor
369 void set_cursor(int cursor, int override /* = 0 */, int flush);
370 // Set the cursor to a character in the X cursor library. Used by test.C
371 void set_x_cursor(int cursor);
373 // Shows the cursor after it's hidden by video playback
374 void unhide_cursor();
375 // Called by video updating routines to hide the cursor after a timeout
376 void update_video_cursor();
378 // Entry point for starting hourglass.
379 // Converts all cursors and saves the previous cursor.
380 void start_hourglass();
381 void stop_hourglass();
383 // Recursive part of hourglass commands.
384 void start_hourglass_recursive();
385 void stop_hourglass_recursive();
387 BC_Pixmap *create_pixmap(VFrame *vframe);
390 void copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap = 0);
391 void clear_box(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
392 void draw_box(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
393 void draw_circle(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
394 void draw_arc(int x, int y, int w, int h,
395 int start_angle, int angle_length, BC_Pixmap *pixmap = 0);
396 void draw_disc(int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
397 void draw_text(int x, int y, const char *text, int length = -1, BC_Pixmap *pixmap = 0);
398 void draw_utf8_text(int x, int y, const char *text, int length = -1, BC_Pixmap *pixmap = 0);
399 void draw_text_line(int x, int y, const char *text, int len, BC_Pixmap *pixmap = 0);
400 void draw_xft_text(int x, int y, const char *text, int len,
401 BC_Pixmap *pixmap = 0, int is_utf8 = 0);
402 void draw_xft_text(int x, int y, const wchar_t *text,
403 int length, BC_Pixmap *pixmap);
404 int draw_single_text(int draw, int font,
405 int x, int y, const wchar_t *text, int length = -1, BC_Pixmap *pixmap = 0);
406 // truncate the text to a ... version that fits in the width, using the current_font
407 void truncate_text(char *result, const char *text, int w);
408 void draw_center_text(int x, int y, const char *text, int length = -1);
409 void draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap = 0);
410 void draw_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap = 0);
411 void fill_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap = 0);
412 void draw_rectangle(int x, int y, int w, int h);
413 void draw_3segment(int x, int y, int w, int h, BC_Pixmap *left_image,
414 BC_Pixmap *mid_image, BC_Pixmap *right_image, BC_Pixmap *pixmap = 0);
415 void draw_3segment(int x, int y, int w, int h, VFrame *left_image,
416 VFrame *mid_image, VFrame *right_image, BC_Pixmap *pixmap = 0);
417 // For drawing a changing level
418 void draw_3segmenth(int x, int y, int w, int total_x, int total_w,
419 VFrame *image, BC_Pixmap *pixmap);
420 void draw_3segmenth(int x, int y, int w, int total_x, int total_w,
421 BC_Pixmap *src, BC_Pixmap *dst = 0);
422 void draw_3segmentv(int x, int y, int h, int total_y, int total_h,
423 BC_Pixmap *src, BC_Pixmap *dst = 0);
424 void draw_3segmentv(int x, int y, int h, int total_y, int total_h,
425 VFrame *src, BC_Pixmap *dst = 0);
426 // For drawing a single level
427 void draw_3segmenth(int x, int y, int w, VFrame *image, BC_Pixmap *pixmap = 0);
428 void draw_3segmenth(int x, int y, int w, BC_Pixmap *src, BC_Pixmap *dst = 0);
429 void draw_3segmentv(int x, int y, int h, BC_Pixmap *src, BC_Pixmap *dst = 0);
430 void draw_3segmentv(int x, int y, int h, VFrame *src, BC_Pixmap *dst = 0);
431 void draw_9segment(int x, int y, int w, int h, VFrame *src, BC_Pixmap *dst = 0);
432 void draw_9segment(int x, int y, int w, int h, BC_Pixmap *src, BC_Pixmap *dst = 0);
433 void draw_3d_box(int x, int y, int w, int h, int light1, int light2,
434 int middle, int shadow1, int shadow2, BC_Pixmap *pixmap = 0);
435 void draw_3d_box(int x, int y, int w, int h, int is_down, BC_Pixmap *pixmap = 0);
436 void draw_3d_border(int x, int y, int w, int h,
437 int light1, int light2, int shadow1, int shadow2);
438 void draw_3d_border(int x, int y, int w, int h, int is_down);
439 void draw_colored_box(int x, int y, int w, int h, int down, int highlighted);
440 void draw_check(int x, int y);
441 void draw_triangle_down_flat(int x, int y, int w, int h);
442 void draw_triangle_up(int x, int y, int w, int h,
443 int light1, int light2, int middle, int shadow1, int shadow2);
444 void draw_triangle_down(int x, int y, int w, int h,
445 int light1, int light2, int middle, int shadow1, int shadow2);
446 void draw_triangle_left(int x, int y, int w, int h,
447 int light1, int light2, int middle, int shadow1, int shadow2);
448 void draw_triangle_right(int x, int y, int w, int h,
449 int light1, int light2, int middle, int shadow1, int shadow2);
450 // Set the gc to opaque
453 void set_background(VFrame *bitmap);
454 // Change the window title.
455 void put_title(const char *text);
456 void set_title(const char *text, int utf8=1);
457 const char *get_title();
458 // Change the window title. The title is translated internally.
462 void set_done(int return_value);
463 void close(int return_value);
464 // Reroute toplevel events
465 int grab(BC_WindowBase *window);
466 int ungrab(BC_WindowBase *window);
467 int grab_event_count();
468 // Grab button events
470 void ungrab_buttons();
472 void ungrab_cursor();
473 // Get a bitmap to draw on the window with
474 BC_Bitmap* new_bitmap(int w, int h, int color_model = -1);
475 // Draw a bitmap on the window
476 void draw_bitmap(BC_Bitmap *bitmap, int dont_wait,
477 int dest_x = 0, int dest_y = 0, int dest_w = 0, int dest_h = 0,
478 int src_x = 0, int src_y = 0, int src_w = 0, int src_h = 0,
479 BC_Pixmap *pixmap = 0);
480 void draw_pixel(int x, int y, BC_Pixmap *pixmap = 0);
481 // Draw a pixmap on the window
482 void draw_pixmap(BC_Pixmap *pixmap,
483 int dest_x = 0, int dest_y = 0, int dest_w = -1, int dest_h = -1,
484 int src_x = 0, int src_y = 0, BC_Pixmap *dst = 0);
485 // Draw a vframe on the window
486 void draw_vframe(VFrame *frame,
487 int dest_x = 0, int dest_y = 0, int dest_w = -1, int dest_h = -1,
488 int src_x = 0, int src_y = 0, int src_w = 0, int src_h = 0,
489 BC_Pixmap *pixmap = 0);
490 void draw_border(char *text, int x, int y, int w, int h);
491 // Draw a region of the background
492 void draw_top_background(BC_WindowBase *parent_window, int x, int y, int w, int h, BC_Pixmap *pixmap = 0);
493 void draw_top_tiles(BC_WindowBase *parent_window, int x, int y, int w, int h);
494 void draw_background(int x, int y, int w, int h);
495 void draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y,
496 int x, int y, int w, int h);
497 void slide_left(int distance);
498 void slide_right(int distance);
499 void slide_up(int distance);
500 void slide_down(int distance);
501 void flicker(int n=3, int ms=66);
504 int cycle_textboxes(int amount);
506 int raise_window(int do_flush = 1);
507 int lower_window(int do_flush = 1);
508 void set_force_tooltip(int v);
509 void set_tooltips(int v);
510 int resize_window(int w, int h);
511 int reposition_window(int x, int y);
512 int reposition_window(int x, int y, int w, int h);
513 int reposition_window_relative(int dx, int dy);
514 int reposition_window_relative(int dx, int dy, int w, int h);
515 // Cause a repeat event to be dispatched every duration.
516 // duration is milliseconds
517 int set_repeat(int64_t duration);
518 // Stop a repeat event from being dispatched.
519 int unset_repeat(int64_t duration);
520 const char *get_tooltip();
521 int set_tooltip(const char *text);
522 virtual int show_tooltip(const char *text, int x=-1, int y=-1, int w = -1, int h = -1);
523 int show_tooltip(int w=-1, int h=-1) { return show_tooltip(0, -1, -1, w, h); }
525 int set_icon(VFrame *data);
526 int load_defaults(BC_Hash *defaults);
527 int save_defaults(BC_Hash *defaults);
529 #ifdef HAVE_LIBXXF86VM
530 // Mode switch methods.
531 void closest_vm(int *vm, int *width, int *height);
532 void scale_vm(int vm);
536 Atom to_clipboard(const char *data, long len, int clipboard_num);
537 long from_clipboard(char *data, long maxlen, int clipboard_num);
538 long clipboard_len(int clipboard_num);
541 char keys_return[KEYPRESSLEN];
546 virtual int create_window(BC_WindowBase *parent_window,
547 const char *title, int x, int y, int w, int h,
548 int minw, int minh, int allow_resize, int private_color,
549 int hide, int bg_color, const char *display_name,
550 int window_type, BC_Pixmap *bg_pixmap, int group_it);
552 static Display* init_display(const char *display_name);
553 // Get display from top level
554 Display* get_display();
556 virtual int initialize();
558 // Function to overload to receive customly defined atoms
559 virtual int receive_custom_xatoms(xatom_event *event);
563 int init_window_shape();
564 static int evaluate_color_model(int client_byte_order, int server_byte_order, int depth);
565 int create_private_colors();
566 int create_color(int color);
567 int create_shared_colors();
568 Cursor create_grab_cursor();
569 // Get width of a single line. Used by get_text_width
570 int get_single_text_width(int font, const char *text, int length);
571 int get_single_text_width(int font, const wchar_t *text, int length);
572 int allocate_color_table();
578 int get_color_rgb8(int color);
579 int64_t get_color_rgb16(int color);
580 int64_t get_color_bgr16(int color);
581 int64_t get_color_bgr24(int color);
582 XFontStruct* get_font_struct(int font);
583 XftFont* get_xft_struct(int font);
584 Cursor get_cursor_struct(int cursor);
585 XFontSet get_fontset(int font);
586 XFontSet get_curr_fontset(void);
587 void set_fontset(int font);
588 int dispatch_event(XEvent *event);
590 int get_key_masks(unsigned int key_state);
592 int trigger_tooltip();
593 int untrigger_tooltip();
594 void draw_tooltip(const char *text=0);
595 static XEvent *new_xevent();
596 // delete all repeater opjects for a close
597 int unset_all_repeaters();
599 // Block and get event from common events.
601 // Return number of events in table.
602 int get_event_count();
603 // Put event in common events.
604 void put_event(XEvent *event);
605 // remove events queued for win
606 void dequeue_events(Window win);
608 int do_selection_clear(Atom selection);
610 // Recursive event dispatchers
611 int dispatch_resize_event(int w, int h);
612 int dispatch_flash();
613 int dispatch_focus_in();
614 int dispatch_focus_out();
615 int dispatch_motion_event();
616 int dispatch_keypress_event();
617 int dispatch_keyrelease_event();
618 int dispatch_repeat_event(int64_t duration);
619 int dispatch_repeat_event_master(int64_t duration);
620 int dispatch_button_press();
621 int dispatch_button_release();
622 int dispatch_cursor_leave();
623 int dispatch_cursor_enter();
624 int dispatch_translation_event();
625 int dispatch_drag_start();
626 int dispatch_drag_motion();
627 int dispatch_drag_stop();
628 int dispatch_expose_event();
629 int dispatch_selection_clear();
631 // Get the port ID for a color model or return -1 for failure
632 int grab_port_id(int color_model);
634 int find_next_textbox(BC_WindowBase **first_textbox, BC_WindowBase **next_textbox, int &result);
635 int find_prev_textbox(BC_WindowBase **last_textbox, BC_WindowBase **prev_textbox, int &result);
637 void xft_draw_string(XftColor *xft_color, XftFont *xft_font, int x, int y,
638 const FcChar32 *fc, int len, BC_Pixmap *pixmap=0);
640 void translate_coordinates(Window src_w, Window dest_w,
641 int src_x, int src_y, int *dest_x_return, int *dest_y_return);
643 // Top level window above this window
644 BC_WindowBase* top_level;
645 // Window just above this window
646 BC_WindowBase* parent_window;
647 // list of window bases in this window
648 BC_SubWindowList* subwindows;
649 // list of window bases in this window
650 ArrayList<BC_WindowBase*> popups;
651 // Position of window
654 int light1, light2, medium, dark1, dark2, bg_color;
655 // Type of window defined above
657 // keypress/pointer active grab
658 BC_WindowBase *active_grab, *grab_active;
659 // Pointer to the active menubar in the window.
660 BC_MenuBar* active_menubar;
661 // pointer to the active popup menu in the window
662 BC_PopupMenu* active_popup_menu;
663 // pointer to the active subwindow
664 BC_WindowBase* active_subwindow;
665 // pointer to the window to which to put the current event
666 BC_WindowBase* resend_event_window;
667 // thread id of display locker
668 pthread_t display_lock_owner;
672 int hidden, private_color, bits_per_pixel, color_model;
673 int server_byte_order, client_byte_order;
674 // number of colors in color table
676 // last color found in table
677 int current_color_value, current_color_pixel;
678 // table for every color allocated
679 int color_table[256][2];
680 // Turn on optimization
682 // Event handler completion
683 int done, done_set, window_running;
684 // Enter/Leave notify state
686 // Return value of event handler
688 // Motion event compression
689 int motion_events, last_motion_x, last_motion_y;
690 unsigned int last_motion_state;
691 // window of buffered motion
692 Window last_motion_win;
693 // Resize event compression
694 int resize_events, last_resize_w, last_resize_h;
695 int translation_events, last_translate_x, last_translate_y;
697 // Since the window manager automatically translates the window at boot,
698 // use the first translation event to get correction factors
699 int translation_count;
700 int x_correction, y_correction;
704 int ctrl_mask, shift_mask, alt_mask;
705 // Cursor motion information
706 int cursor_x, cursor_y;
707 // Button status information
708 int button_down, button_number;
709 // When button was pressed and whether it qualifies as a double click
710 int64_t button_time1;
711 int64_t button_time2;
712 int64_t button_time3;
715 // Which button is down. 1, 2, 3, 4, 5
719 int wkey_string_length;
720 wchar_t wkey_string[4];
721 #ifdef X_HAVE_UTF8_STRING
722 char* key_pressed_utf8;
724 // During a selection drag involving toggles, set the same value for each toggle
727 // Whether the window has the focus
730 static BC_Resources resources;
732 #ifndef SINGLE_THREAD
733 // Array of repeaters for multiple repeating objects.
734 ArrayList<BC_Repeater*> repeaters;
735 int arm_repeat(int64_t duration);
737 // Text for tooltip if one exists
738 const char *tooltip_text;
739 // tooltip forced for this window
741 // If the current window's tooltip is visible
743 // Repeat ID of tooltip
744 // int64_t tooltip_id;
745 // Popup window for tooltip
746 BC_Popup *tooltip_popup;
747 // If this subwindow has already shown a tooltip since the last EnterNotify
752 XFontSet smallfontset, mediumfontset, largefontset, bigfontset, clockfontset;
753 XFontSet curr_fontset;
756 XFontStruct *smallfont, *mediumfont, *largefont, *bigfont, *clockfont;
757 // Must be void so users don't need to include the wrong libpng version.
758 void *smallfont_xft, *mediumfont_xft, *largefont_xft, *bigfont_xft, *clockfont_xft;
759 void *bold_smallfont_xft, *bold_mediumfont_xft, *bold_largefont_xft;
763 int64_t current_color;
764 // Coordinate of drag start
766 // Boundaries the cursor must pass to start a drag
767 int drag_x1, drag_x2, drag_y1, drag_y2;
768 // Dragging is specific to the subwindow
770 // Don't delete the background pixmap
771 int shared_bg_pixmap;
772 char title[BCTEXTLEN];
774 // X Window parameters
777 // windows previous events happened in
778 Window event_win, drag_win;
780 Atom event_selection;
784 char display_name[BCTEXTLEN];
785 // Display for all synchronous operations
788 int xinerama_screens;
789 XineramaScreenInfo *xinerama_info;
791 int glx_fb_configs(int *attrs, GLXFBConfig *&cfgs);
792 int glx_test_fb_configs(int *attrs, GLXFBConfig *&cfgs,
793 const char *msg, int &msgs);
794 GLXFBConfig *glx_fbcfgs_window, *glx_window_fb_configs();
796 GLXFBConfig *glx_fbcfgs_pbuffer, *glx_pbuffer_fb_configs();
797 int n_fbcfgs_pbuffer;
798 GLXFBConfig *glx_fbcfgs_pixmap, *glx_pixmap_fb_configs();
800 Visual *get_glx_visual(Display *display);
802 void sync_lock(const char *cp);
804 GLXWindow glx_window();
806 // The first context to be created and the one whose texture id
807 // space is shared with the other contexts.
808 GLXContext glx_get_context();
809 bool glx_make_current(GLXDrawable draw);
810 bool glx_make_current(GLXDrawable draw, GLXContext glx_ctxt);
812 GLXFBConfig glx_fb_config;
813 GLXContext glx_win_context;
819 // Depth given by the X Server
826 // Number of times start_hourglass was called
828 // Cursor set by last set_cursor which wasn't an hourglass or transparent.
830 // If hourglass overrides current cursor. Only effective in top level.
832 // If transparent overrides all cursors. Only effective in subwindow.
837 Cursor vseparate_cursor;
838 Cursor hseparate_cursor;
843 Cursor upright_arrow_cursor;
844 Cursor upleft_resize_cursor;
845 Cursor upright_resize_cursor;
846 Cursor downleft_resize_cursor;
847 Cursor downright_resize_cursor;
848 Cursor hourglass_cursor;
849 Cursor transparent_cursor;
850 Cursor grabbed_cursor;
853 ArrayList<BC_ResizeCall*> resize_history;
856 // Background tile if tiled
857 BC_Pixmap *bg_pixmap;
859 BC_Popup *icon_window;
860 BC_Pixmap *icon_pixmap;
861 BC_Pixmap **_7segment_pixmaps;
863 BC_Bitmap *temp_bitmap;
864 BC_ActiveBitmaps active_bitmaps;
866 #ifndef SINGLE_THREAD
867 BC_Clipboard *clipboard;
870 #ifdef HAVE_LIBXXF86VM
871 // Mode switch information.
873 XF86VidModeModeInfo orig_modeline;
879 #ifndef SINGLE_THREAD
880 // Common events coming from X server and repeater.
881 ArrayList<XEvent*> common_events;
882 // Locks for common events
884 // 1) event_condition
887 Condition *event_condition;
888 // Lock that waits until the event handler is running
889 Condition *init_lock;
891 Condition *completion_lock;
898 BC_WindowEvents *event_thread;
900 // Hide cursor when video is enabled
902 // unique ID of window.
905 // Used to communicate with the input method (IM) server
907 // Used for retaining the state, properties, and semantics
908 // of communication with the input method (IM) server
912 Atom create_xatom(const char *atom_name);
913 int send_custom_xatom(xatom_event *event);