HiDPI support: keep window's cursor after rescaling.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12275 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
9041a3dc70
commit
322b62a9f1
@ -152,6 +152,8 @@ public:
|
||||
// --- window cursor stuff
|
||||
virtual int set_cursor(Fl_Cursor);
|
||||
virtual int set_cursor(const Fl_RGB_Image*, int, int);
|
||||
virtual void reuse_cursor(fl_uintptr_t);
|
||||
virtual fl_uintptr_t current_cursor();
|
||||
|
||||
// --- window shape stuff
|
||||
void shape_pixmap_(Fl_Image* pixmap); // platform-independent, support function
|
||||
|
@ -365,6 +365,7 @@ void Fl_Screen_Driver::rescale_all_windows_from_screen(int screen, float f)
|
||||
for (i = count - 1; i >= 0; i--) { // rescale all top-level windows, finishing with front one
|
||||
win = win_array[i];
|
||||
int oldx = win->x(), oldy = win->y();
|
||||
fl_uintptr_t current = win->driver()->current_cursor();
|
||||
win->hide();
|
||||
win->driver()->screen_num(screen);
|
||||
win->position(oldx*old_f/f, oldy*old_f/f);
|
||||
@ -373,6 +374,7 @@ void Fl_Screen_Driver::rescale_all_windows_from_screen(int screen, float f)
|
||||
win->size(win->w() * old_f/f, win->h() * old_f/f);
|
||||
}
|
||||
win->show();
|
||||
win->driver()->reuse_cursor(current);
|
||||
win->wait_for_expose();
|
||||
}
|
||||
delete[] win_array;
|
||||
|
@ -239,6 +239,14 @@ int Fl_Window_Driver::set_cursor(const Fl_RGB_Image*, int, int) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fl_Window_Driver::reuse_cursor(fl_uintptr_t) {
|
||||
}
|
||||
|
||||
fl_uintptr_t Fl_Window_Driver::current_cursor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Fl_Window_Driver::wait_for_expose() {
|
||||
if (!shown()) return;
|
||||
Fl_X *i = Fl_X::i(pWindow);
|
||||
|
@ -2294,6 +2294,7 @@ int Fl_WinAPI_Window_Driver::set_cursor(Fl_Cursor c) {
|
||||
custom_cursor = 0;
|
||||
|
||||
SetCursor(cursor);
|
||||
current_cursor_ = c;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -2316,6 +2317,16 @@ int Fl_WinAPI_Window_Driver::set_cursor(const Fl_RGB_Image *image, int hotx, int
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Fl_WinAPI_Window_Driver::reuse_cursor(fl_uintptr_t c) {
|
||||
// calling SetCursor(cursor) does not work, so we call the crossplatform API
|
||||
pWindow->cursor((Fl_Cursor)c);
|
||||
}
|
||||
|
||||
fl_uintptr_t Fl_WinAPI_Window_Driver::current_cursor() {
|
||||
return (fl_uintptr_t)current_cursor_;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Implement the virtual functions for the base Fl_Window class:
|
||||
|
||||
|
11
src/Fl_x.cxx
11
src/Fl_x.cxx
@ -2420,9 +2420,6 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
|
||||
fl_background_pixel = -1;
|
||||
mask |= CWBackPixel;
|
||||
}
|
||||
// reproduce the window cursor if a window is hidden and then recreated (e.g., rescaled)
|
||||
attr.cursor = Fl_X11_Window_Driver::driver(win)->current_cursor_;
|
||||
mask |= CWCursor;
|
||||
float s = 1;
|
||||
#if USE_XFT
|
||||
//compute adequate screen where to put the window
|
||||
@ -2885,6 +2882,7 @@ int Fl_X11_Window_Driver::set_cursor(const Fl_RGB_Image *image, int hotx, int ho
|
||||
|
||||
xc = XcursorImageLoadCursor(fl_display, cursor);
|
||||
XDefineCursor(fl_display, fl_xid(pWindow), xc);
|
||||
current_cursor_ = xc;
|
||||
XFreeCursor(fl_display, xc);
|
||||
|
||||
XcursorImageDestroy(cursor);
|
||||
@ -2893,6 +2891,13 @@ int Fl_X11_Window_Driver::set_cursor(const Fl_RGB_Image *image, int hotx, int ho
|
||||
#endif
|
||||
}
|
||||
|
||||
void Fl_X11_Window_Driver::reuse_cursor(fl_uintptr_t c)
|
||||
{
|
||||
if (c) {
|
||||
XDefineCursor(fl_display, fl_xid(pWindow), (Cursor)c);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// returns pointer to the filename, or null if name ends with '/'
|
||||
|
@ -61,6 +61,7 @@ class FL_EXPORT Fl_WinAPI_Window_Driver : public Fl_Window_Driver
|
||||
HICON big_icon;
|
||||
HICON small_icon;
|
||||
};
|
||||
Fl_Cursor current_cursor_;
|
||||
private:
|
||||
void shape_bitmap_(Fl_Image* b);
|
||||
void shape_alpha_(Fl_Image* img, int offset);
|
||||
@ -100,6 +101,8 @@ public:
|
||||
// --- window cursor stuff
|
||||
virtual int set_cursor(Fl_Cursor);
|
||||
virtual int set_cursor(const Fl_RGB_Image*, int, int);
|
||||
virtual void reuse_cursor(fl_uintptr_t);
|
||||
virtual fl_uintptr_t current_cursor();
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
@ -47,6 +47,8 @@ Fl_WinAPI_Window_Driver::Fl_WinAPI_Window_Driver(Fl_Window *win)
|
||||
{
|
||||
icon_ = new icon_data;
|
||||
memset(icon_, 0, sizeof(icon_data));
|
||||
cursor = NULL;
|
||||
current_cursor_ = FL_CURSOR_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,6 +130,8 @@ public:
|
||||
// --- window cursor stuff
|
||||
virtual int set_cursor(Fl_Cursor);
|
||||
virtual int set_cursor(const Fl_RGB_Image*, int, int);
|
||||
virtual void reuse_cursor(fl_uintptr_t);
|
||||
virtual fl_uintptr_t current_cursor() {return current_cursor_;}
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
Loading…
Reference in New Issue
Block a user