Move platform-dependent implementations of fl_open/close_display() to the Fl_Screen_Driver class
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11619 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
15715cd898
commit
2fcb4f4192
8
FL/Fl.H
8
FL/Fl.H
@ -842,15 +842,7 @@ int main() {
|
||||
static int event_inside(const Fl_Widget*);
|
||||
static int test_shortcut(Fl_Shortcut);
|
||||
|
||||
/**
|
||||
Enables the system input methods facilities. This is the default.
|
||||
\see disable_im()
|
||||
*/
|
||||
static void enable_im();
|
||||
/**
|
||||
Disables the system input methods facilities.
|
||||
\see enable_im()
|
||||
*/
|
||||
static void disable_im();
|
||||
|
||||
// event destinations:
|
||||
|
@ -138,6 +138,10 @@ public:
|
||||
// optional methods to enable/disable input methods for complex scripts
|
||||
virtual void enable_im() {}
|
||||
virtual void disable_im() {}
|
||||
// implement to open access to the display
|
||||
virtual void open_display() {}
|
||||
// optional method to close display access
|
||||
virtual void close_display() {}
|
||||
};
|
||||
|
||||
|
||||
|
18
src/Fl.cxx
18
src/Fl.cxx
@ -1941,16 +1941,34 @@ int Fl::clipboard_contains(const char *type)
|
||||
return Fl::system_driver()->clipboard_contains(type);
|
||||
}
|
||||
|
||||
/**
|
||||
Enables the system input methods facilities. This is the default.
|
||||
\see disable_im()
|
||||
*/
|
||||
void Fl::enable_im()
|
||||
{
|
||||
Fl::screen_driver()->enable_im();
|
||||
}
|
||||
|
||||
/**
|
||||
Disables the system input methods facilities.
|
||||
\see enable_im()
|
||||
*/
|
||||
void Fl::disable_im()
|
||||
{
|
||||
Fl::screen_driver()->disable_im();
|
||||
}
|
||||
|
||||
void fl_open_display()
|
||||
{
|
||||
Fl::screen_driver()->open_display();
|
||||
}
|
||||
|
||||
void fl_close_display()
|
||||
{
|
||||
Fl::screen_driver()->close_display();
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -1721,7 +1721,7 @@ void fl_open_callback(void (*cb)(const char *)) {
|
||||
}
|
||||
*/
|
||||
|
||||
void fl_open_display() {
|
||||
void Fl_Cocoa_Screen_Driver::open_display() {
|
||||
static char beenHereDoneThat = 0;
|
||||
if ( !beenHereDoneThat ) {
|
||||
beenHereDoneThat = 1;
|
||||
@ -1797,12 +1797,6 @@ void fl_open_display() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get rid of allocated resources
|
||||
*/
|
||||
void fl_close_display() {
|
||||
}
|
||||
|
||||
// Force a "Roman" or "ASCII" keyboard, which both the Mozilla and
|
||||
// Safari people seem to think implies turning off advanced IME stuff
|
||||
// (see nsTSMManager::SyncKeyScript in Mozilla and enableSecureTextInput
|
||||
@ -1883,7 +1877,7 @@ int Fl_Cocoa_Screen_Driver::x() {
|
||||
* smallest y coordinate in screen space of work area of menubar-containing display
|
||||
*/
|
||||
int Fl_Cocoa_Screen_Driver::y() {
|
||||
fl_open_display();
|
||||
open_display();
|
||||
NSRect visible = [[[NSScreen screens] objectAtIndex:0] visibleFrame];
|
||||
return int(main_screen_height - (visible.origin.y + visible.size.height));
|
||||
}
|
||||
@ -1909,7 +1903,7 @@ void Fl_Cocoa_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, in
|
||||
{
|
||||
if (num_screens < 0) init();
|
||||
if (n < 0 || n >= num_screens) n = 0;
|
||||
fl_open_display();
|
||||
open_display();
|
||||
NSRect r = [[[NSScreen screens] objectAtIndex:n] visibleFrame];
|
||||
X = int(r.origin.x);
|
||||
Y = main_screen_height - int(r.origin.y + r.size.height);
|
||||
@ -1922,7 +1916,7 @@ void Fl_Cocoa_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, in
|
||||
*/
|
||||
void Fl_Cocoa_Screen_Driver::get_mouse(int &x, int &y)
|
||||
{
|
||||
fl_open_display();
|
||||
open_display();
|
||||
NSPoint pt = [NSEvent mouseLocation];
|
||||
x = int(pt.x);
|
||||
y = int(main_screen_height - pt.y);
|
||||
|
@ -515,7 +515,7 @@ int fl_ready() {
|
||||
return get_wsock_mod() ? s_wsock_select(0,&fdt[0],&fdt[1],&fdt[2],&t) : 0;
|
||||
}
|
||||
|
||||
void fl_open_display() {
|
||||
void Fl_WinAPI_Screen_Driver::open_display() {
|
||||
static char beenHereDoneThat = 0;
|
||||
|
||||
if (beenHereDoneThat)
|
||||
@ -549,7 +549,7 @@ static Fl_Win32_At_Exit win32_at_exit;
|
||||
static char im_enabled = 1;
|
||||
|
||||
void Fl_WinAPI_Screen_Driver::enable_im() {
|
||||
fl_open_display();
|
||||
open_display();
|
||||
|
||||
Fl_X* i = Fl_X::first;
|
||||
while (i) {
|
||||
@ -561,7 +561,7 @@ void Fl_WinAPI_Screen_Driver::enable_im() {
|
||||
}
|
||||
|
||||
void Fl_WinAPI_Screen_Driver::disable_im() {
|
||||
fl_open_display();
|
||||
open_display();
|
||||
|
||||
Fl_X* i = Fl_X::first;
|
||||
while (i) {
|
||||
|
@ -669,7 +669,7 @@ void Fl_X11_Screen_Driver::disable_im() {
|
||||
fl_xim_deactivate();
|
||||
}
|
||||
|
||||
void fl_open_display() {
|
||||
void Fl_X11_Screen_Driver::open_display() {
|
||||
if (fl_display) return;
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
@ -782,14 +782,14 @@ void fl_open_display(Display* d) {
|
||||
XSelectInput(d, RootWindow(d, fl_screen), PropertyChangeMask);
|
||||
}
|
||||
|
||||
void fl_close_display() {
|
||||
void Fl_X11_Screen_Driver::close_display() {
|
||||
Fl::remove_fd(ConnectionNumber(fl_display));
|
||||
XCloseDisplay(fl_display);
|
||||
}
|
||||
|
||||
|
||||
void Fl_X11_Screen_Driver::get_mouse(int &xx, int &yy) {
|
||||
fl_open_display();
|
||||
open_display();
|
||||
Window root = RootWindow(fl_display, fl_screen);
|
||||
Window c; int mx,my,cx,cy; unsigned int mask;
|
||||
XQueryPointer(fl_display,root,&root,&c,&mx,&my,&cx,&cy,&mask);
|
||||
|
@ -93,6 +93,7 @@ public:
|
||||
virtual void get_mouse(int &x, int &y);
|
||||
virtual void enable_im();
|
||||
virtual void disable_im();
|
||||
virtual void open_display();
|
||||
};
|
||||
|
||||
|
||||
|
@ -218,7 +218,7 @@ static void set_selection_color(uchar r, uchar g, uchar b)
|
||||
// look-n-feel...
|
||||
void Fl_Cocoa_Screen_Driver::get_system_colors()
|
||||
{
|
||||
fl_open_display();
|
||||
open_display();
|
||||
|
||||
if (!bg2_set) Fl::background2(0xff, 0xff, 0xff);
|
||||
if (!fg_set) Fl::foreground(0, 0, 0);
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
virtual void get_mouse(int &x, int &y);
|
||||
virtual void enable_im();
|
||||
virtual void disable_im();
|
||||
virtual void open_display();
|
||||
};
|
||||
|
||||
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
virtual void get_mouse(int &x, int &y);
|
||||
virtual void enable_im();
|
||||
virtual void disable_im();
|
||||
virtual void open_display();
|
||||
virtual void close_display();
|
||||
};
|
||||
|
||||
|
||||
|
@ -184,7 +184,7 @@ int Fl_X11_Screen_Driver::visual(int flags)
|
||||
#if USE_XDBE == 0
|
||||
if (flags & FL_DOUBLE) return 0;
|
||||
#endif
|
||||
fl_open_display();
|
||||
open_display();
|
||||
// always use default if possible:
|
||||
if (test_visual(*fl_visual, flags)) return 1;
|
||||
// get all the visuals:
|
||||
@ -210,7 +210,7 @@ static int fl_workarea_xywh[4] = { -1, -1, -1, -1 };
|
||||
|
||||
void Fl_X11_Screen_Driver::init_workarea()
|
||||
{
|
||||
fl_open_display();
|
||||
open_display();
|
||||
|
||||
Atom actual;
|
||||
unsigned long count, remaining;
|
||||
@ -267,7 +267,7 @@ int Fl_X11_Screen_Driver::h() {
|
||||
|
||||
void Fl_X11_Screen_Driver::init()
|
||||
{
|
||||
if (!fl_display) fl_open_display();
|
||||
if (!fl_display) open_display();
|
||||
// FIXME: Rewrite using RandR instead
|
||||
#if HAVE_XINERAMA
|
||||
if (XineramaIsActive(fl_display)) {
|
||||
@ -356,11 +356,11 @@ void Fl_X11_Screen_Driver::beep(int type)
|
||||
switch (type) {
|
||||
case FL_BEEP_DEFAULT :
|
||||
case FL_BEEP_ERROR :
|
||||
if (!fl_display) fl_open_display();
|
||||
if (!fl_display) open_display();
|
||||
XBell(fl_display, 100);
|
||||
break;
|
||||
default :
|
||||
if (!fl_display) fl_open_display();
|
||||
if (!fl_display) open_display();
|
||||
XBell(fl_display, 50);
|
||||
break;
|
||||
}
|
||||
@ -493,7 +493,7 @@ void Fl_X11_Screen_Driver::grab(Fl_Window* win)
|
||||
int Fl_X11_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar& b)
|
||||
{
|
||||
XColor x;
|
||||
if (!fl_display) fl_open_display();
|
||||
if (!fl_display) open_display();
|
||||
if (XParseColor(fl_display, fl_colormap, p, &x)) {
|
||||
r = (uchar)(x.red>>8);
|
||||
g = (uchar)(x.green>>8);
|
||||
@ -533,7 +533,7 @@ static void getsyscolor(const char *key1, const char* key2, const char *arg, con
|
||||
|
||||
void Fl_X11_Screen_Driver::get_system_colors()
|
||||
{
|
||||
fl_open_display();
|
||||
open_display();
|
||||
const char* key1 = 0;
|
||||
if (Fl::first_window()) key1 = Fl::first_window()->xclass();
|
||||
if (!key1) key1 = "fltk";
|
||||
@ -554,7 +554,7 @@ const char *Fl_X11_Screen_Driver::get_system_scheme()
|
||||
const char* key = 0;
|
||||
if (Fl::first_window()) key = Fl::first_window()->xclass();
|
||||
if (!key) key = "fltk";
|
||||
fl_open_display();
|
||||
open_display();
|
||||
s = XGetDefault(fl_display, key, "scheme");
|
||||
}
|
||||
return s;
|
||||
|
Loading…
Reference in New Issue
Block a user