Skip to content

Commit

Permalink
Fix Fl_Paged_Device::print_window(), Fl_Window::decorated_w() and Fl_…
Browse files Browse the repository at this point in the history
…Window::decorated_h()

when the window is iconized for all platforms.
Also, factorized some duplicated code in src/Fl_x.cxx.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8759 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed May 30, 2011
1 parent 39998a9 commit 18a902c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/Fl_cocoa.mm
Expand Up @@ -3392,23 +3392,23 @@ Window fl_xid(const Fl_Window* w)

int Fl_Window::decorated_w()
{
if (parent() || !border()) return w();
if (!shown() || parent() || !border() || !visible()) return w();
int bx, by, bt;
get_window_frame_sizes(bx, by, bt);
return w() + 2 * bx;
}

int Fl_Window::decorated_h()
{
if (parent() || !border()) return h();
if (!shown() || parent() || !border() || !visible()) return h();
int bx, by, bt;
get_window_frame_sizes(bx, by, bt);
return h() + bt + by;
}

void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
{
if (!win->shown() || win->parent() || !win->border()) {
if (!win->shown() || win->parent() || !win->border() || !win->visible()) {
this->print_widget(win, x_offset, y_offset);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Fl_win32.cxx
Expand Up @@ -1966,23 +1966,23 @@ Window fl_xid_(const Fl_Window *w) {

int Fl_Window::decorated_w()
{
if (parent() || !shown()) return w();
if (!shown() || parent() || !border() || !visible()) return w();
int X, Y, bt, bx, by;
Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
return w() + 2 * bx;
}

int Fl_Window::decorated_h()
{
if (this->parent() || !shown()) return h();
if (!shown() || parent() || !border() || !visible()) return h();
int X, Y, bt, bx, by;
Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
return h() + bt + 2 * by;
}

void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
{
if (win->parent() || !win->border()) {
if (!win->shown() || win->parent() || !win->border() || !win->visible()) {
this->print_widget(win, x_offset, y_offset);
return;
}
Expand Down
44 changes: 25 additions & 19 deletions src/Fl_x.cxx
Expand Up @@ -1971,37 +1971,41 @@ Window fl_xid_(const Fl_Window *w) {
return temp ? temp->xid : 0;
}

int Fl_Window::decorated_h()
static void decorated_win_size(Fl_Window *win, int &w, int &h)
{
if (parent() || !shown()) return h();
w = win->w();
h = win->h();
if (!win->shown() || win->parent() || !win->border() || !win->visible()) return;
Window root, parent, *children;
unsigned n;
XQueryTree(fl_display, i->xid, &root, &parent, &children, &n); if (n) XFree(children);
unsigned n = 0;
Status status = XQueryTree(fl_display, Fl_X::i(win)->xid, &root, &parent, &children, &n);
if (status != 0 && n) XFree(children);
// when compiz is used, root and parent are the same window
// and I don't know where to find the window decoration
if (root == parent) return h();
if (status == 0 || root == parent) return;
XWindowAttributes attributes;
XGetWindowAttributes(fl_display, parent, &attributes);
return attributes.height;
w = attributes.width;
h = attributes.height;
}

int Fl_Window::decorated_h()
{
int w, h;
decorated_win_size(this, w, h);
return h;
}

int Fl_Window::decorated_w()
{
if (parent() || !shown()) return w();
Window root, parent, *children;
unsigned n;
XQueryTree(fl_display, i->xid, &root, &parent, &children, &n); if (n) XFree(children);
// when compiz is used, root and parent are the same window
// and I don't know where to find the window decoration
if (root == parent) return w();
XWindowAttributes attributes;
XGetWindowAttributes(fl_display, parent, &attributes);
return attributes.width;
int w, h;
decorated_win_size(this, w, h);
return w;
}

void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
{
if (win->parent() || !win->border()) {
if (!win->shown() || win->parent() || !win->border() || !win->visible()) {
this->print_widget(win, x_offset, y_offset);
return;
}
Expand Down Expand Up @@ -2034,8 +2038,10 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
}
fl_window = from;
this->set_current();
fl_draw_image(top_image, x_offset, y_offset, win->w() + 2 * bx, bt, 3);
delete[] top_image;
if (top_image) {
fl_draw_image(top_image, x_offset, y_offset, win->w() + 2 * bx, bt, 3);
delete[] top_image;
}
if (bx) {
if (left_image) fl_draw_image(left_image, x_offset, y_offset + bt, bx, win->h() + bx, 3);
if (right_image) fl_draw_image(right_image, x_offset + win->w() + bx, y_offset + bt, bx, win->h() + bx, 3);
Expand Down

0 comments on commit 18a902c

Please sign in to comment.