Browse Source

Don't resize viewer window when maximized

Most window managers won't like this, and it tends to provoke bugs in
FLTK, so let's avoid it. It's probably not what the user wants anyway.
tags/v1.10.90
Pierre Ossman 4 years ago
parent
commit
aaeee37f0a
3 changed files with 47 additions and 1 deletions
  1. 38
    1
      vncviewer/DesktopWindow.cxx
  2. 2
    0
      vncviewer/cocoa.h
  3. 7
    0
      vncviewer/cocoa.mm

+ 38
- 1
vncviewer/DesktopWindow.cxx View File



void DesktopWindow::resizeFramebuffer(int new_w, int new_h) void DesktopWindow::resizeFramebuffer(int new_w, int new_h)
{ {
bool maximized;

if ((new_w == viewport->w()) && (new_h == viewport->h())) if ((new_w == viewport->w()) && (new_h == viewport->h()))
return; return;


maximized = false;

#ifdef WIN32
WINDOWPLACEMENT wndpl;
memset(&wndpl, 0, sizeof(WINDOWPLACEMENT));
wndpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(fl_xid(this), &wndpl);
if (wndpl.showCmd == SW_SHOWMAXIMIZED)
maximized = true;
#elif defined(__APPLE__)
if (cocoa_win_is_zoomed(this))
maximized = true;
#else
Atom net_wm_state = XInternAtom (fl_display, "_NET_WM_STATE", 0);
Atom net_wm_state_maximized_vert = XInternAtom (fl_display, "_NET_WM_STATE_MAXIMIZED_VERT", 0);
Atom net_wm_state_maximized_horz = XInternAtom (fl_display, "_NET_WM_STATE_MAXIMIZED_HORZ", 0);

Atom type;
int format;
unsigned long nitems, remain;
Atom *atoms;

XGetWindowProperty(fl_display, fl_xid(this), net_wm_state, 0, 1024, False, XA_ATOM, &type, &format, &nitems, &remain, (unsigned char**)&atoms);

for (unsigned long i = 0;i < nitems;i++) {
if ((atoms[i] == net_wm_state_maximized_vert) ||
(atoms[i] == net_wm_state_maximized_horz)) {
maximized = true;
break;
}
}

XFree(atoms);
#endif

// If we're letting the viewport match the window perfectly, then // If we're letting the viewport match the window perfectly, then
// keep things that way for the new size, otherwise just keep things // keep things that way for the new size, otherwise just keep things
// like they are. // like they are.
if (!fullscreen_active()) {
if (!fullscreen_active() && !maximized) {
if ((w() == viewport->w()) && (h() == viewport->h())) if ((w() == viewport->w()) && (h() == viewport->h()))
size(new_w, new_h); size(new_w, new_h);
else { else {

+ 2
- 0
vncviewer/cocoa.h View File



CGColorSpaceRef cocoa_win_color_space(Fl_Window *win); CGColorSpaceRef cocoa_win_color_space(Fl_Window *win);


bool cocoa_win_is_zoomed(Fl_Window *win);

int cocoa_is_keyboard_event(const void *event); int cocoa_is_keyboard_event(const void *event);


int cocoa_is_key_press(const void *event); int cocoa_is_key_press(const void *event);

+ 7
- 0
vncviewer/cocoa.mm View File

return lut; return lut;
} }


bool cocoa_win_is_zoomed(Fl_Window *win)
{
NSWindow *nsw;
nsw = (NSWindow*)fl_xid(win);
return [nsw isZoomed];
}

int cocoa_is_keyboard_event(const void *event) int cocoa_is_keyboard_event(const void *event)
{ {
NSEvent *nsevent; NSEvent *nsevent;

Loading…
Cancel
Save