Skip to content

Commit

Permalink
TEMP: experiment giving focus to auth dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Dec 8, 2024
1 parent ec157df commit 16da7c1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions vncviewer/CConn.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ CConn::CConn(const char* vncServerName, network::Socket* socket=nullptr)

if(sock == nullptr) {
try {
// FIXME: This shouldn't block
#ifndef WIN32
if (strchr(vncServerName, '/') != nullptr) {
sock = new network::UnixSocket(vncServerName);
Expand Down
15 changes: 9 additions & 6 deletions vncviewer/DesktopWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name,
#else
delayedFullscreen = true;
#endif

// Full screen events are not sent out for a hidden window,
// so send a fake one here to set up things properly.
if (fullscreen_active())
handle(FL_FULLSCREEN);
}

show();

// Full screen events are not sent out for a hidden window,
// so send a fake one here to set up things properly.
if (fullscreen_active())
handle(FL_FULLSCREEN);

// Unfortunately, current FLTK does not allow us to set the
// maximized property on Windows and X11 before showing the window.
// See STR #2083 and STR #2178
Expand Down Expand Up @@ -821,6 +821,7 @@ int DesktopWindow::handle(int event)
{
switch (event) {
case FL_FULLSCREEN:
vlog.error("FL_FULLSCREEN");
fullScreen.setParam(fullscreen_active());

// Update scroll bars
Expand Down Expand Up @@ -906,9 +907,11 @@ int DesktopWindow::fltkDispatch(int event, Fl_Window *win)
// all monitors and the user clicked on another application.
// Make sure we update our grabs with the focus changes.
case FL_FOCUS:
vlog.error("FL_FOCUS");
dw->maybeGrabKeyboard();
break;
case FL_UNFOCUS:
vlog.error("FL_UNFOCUS");
if (fullscreenSystemKeys) {
dw->ungrabKeyboard();
}
Expand Down Expand Up @@ -1088,7 +1091,7 @@ void DesktopWindow::grabKeyboard()
#elif defined(__APPLE__)
bool ret;

ret = cocoa_tap_keyboard();
ret = cocoa_tap_keyboard(this);
if (!ret) {
vlog.error(_("Failure grabbing keyboard"));
return;
Expand Down
2 changes: 1 addition & 1 deletion vncviewer/cocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Fl_Window;

bool cocoa_is_trusted(bool prompt=false);

bool cocoa_tap_keyboard();
bool cocoa_tap_keyboard(Fl_Window* win);
void cocoa_untap_keyboard();

typedef struct CGColorSpace *CGColorSpaceRef;
Expand Down
10 changes: 8 additions & 2 deletions vncviewer/cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,21 @@ static CGEventRef cocoa_event_tap(CGEventTapProxy /*proxy*/,
#endif
}

bool cocoa_tap_keyboard()
bool cocoa_tap_keyboard(Fl_Window* win)
{
CGEventMask mask;

if (event_tap != nullptr)
return true;

if (!cocoa_is_trusted())
if (!cocoa_is_trusted()) {
NSWindow *nsw;
nsw = (NSWindow*)fl_xid(win);
[nsw setLevel:NSNormalWindowLevel];
[nsw orderBack:nullptr];
[NSApp deactivate];
return false;
}

mask = CGEventMaskBit(kCGEventKeyDown) |
CGEventMaskBit(kCGEventKeyUp) |
Expand Down
5 changes: 4 additions & 1 deletion vncviewer/vncviewer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,10 @@ int main(int argc, char** argv)
}
}

usage(argv[0]);
vlog.error(_("Unknown parameter: %s"), argv[i]);

if (false)
usage(argv[0]);
}

strncpy(vncServerName, argv[i], VNCSERVERNAMELEN);
Expand Down

0 comments on commit 16da7c1

Please sign in to comment.