-//printf("BC_ListBox::activate %d %p\n", __LINE__, this);
- if(!active)
- {
- if(take_focus)
- {
- top_level->active_subwindow = this;
- active = 1;
- }
-
- button_releases = 0;
-
-// Test for existence of GUI in case this was previously called without
-// take_focus & again with take_focus
- if(is_popup && !gui)
- {
- Window tempwin;
- int x, y;
- int new_x, new_y;
- y = get_y() + get_h();
- if(justify == LISTBOX_RIGHT)
- {
- x = get_x() - popup_w + get_w();
- }
- else
- {
- x = get_x();
- }
-
-
- XTranslateCoordinates(top_level->display,
- parent_window->win,
- top_level->rootwin,
- x,
- y,
- &new_x,
- &new_y,
- &tempwin);
-
- if(new_x < 0) new_x = 0;
- if(new_y + popup_h > top_level->get_root_h(0))
- new_y -= get_h() + popup_h;
-
- add_subwindow(gui = new BC_Popup(this,
- new_x,
- new_y,
- popup_w,
- popup_h,
- -1,
- 0,
- 0));
-// Avoid top going out of screen
- if(new_y < 0 )
- new_y = 2;
-//printf("BC_ListBox::activate %d this=%p %p\n", __LINE__, this, gui->win);
- draw_items(1);
- gui->show_window(1);
- }
-//printf("BC_ListBox::activate %d %p\n", __LINE__, this);
-//sleep(1);
- }
+ if( active ) return 0;
+ active = 1;
+ if( take_focus )
+ set_active_subwindow(this);
+ button_releases = 0;
+ if( !is_popup || gui ) return 0;
+ int wx = get_x(), wy = get_y() + get_h();
+ if( justify == LISTBOX_RIGHT ) wx += get_w() - popup_w;
+ Window xwin;
+ int abs_x, abs_y;
+ XTranslateCoordinates(top_level->display,
+ parent_window->win, top_level->rootwin,
+ wx, wy, &abs_x, &abs_y, &xwin);
+ if( x <= 0 ) x = 2;
+ if( y <= 0 ) y = 2;
+ return activate(abs_x, abs_y);
+}
+
+int BC_ListBox::activate(int x, int y, int w, int h)
+{
+ if( !is_popup || gui ) return 0;
+ active = 1;
+ if( w != -1 ) popup_w = w;
+ if( h != -1 ) popup_h = h;
+ reset_query();
+ if( y + popup_h > top_level->get_root_h(0) )
+ y -= get_h() + popup_h;
+ add_subwindow(gui = new BC_Popup(this,
+ x, y, popup_w, popup_h, -1, 0, 0));
+ draw_items(1);
+ gui->show_window(1);