#include <string.h>
#include <unistd.h>
#include <wchar.h>
+#include <typeinfo>
#include <X11/extensions/Xinerama.h>
#include <X11/extensions/Xvlib.h>
done = 0;
done_set = 0;
window_running = 0;
+ display_lock_owner = 0;
test_keypress = 0;
keys_return[0] = 0;
is_deleting = 0;
if(get_resources()->use_fontset && top_level->get_fontset(font))
return XmbTextEscapement(top_level->get_fontset(font), text, length);
else
- if(get_font_struct(font))
+ if(get_font_struct(font))
return XTextWidth(get_font_struct(font), text, length);
else
{
int BC_WindowBase::get_text_width(int font, const wchar_t *text, int length)
{
- int i, j, w = 0, line_w = 0;
+ int i, j, w = 0;
+ if( length < 0 ) length = wcslen(text);
- if(length < 0) length = wcslen(text);
-
- for(i = 0, j = 0; i <= length; i++)
- {
- line_w = 0;
- if(text[i] == '\n')
- {
- line_w = get_single_text_width(font, &text[j], i - j);
- j = i + 1;
+ for( i=j=0; i<length && text[i]; ++i ) {
+ if( text[i] != '\n' ) continue;
+ if( i > j ) {
+ int lw = get_single_text_width(font, &text[j], i-j);
+ if( w < lw ) w = lw;
}
- else
- if(text[i] == 0)
- line_w = get_single_text_width(font, &text[j], length - j);
-
- if(line_w > w) w = line_w;
+ j = i + 1;
+ }
+ if( j < length ) {
+ int lw = get_single_text_width(font, &text[j], length-j);
+ if( w < lw ) w = lw;
}
-
- if(i > length && w == 0)
- w = get_single_text_width(font, text, length);
return w;
}
ptr->message_type = SetDoneXAtom;
ptr->format = 32;
this->return_value = return_value;
-// May lock up here because XSendEvent doesn't work too well
+// May lock up here because XSendEvent doesn't work too well
// asynchronous with XNextEvent.
-// This causes BC_WindowEvents to forward a copy of the event to run_window where
+// This causes BC_WindowEvents to forward a copy of the event to run_window where
// it is deleted.
// Deletion of event_thread is done at the end of BC_WindowBase::run_window() - by calling the destructor
put_event(event);
return abs_y;
}
+int BC_WindowBase::get_pop_cursor_x(int lock_window)
+{
+ int margin = 100;
+ int px = get_abs_cursor_x(lock_window);
+ if( px < margin ) px = margin;
+ int wd = get_screen_w(lock_window,-1) - margin;
+ if( px > wd ) px = wd;
+ return px;
+}
+
+int BC_WindowBase::get_pop_cursor_y(int lock_window)
+{
+ int margin = 100;
+ int py = get_abs_cursor_y(lock_window);
+ if( py < margin ) py = margin;
+ int ht = get_screen_h(lock_window,-1) - margin;
+ if( py > ht ) py = ht;
+ return py;
+}
+
int BC_WindowBase::match_window(Window win)
{
if (this->win == win) return 1;
int BC_WindowBase::dump_windows()
{
- printf("\tBC_WindowBase::dump_windows window=%p win=%p\n",
- this, (void*)this->win);
+ printf("\tBC_WindowBase::dump_windows window=%p win=%p '%s', %dx%d+%d+%d %s\n",
+ this, (void*)this->win, title, w,h,x,y, typeid(*this).name());
for(int i = 0; i < subwindows->size(); i++)
subwindows->get(i)->dump_windows();
- for(int i = 0; i < popups.size(); i++)
- printf("\tBC_WindowBase::dump_windows popup=%p win=%p\n",
- popups.get(i), (void*)popups.get(i)->win);
+ for(int i = 0; i < popups.size(); i++) {
+ BC_WindowBase *p = popups[i];
+ printf("\tBC_WindowBase::dump_windows popup=%p win=%p '%s', %dx%d+%d+%d %s\n",
+ p, (void*)p->win, p->title, p->w,p->h,p->x,p->y, typeid(*p).name());
+ }
return 0;
}
}
+void BC_WindowBase::flicker(int n, int ms)
+{
+ int color = get_bg_color();
+ for( int i=2*n; --i>=0; ) {
+ set_inverse(); set_bg_color(WHITE);
+ clear_box(0,0, w,h); flash(1);
+ sync_display(); Timer::delay(ms);
+ }
+ set_bg_color(color);
+ set_opaque();
+}
+