Skip to content

Commit

Permalink
Window Focus Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kylogias committed May 8, 2024
1 parent c55fd6f commit bf75f4b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions CNFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ extern float CNFGVertDataV[CNFG_BATCH*3];
extern uint32_t CNFGVertDataC[CNFG_BATCH];
#endif

#define CNFG_KEY_FOCUS 0xf000

#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) || defined(_WIN32) || defined(_WIN64)

Expand Down
5 changes: 5 additions & 0 deletions CNFGWinDriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ LRESULT CALLBACK MyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
#endif
case WM_KILLFOCUS:
case WM_SETFOCUS:
CNFGLastScancode = 0;
HandleKey( CNFG_KEY_FOCUS, msg == WM_SETFOCUS );
return 0;
case WM_CLOSE:
if( HandleDestroy() )
return 0;
Expand Down
7 changes: 6 additions & 1 deletion CNFGXDriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void InternalLinkScreenAndGo( const char * WindowName )
fprintf( stderr, "Pre-existing XClassHint\n" );
}

XSelectInput (CNFGDisplay, CNFGWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask );
XSelectInput (CNFGDisplay, CNFGWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask | FocusChangeMask );


CNFGWindowGC = XCreateGC(CNFGDisplay, CNFGWindow, 0, 0);
Expand Down Expand Up @@ -500,6 +500,11 @@ int CNFGHandleInput()
case MotionNotify:
HandleMotion( report.xmotion.x, report.xmotion.y, ButtonsDown>>1 );
break;
case FocusIn:
case FocusOut:
CNFGLastScancode = 0;
HandleKey( CNFG_KEY_FOCUS, report.type == FocusIn );
break;
case ClientMessage:
if ( report.xclient.data.l[0] == CFNGWMDeleteWindow )
return 0;
Expand Down
15 changes: 13 additions & 2 deletions rawdraw_sf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//This file was automatically generated by Makefile at https://github.com/cntools/rawdraw
//Generated from files git hash a4e1d56080c42e7d5a7d72317776c7c268764bd7 on Tue May 7 08:10:18 PM EDT 2024 (This is not the git hash of this file)
//Generated from files git hash c55fd6fe2c807fbe9103c7fb72dc277ebd641397 on Tue May 7 09:58:03 PM EDT 2024 (This is not the git hash of this file)
// Copyright 2010-2021 <>< CNLohr, et. al. (Several other authors, many but not all mentioned)
// Licensed under the MIT/x11 or NewBSD License you choose.
//
Expand Down Expand Up @@ -206,6 +206,7 @@ extern float CNFGVertDataV[CNFG_BATCH*3];
extern uint32_t CNFGVertDataC[CNFG_BATCH];
#endif

#define CNFG_KEY_FOCUS 0xf000

#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) || defined(_WIN32) || defined(_WIN64)

Expand Down Expand Up @@ -3892,6 +3893,11 @@ LRESULT CALLBACK MyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
#endif
case WM_KILLFOCUS:
case WM_SETFOCUS:
CNFGLastScancode = 0;
HandleKey( CNFG_KEY_FOCUS, msg == WM_SETFOCUS );
break;
case WM_CLOSE:
if( HandleDestroy() )
return 0;
Expand Down Expand Up @@ -5811,7 +5817,7 @@ static void InternalLinkScreenAndGo( const char * WindowName )
fprintf( stderr, "Pre-existing XClassHint\n" );
}

XSelectInput (CNFGDisplay, CNFGWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask );
XSelectInput (CNFGDisplay, CNFGWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask | FocusChangeMask );


CNFGWindowGC = XCreateGC(CNFGDisplay, CNFGWindow, 0, 0);
Expand Down Expand Up @@ -6088,6 +6094,11 @@ int CNFGHandleInput()
case MotionNotify:
HandleMotion( report.xmotion.x, report.xmotion.y, ButtonsDown>>1 );
break;
case FocusIn:
case FocusOut:
CNFGLastScancode = 0;
HandleKey( CNFG_KEY_FOCUS, report.type == FocusIn );
break;
case ClientMessage:
if ( report.xclient.data.l[0] == CFNGWMDeleteWindow )
return 0;
Expand Down

0 comments on commit bf75f4b

Please sign in to comment.