Remove useless Fl_Window_Driver accessors after new member Fl_Window::get_size_range()

This commit is contained in:
ManoloFLTK 2024-05-27 11:34:34 +02:00
parent c1333a2dec
commit f3f69b892d
9 changed files with 65 additions and 72 deletions

View File

@ -91,14 +91,6 @@ public:
Fl_Group *parent() const { return pWindow->parent(); }
// --- accessors to private window data
int minw();
int minh();
int maxw();
int maxh();
int dw();
int dh();
int aspect();
unsigned char size_range_set();
int is_resizable() { return pWindow->is_resizable(); }
void is_a_rescale(bool b) { is_a_rescale_ = b;}
int fullscreen_screen_top();

View File

@ -50,19 +50,7 @@ Fl_Window_Driver::~Fl_Window_Driver() {
// empty
}
// accessors to Fl_Window's size_range stuff
int Fl_Window_Driver::minw() {return pWindow->minw_;}
int Fl_Window_Driver::minh() {return pWindow->minh_;}
int Fl_Window_Driver::maxw() {return pWindow->maxw_;}
int Fl_Window_Driver::maxh() {return pWindow->maxh_;}
int Fl_Window_Driver::dw() {return pWindow->dw_;}
int Fl_Window_Driver::dh() {return pWindow->dh_;}
int Fl_Window_Driver::aspect() {return pWindow->aspect_;}
unsigned char Fl_Window_Driver::size_range_set() {return pWindow->size_range_set_;}
// other Fl_Window accessors
// accessors to Fl_Window private stuff
int Fl_Window_Driver::force_position() {return pWindow->force_position(); }
void Fl_Window_Driver::force_position(int c) { pWindow->force_position(c); }
void Fl_Window_Driver::x(int X) {pWindow->x(X); }

View File

@ -2083,7 +2083,9 @@ static int fake_X_wm(Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by) {
int W, H, xoff, yoff, dx, dy;
int ret = bx = by = bt = 0;
if (w->border() && !w->parent()) {
if (Fl_Window_Driver::driver(w)->maxw() != Fl_Window_Driver::driver(w)->minw() || Fl_Window_Driver::driver(w)->maxh() != Fl_Window_Driver::driver(w)->minh()) {
int minw, minh, maxw, maxh;
w->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
if (maxw != minw || maxh != minh) {
ret = 2;
} else {
ret = 1;
@ -3219,7 +3221,7 @@ void Fl_Cocoa_Window_Driver::makeWindow()
[myview registerForDraggedTypes:[NSArray arrayWithObjects:UTF8_pasteboard_type,
fl_filenames_pboard_type, nil]];
if (size_range_set()) size_range();
if (pWindow->get_size_range(NULL, NULL, NULL, NULL, NULL, NULL, NULL)) size_range();
if ( w->border() || (!w->modal() && !w->tooltip_window()) ) {
Fl_Tooltip::enter(0);
@ -3414,8 +3416,10 @@ void Fl_Cocoa_Window_Driver::size_range() {
if (i && i->xid) {
float s = Fl::screen_driver()->scale(0);
int bt = get_window_frame_sizes(pWindow);
NSSize minSize = NSMakeSize(int(minw() * s +.5) , int(minh() * s +.5) + bt);
NSSize maxSize = NSMakeSize(maxw() ? int(maxw() * s + .5):32000, maxh() ? int(maxh() * s +.5) + bt:32000);
int minw, minh, maxw, maxh;
pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
NSSize minSize = NSMakeSize(int(minw * s +.5) , int(minh * s +.5) + bt);
NSSize maxSize = NSMakeSize(maxw ? int(maxw * s + .5):32000, maxh ? int(maxh * s +.5) + bt:32000);
[(FLWindow*)i->xid setMinSize:minSize];
[(FLWindow*)i->xid setMaxSize:maxSize];
}

View File

@ -1761,6 +1761,8 @@ int Fl_WinAPI_Window_Driver::fake_X_wm(int &X, int &Y, int &bt, int &bx, int &by
int fallback = 1;
float s = Fl::screen_driver()->scale(screen_num());
int minw, minh, maxw, maxh;
pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
if (!w->parent()) {
if (fl_xid(w) || style) {
// The block below calculates the window borders by requesting the
@ -1805,7 +1807,7 @@ int Fl_WinAPI_Window_Driver::fake_X_wm(int &X, int &Y, int &bt, int &bx, int &by
yoff = by + bt;
dx = W - int(w->w() * s);
dy = H - int(w->h() * s);
if (maxw() != minw() || maxh() != minh())
if (maxw != minw || maxh != minh)
ret = 2;
else
ret = 1;
@ -1816,7 +1818,7 @@ int Fl_WinAPI_Window_Driver::fake_X_wm(int &X, int &Y, int &bt, int &bx, int &by
// This is the original (pre 1.1.7) routine to calculate window border sizes.
if (fallback) {
if (w->border() && !w->parent()) {
if (maxw() != minw() || maxh() != minh()) {
if (maxw != minw || maxh != minh) {
ret = 2;
bx = GetSystemMetrics(SM_CXSIZEFRAME);
by = GetSystemMetrics(SM_CYSIZEFRAME);
@ -2256,16 +2258,18 @@ void Fl_WinAPI_Window_Driver::set_minmax(LPMINMAXINFO minmax) {
hd *= 2;
hd += td;
int minw, minh, maxw, maxh;
pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
float s = Fl::screen_driver()->scale(screen_num());
minmax->ptMinTrackSize.x = LONG(s * minw()) + wd;
minmax->ptMinTrackSize.y = LONG(s * minh()) + hd;
if (maxw()) {
minmax->ptMaxTrackSize.x = LONG(s * maxw()) + wd;
minmax->ptMaxSize.x = LONG(s * maxw()) + wd;
minmax->ptMinTrackSize.x = LONG(s * minw) + wd;
minmax->ptMinTrackSize.y = LONG(s * minh) + hd;
if (maxw) {
minmax->ptMaxTrackSize.x = LONG(s * maxw) + wd;
minmax->ptMaxSize.x = LONG(s * maxw) + wd;
}
if (maxh()) {
minmax->ptMaxTrackSize.y = LONG(s * maxh()) + hd;
minmax->ptMaxSize.y = LONG(s * maxh()) + hd;
if (maxh) {
minmax->ptMaxTrackSize.y = LONG(s * maxh) + hd;
minmax->ptMaxSize.y = LONG(s * maxh) + hd;
}
}

View File

@ -2757,13 +2757,15 @@ void Fl_X11_Window_Driver::sendxjunk() {
// memset(&hints, 0, sizeof(hints)); jreiser suggestion to fix purify?
float s = Fl::screen_driver()->scale(screen_num());
hints->min_width = s * minw();
hints->min_height = s * minh();
hints->max_width = s * maxw();
hints->max_height = s * maxh();
int minw, minh, maxw, maxh, dw, dh, aspect;
pWindow->get_size_range(&minw, &minh, &maxw, &maxh, &dw, &dh, &aspect);
hints->min_width = s * minw;
hints->min_height = s * minh;
hints->max_width = s * maxw;
hints->max_height = s * maxh;
if (int(s) == s) { // use win size increment value only if scale is an integer. Is it possible to do better?
hints->width_inc = s * dw();
hints->height_inc = s * dh();
hints->width_inc = s * dw;
hints->height_inc = s * dh;
} else {
hints->width_inc = 0;
hints->height_inc = 0;
@ -2789,7 +2791,7 @@ void Fl_X11_Window_Driver::sendxjunk() {
if (hints->max_height < hints->min_height) hints->max_height = Fl::h()*s;
}
if (hints->width_inc && hints->height_inc) hints->flags |= PResizeInc;
if (aspect()) {
if (aspect) {
// stupid X! It could insist that the corner go on the
// straight line between min and max...
hints->min_aspect.x = hints->max_aspect.x = hints->min_width;

View File

@ -89,23 +89,26 @@ void Fl_Cocoa_Window_Driver::draw_end()
{
// on OS X, windows have no frame. Before OS X 10.7, to resize a window, we drag the lower right
// corner. This code draws a little ribbed triangle for dragging.
if (fl_mac_os_version < 100700 && !parent() && is_resizable() &&
(!size_range_set() || minh() != maxh() || minw() != maxw())) {
int dx = Fl::box_dw(pWindow->box())-Fl::box_dx(pWindow->box());
int dy = Fl::box_dh(pWindow->box())-Fl::box_dy(pWindow->box());
if (dx<=0) dx = 1;
if (dy<=0) dy = 1;
int x1 = w()-dx-1, x2 = x1, y1 = h()-dx-1, y2 = y1;
Fl_Color c[4] = {
pWindow->color(),
fl_color_average(pWindow->color(), FL_WHITE, 0.7f),
fl_color_average(pWindow->color(), FL_BLACK, 0.6f),
fl_color_average(pWindow->color(), FL_BLACK, 0.8f),
};
int i;
for (i=dx; i<12; i++) {
fl_color(c[i&3]);
fl_line(x1--, y1, x2, y2--);
if (fl_mac_os_version < 100700 && !parent() && is_resizable()) {
int minw, minh, maxw, maxh, set;
set = pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
if (!set || minh != maxh || minw != maxw) {
int dx = Fl::box_dw(pWindow->box())-Fl::box_dx(pWindow->box());
int dy = Fl::box_dh(pWindow->box())-Fl::box_dy(pWindow->box());
if (dx<=0) dx = 1;
if (dy<=0) dy = 1;
int x1 = w()-dx-1, x2 = x1, y1 = h()-dx-1, y2 = y1;
Fl_Color c[4] = {
pWindow->color(),
fl_color_average(pWindow->color(), FL_WHITE, 0.7f),
fl_color_average(pWindow->color(), FL_BLACK, 0.6f),
fl_color_average(pWindow->color(), FL_BLACK, 0.8f),
};
int i;
for (i=dx; i<12; i++) {
fl_color(c[i&3]);
fl_line(x1--, y1, x2, y2--);
}
}
}
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4

View File

@ -1873,11 +1873,7 @@ void *Fl_Wayland_Screen_Driver::control_maximize_button(void *data) {
LIBDECOR_WINDOW_STATE_MAXIMIZED) ) {
win_dims *dim = new win_dims;
dim->tracker = new Fl_Widget_Tracker(win);
Fl_Window_Driver *dr = Fl_Window_Driver::driver(win);
dim->minw = dr->minw();
dim->minh = dr->minh();
dim->maxw = dr->maxw();
dim->maxh = dr->maxh();
win->get_size_range(&dim->minw, &dim->minh, &dim->maxw, &dim->maxh, NULL, NULL, NULL);
//make win un-resizable
win->size_range(win->w(), win->h(), win->w(), win->h());
dim->next = first_dim;

View File

@ -542,30 +542,32 @@ void Fl_Wayland_Window_Driver::size_range() {
Fl_X* ip = Fl_X::flx(pWindow);
struct wld_window *wl_win = (struct wld_window*)ip->xid;
float f = Fl::screen_scale(pWindow->screen_num());
int minw, minh, maxw, maxh;
pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
if (wl_win->kind == DECORATED && wl_win->frame) {
int X,Y,W,H;
Fl::screen_work_area(X,Y,W,H, Fl::screen_num(x(),y(),w(),h()));
if (maxw() && maxw() < W && maxh() && maxh() < H) {
if (maxw && maxw < W && maxh && maxh < H) {
libdecor_frame_unset_capabilities(wl_win->frame, LIBDECOR_ACTION_FULLSCREEN);
} else {
libdecor_frame_set_capabilities(wl_win->frame, LIBDECOR_ACTION_FULLSCREEN);
}
if (maxw() && maxh() && (minw() >= maxw() || minh() >= maxh())) {
if (maxw && maxh && (minw >= maxw || minh >= maxh)) {
libdecor_frame_unset_capabilities(wl_win->frame, LIBDECOR_ACTION_RESIZE);
} else {
libdecor_frame_set_capabilities(wl_win->frame, LIBDECOR_ACTION_RESIZE);
}
libdecor_frame_set_min_content_size(wl_win->frame, minw()*f, minh()*f);
libdecor_frame_set_max_content_size(wl_win->frame, maxw()*f, maxh()*f);
libdecor_frame_set_min_content_size(wl_win->frame, minw*f, minh*f);
libdecor_frame_set_max_content_size(wl_win->frame, maxw*f, maxh*f);
if (xdg_toplevel()) {
struct libdecor_state *state = libdecor_state_new(int(w() * f), int(h() * f));
libdecor_frame_commit(wl_win->frame, state, NULL);
libdecor_state_free(state);
}
} else if (wl_win->kind == UNFRAMED && wl_win->xdg_toplevel) {
xdg_toplevel_set_min_size(wl_win->xdg_toplevel, minw()*f, minh()*f);
if (maxw() && maxh())
xdg_toplevel_set_max_size(wl_win->xdg_toplevel, maxw()*f, maxh()*f);
xdg_toplevel_set_min_size(wl_win->xdg_toplevel, minw*f, minh*f);
if (maxw && maxh)
xdg_toplevel_set_max_size(wl_win->xdg_toplevel, maxw*f, maxh*f);
}
}
}

View File

@ -631,7 +631,9 @@ void Fl_WinAPI_Window_Driver::iconize() {
void Fl_WinAPI_Window_Driver::decoration_sizes(int *top, int *left, int *right, int *bottom) {
if (size_range_set() && (maxw() != minw() || maxh() != minh())) {
int minw, minh, maxw, maxh, set;
set = pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
if (set && (maxw != minw || maxh != minh)) {
*left = *right = GetSystemMetrics(SM_CXSIZEFRAME);
*top = *bottom = GetSystemMetrics(SM_CYSIZEFRAME);
} else {