{
// stop event input
XSelectInput(top_level->display, this->win, 0);
- motion_events = resize_events = translation_events = 0;
+ XSync(top_level->display,0);
#ifndef SINGLE_THREAD
top_level->dequeue_events(win);
#endif
- if(top_level->active_grab == this) top_level->active_grab = 0;
+// drop active window refs to this
if(top_level->active_menubar == this) top_level->active_menubar = 0;
if(top_level->active_popup_menu == this) top_level->active_popup_menu = 0;
if(top_level->active_subwindow == this) top_level->active_subwindow = 0;
+// drop motion window refs to this
+ if(top_level->motion_events && top_level->last_motion_win == this->win)
+ top_level->motion_events = 0;
+
// Remove pointer from parent window to this
parent_window->subwindows->remove(this);
}
+ if(grab_active) grab_active->active_grab = 0;
if(icon_window) delete icon_window;
if(window_type == POPUP_WINDOW)
parent_window->remove_popup(this);
last_motion_win = 0;
key_pressed = 0;
active_grab = 0;
+ grab_active = 0;
active_menubar = 0;
active_popup_menu = 0;
active_subwindow = 0;
}
return 0;
}
+void BC_WindowBase::set_tooltip_done(int v)
+{
+ tooltip_done = v;
+}
// signal the event handler to repeat
int BC_WindowBase::set_repeat(int64_t duration)
hourglass_cursor = XCreateFontCursor(display, XC_watch);
- char cursor_data[] = { 0,0,0,0, 0,0,0,0 };
+ static char cursor_data[] = { 0,0,0,0, 0,0,0,0 };
Colormap colormap = DefaultColormap(display, screen);
Pixmap pixmap_bottom = XCreateBitmapFromData(display,
rootwin, cursor_data, 8, 8);
pixmap_bottom, pixmap_bottom, &black, &black, 0, 0);
// XDefineCursor(display, win, transparent_cursor);
XFreePixmap(display, pixmap_bottom);
+
+ int iw = 23, iw1 = iw-1, iw2 = iw/2;
+ int ih = 23, ih1 = ih-1, ih2 = ih/2;
+ VFrame grab(iw,ih,BC_RGB888);
+ grab.clear_frame();
+ grab.set_pixel_color(RED); // fg
+ grab.draw_smooth(iw2,0, iw1,0, iw1,ih2);
+ grab.draw_smooth(iw1,ih2, iw1,ih1, iw2,ih1);
+ grab.draw_smooth(iw2,ih1, 0,ih1, 0,ih2);
+ grab.draw_smooth(0,ih2, 0,0, iw2,0);
+ grab.set_pixel_color(WHITE); // bg
+ grab.draw_line(0,ih2, iw2-2,ih2);
+ grab.draw_line(iw2+2,ih2, iw1,ih2);
+ grab.draw_line(iw2,0, iw2,ih2-2);
+ grab.draw_line(iw2,ih2+2, iw2,ih1);
+
+ int bpl = (iw+7)/8, isz = bpl * ih;
+ char img[isz]; memset(img, 0, isz);
+ char msk[isz]; memset(msk, 0, isz);
+ unsigned char **rows = grab.get_rows();
+ for( int iy=0; iy<ih; ++iy ) {
+ char *op = img + iy*bpl;
+ char *mp = msk + iy*bpl;
+ unsigned char *ip = rows[iy];
+ for( int ix=0; ix<iw; ++ix,ip+=3 ) {
+ if( ip[0] ) mp[ix>>3] |= (1<<(ix&7));
+ if( !ip[1] ) op[ix>>3] |= (1<<(ix&7));
+ }
+ }
+ unsigned long white_pix = WhitePixel(display, screen);
+ unsigned long black_pix = BlackPixel(display, screen);
+ Pixmap img_xpm = XCreatePixmapFromBitmapData(display, rootwin,
+ img, iw,ih, white_pix,black_pix, 1);
+ Pixmap msk_xpm = XCreatePixmapFromBitmapData(display, rootwin,
+ msk, iw,ih, white_pix,black_pix, 1);
+
+ XColor fc, bc;
+ fc.flags = bc.flags = DoRed | DoGreen | DoBlue;
+ fc.red = 0xffff; fc.green = fc.blue = 0; // fg
+ bc.red = bc.green = bc.blue = 0x0000; // bg
+ grabbed_cursor = XCreatePixmapCursor(display, img_xpm,msk_xpm, &fc,&bc, iw2,ih2);
+ XFreePixmap(display, img_xpm);
+ XFreePixmap(display, msk_xpm);
}
int BC_WindowBase::evaluate_color_model(int client_byte_order, int server_byte_order, int depth)
{
if( window->active_grab && this != window->active_grab ) return 0;
window->active_grab = this;
+ this->grab_active = window;
return 1;
}
int BC_WindowBase::ungrab(BC_WindowBase *window)
{
if( window->active_grab && this != window->active_grab ) return 0;
window->active_grab = 0;
+ this->grab_active = 0;
+ return 1;
+}
+int BC_WindowBase::grab_buttons()
+{
+ XSync(top_level->display, False);
+ if( XGrabButton(top_level->display, AnyButton, AnyModifier,
+ top_level->rootwin, True, ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeSync, None, grabbed_cursor) == GrabSuccess ) {
+ set_active_subwindow(this);
+ return 0;
+ }
return 1;
}
+void BC_WindowBase::ungrab_buttons()
+{
+ XUngrabButton(top_level->display, AnyButton, AnyModifier, top_level->rootwin);
+ set_active_subwindow(0);
+ unhide_cursor();
+}
+void BC_WindowBase::grab_cursor()
+{
+ XDefineCursor(top_level->display, top_level->rootwin, grabbed_cursor);
+}
+void BC_WindowBase::ungrab_cursor()
+{
+ XUndefineCursor(top_level->display, top_level->rootwin);
+}
int BC_WindowBase::get_w()
{
{
if(window_type == MAIN_WINDOW)
{
- if(top_level->active_menubar) top_level->active_menubar->deactivate();
- if(top_level->active_popup_menu) top_level->active_popup_menu->deactivate();
- if(top_level->active_subwindow) top_level->active_subwindow->deactivate();
+ if( top_level->active_menubar ) {
+ top_level->active_menubar->deactivate();
+ top_level->active_menubar = 0;
+ }
+ if( top_level->active_popup_menu ) {
+ top_level->active_popup_menu->deactivate();
+ top_level->active_popup_menu = 0;
+ }
+ if( top_level->active_subwindow ) {
+ top_level->active_subwindow->deactivate();
+ top_level->active_subwindow = 0;
+ }
+ if( top_level->motion_events && top_level->last_motion_win == this->win )
+ top_level->motion_events = 0;
- top_level->active_menubar = 0;
- top_level->active_popup_menu = 0;
- top_level->active_subwindow = 0;
}
return 0;
}
#endif
}
-int BC_WindowBase::get_relative_cursor_x()
+void BC_WindowBase::get_relative_cursor_xy(int &x, int &y, int lock_window)
{
- int abs_x, abs_y, x, y, win_x, win_y;
+ int abs_x, abs_y, win_x, win_y;
unsigned int temp_mask;
Window temp_win;
+ if(lock_window) this->lock_window("BC_WindowBase::get_relative_cursor_xy");
XQueryPointer(top_level->display, top_level->win,
&temp_win, &temp_win, &abs_x, &abs_y, &win_x, &win_y,
&temp_mask);
XTranslateCoordinates(top_level->display, top_level->rootwin,
win, abs_x, abs_y, &x, &y, &temp_win);
-
+ if(lock_window) this->unlock_window();
+}
+int BC_WindowBase::get_relative_cursor_x(int lock_window)
+{
+ int x, y;
+ get_relative_cursor_xy(x, y, lock_window);
return x;
}
-
-int BC_WindowBase::get_relative_cursor_y()
+int BC_WindowBase::get_relative_cursor_y(int lock_window)
{
- int abs_x, abs_y, x, y, win_x, win_y;
- unsigned int temp_mask;
- Window temp_win;
-
- XQueryPointer(top_level->display, top_level->win,
- &temp_win, &temp_win, &abs_x, &abs_y, &win_x, &win_y,
- &temp_mask);
-
- XTranslateCoordinates(top_level->display,
- top_level->rootwin, win, abs_x, abs_y, &x, &y, &temp_win);
-
+ int x, y;
+ get_relative_cursor_xy(x, y, lock_window);
return y;
}
-int BC_WindowBase::get_abs_cursor_x(int lock_window)
+void BC_WindowBase::get_abs_cursor_xy(int &abs_x, int &abs_y, int lock_window)
{
- int abs_x, abs_y, win_x, win_y;
+ int win_x, win_y;
unsigned int temp_mask;
Window temp_win;
- if(lock_window) this->lock_window("BC_WindowBase::get_abs_cursor_x");
+ if(lock_window) this->lock_window("BC_WindowBase::get_abs_cursor_xy");
XQueryPointer(top_level->display, top_level->win,
&temp_win, &temp_win, &abs_x, &abs_y, &win_x, &win_y,
&temp_mask);
if(lock_window) this->unlock_window();
+}
+int BC_WindowBase::get_abs_cursor_x(int lock_window)
+{
+ int abs_x, abs_y;
+ get_abs_cursor_xy(abs_x, abs_y, lock_window);
return abs_x;
}
-
int BC_WindowBase::get_abs_cursor_y(int lock_window)
{
- int abs_x, abs_y, win_x, win_y;
- unsigned int temp_mask;
- Window temp_win;
-
- if(lock_window) this->lock_window("BC_WindowBase::get_abs_cursor_y");
- XQueryPointer(top_level->display, top_level->win,
- &temp_win, &temp_win, &abs_x, &abs_y, &win_x, &win_y,
- &temp_mask);
- if(lock_window) this->unlock_window();
+ int abs_x, abs_y;
+ get_abs_cursor_xy(abs_x, abs_y, lock_window);
return abs_y;
}
-int BC_WindowBase::get_pop_cursor_x(int lock_window)
+void BC_WindowBase::get_pop_cursor_xy(int &px, int &py, int lock_window)
{
int margin = 100;
- int px = get_abs_cursor_x(lock_window);
+ get_abs_cursor_xy(px, py, lock_window);
if( px < margin ) px = margin;
+ if( py < margin ) py = margin;
int wd = get_screen_w(lock_window,-1) - margin;
if( px > wd ) px = wd;
+ int ht = get_screen_h(lock_window,-1) - margin;
+ if( py > ht ) py = ht;
+}
+int BC_WindowBase::get_pop_cursor_x(int lock_window)
+{
+ int px, py;
+ get_pop_cursor_xy(px, py, lock_window);
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;
+ int px, py;
+ get_pop_cursor_xy(px, py, lock_window);
return py;
}
int BC_WindowBase::cursor_above()
{
- int rx = get_relative_cursor_x();
- if( rx < 0 || rx >= get_w() ) return 0;
- int ry = get_relative_cursor_y();
- if( ry < 0 || ry >= get_h() ) return 0;
- return 1;
+ int rx, ry;
+ get_relative_cursor_xy(rx, ry);
+ return rx < 0 || rx >= get_w() ||
+ ry < 0 || ry >= get_h() ? 0 : 1;
}
int BC_WindowBase::get_drag_x()