@@ -1673,11 +1673,11 @@ static void handle_keypress(Ghandles * g, XID UNUSED(winid))
1673
1673
1674
1674
static void handle_button (Ghandles * g , XID winid )
1675
1675
{
1676
- struct msg_button key ;
1676
+ struct msg_button msg ;
1677
1677
struct genlist * l = list_lookup (windows_list , winid );
1678
1678
1679
1679
1680
- read_data (g -> vchan , (char * ) & key , sizeof (key ));
1680
+ read_data (g -> vchan , (char * ) & msg , sizeof (msg ));
1681
1681
if (l && l -> data && ((struct window_data * )l -> data )-> is_docked ) {
1682
1682
/* get position of embeder, not icon itself*/
1683
1683
winid = ((struct window_data * )l -> data )-> embeder ;
@@ -1687,19 +1687,19 @@ static void handle_button(Ghandles * g, XID winid)
1687
1687
if (g -> log_level > 1 )
1688
1688
fprintf (stderr ,
1689
1689
"send buttonevent, win 0x%x type=%d button=%d\n" ,
1690
- (int ) winid , key .type , key .button );
1691
- feed_xdriver (g , 'B' , key .button , key .type == ButtonPress ? 1 : 0 );
1690
+ (int ) winid , msg .type , msg .button );
1691
+ feed_xdriver (g , 'B' , msg .button , msg .type == ButtonPress ? 1 : 0 );
1692
1692
}
1693
1693
1694
1694
static void handle_motion (Ghandles * g , XID winid )
1695
1695
{
1696
- struct msg_motion key ;
1696
+ struct msg_motion msg ;
1697
1697
// XMotionEvent event;
1698
1698
XWindowAttributes attr ;
1699
1699
int ret ;
1700
1700
struct genlist * l = list_lookup (windows_list , winid );
1701
1701
1702
- read_data (g -> vchan , (char * ) & key , sizeof (key ));
1702
+ read_data (g -> vchan , (char * ) & msg , sizeof (msg ));
1703
1703
if (l && l -> data && ((struct window_data * )l -> data )-> is_docked ) {
1704
1704
/* get position of embeder, not icon itself*/
1705
1705
winid = ((struct window_data * )l -> data )-> embeder ;
@@ -1712,14 +1712,14 @@ static void handle_motion(Ghandles * g, XID winid)
1712
1712
return ;
1713
1713
};
1714
1714
1715
- feed_xdriver (g , 'M' , attr .x + key .x , attr .y + key .y );
1715
+ feed_xdriver (g , 'M' , attr .x + msg .x , attr .y + msg .y );
1716
1716
}
1717
1717
1718
1718
// ensure that LeaveNotify is delivered to the window - if pointer is still
1719
1719
// above this window, place stub window between pointer and the window
1720
1720
static void handle_crossing (Ghandles * g , XID winid )
1721
1721
{
1722
- struct msg_crossing key ;
1722
+ struct msg_crossing msg ;
1723
1723
XWindowAttributes attr ;
1724
1724
int ret ;
1725
1725
struct genlist * l = list_lookup (windows_list , winid );
@@ -1731,9 +1731,9 @@ static void handle_crossing(Ghandles * g, XID winid)
1731
1731
winid = ((struct window_data * )l -> data )-> embeder ;
1732
1732
}
1733
1733
1734
- read_data (g -> vchan , (char * ) & key , sizeof (key ));
1734
+ read_data (g -> vchan , (char * ) & msg , sizeof (msg ));
1735
1735
1736
- if (key .mode != NotifyNormal )
1736
+ if (msg .mode != NotifyNormal )
1737
1737
return ;
1738
1738
ret = XGetWindowAttributes (g -> display , winid , & attr );
1739
1739
if (ret != 1 ) {
@@ -1743,11 +1743,11 @@ static void handle_crossing(Ghandles * g, XID winid)
1743
1743
return ;
1744
1744
};
1745
1745
1746
- if (key .type == EnterNotify ) {
1746
+ if (msg .type == EnterNotify ) {
1747
1747
// hide stub window
1748
1748
XUnmapWindow (g -> display , g -> stub_win );
1749
- feed_xdriver (g , 'M' , attr .x + key .x , attr .y + key .y );
1750
- } else if (key .type == LeaveNotify ) {
1749
+ feed_xdriver (g , 'M' , attr .x + msg .x , attr .y + msg .y );
1750
+ } else if (msg .type == LeaveNotify ) {
1751
1751
XID window_under_pointer , root_returned ;
1752
1752
int root_x , root_y , win_x , win_y ;
1753
1753
unsigned int mask_return ;
@@ -1771,7 +1771,7 @@ static void handle_crossing(Ghandles * g, XID winid)
1771
1771
XRaiseWindow (g -> display , g -> stub_win );
1772
1772
}
1773
1773
} else {
1774
- fprintf (stderr , "Invalid crossing event: %d\n" , key .type );
1774
+ fprintf (stderr , "Invalid crossing event: %d\n" , msg .type );
1775
1775
}
1776
1776
1777
1777
}
@@ -1794,16 +1794,15 @@ static void take_focus(Ghandles * g, XID winid)
1794
1794
(int ) winid );
1795
1795
}
1796
1796
1797
- static void handle_focus (Ghandles * g , XID winid )
1797
+ static void handle_focus_helper (Ghandles * g , XID winid , struct msg_focus msg )
1798
1798
{
1799
- struct msg_focus key ;
1800
1799
struct genlist * l ;
1801
1800
int use_take_focus = false;
1802
1801
1803
- read_data (g -> vchan , (char * ) & key , sizeof (key ));
1802
+ read_data (g -> vchan , (char * ) & msg , sizeof (msg ));
1804
1803
1805
- if (key .type == FocusIn ) {
1806
- if (key .mode == NotifyNormal ) {
1804
+ if (msg .type == FocusIn ) {
1805
+ if (msg .mode == NotifyNormal ) {
1807
1806
XSetInputFocus (g -> display , winid , RevertToNone , g -> time );
1808
1807
XRaiseWindow (g -> display , winid );
1809
1808
if (g -> log_level > 1 )
@@ -1822,14 +1821,14 @@ static void handle_focus(Ghandles * g, XID winid)
1822
1821
if (use_take_focus )
1823
1822
take_focus (g , winid );
1824
1823
}
1825
- if (key .mode == NotifyGrab ) {
1824
+ if (msg .mode == NotifyGrab ) {
1826
1825
XGrabPointer (g -> display , winid , false, 0 , GrabModeSync , GrabModeSync , None , None , CurrentTime );
1827
1826
}
1828
- if (key .mode == NotifyNormal || key .mode == NotifyUngrab ) {
1827
+ if (msg .mode == NotifyNormal || msg .mode == NotifyUngrab ) {
1829
1828
XUngrabPointer (g -> display , CurrentTime );
1830
1829
}
1831
- } else if (key .type == FocusOut ) {
1832
- if (key .mode == NotifyNormal ) {
1830
+ } else if (msg .type == FocusOut ) {
1831
+ if (msg .mode == NotifyNormal ) {
1833
1832
int ignore ;
1834
1833
XID winid_focused ;
1835
1834
XGetInputFocus (g -> display , & winid_focused , & ignore );
@@ -1839,15 +1838,22 @@ static void handle_focus(Ghandles * g, XID winid)
1839
1838
fprintf (stderr , "0x%x lost focus\n" , (int ) winid );
1840
1839
}
1841
1840
}
1842
- if (key .mode == NotifyGrab ) {
1841
+ if (msg .mode == NotifyGrab ) {
1843
1842
XGrabPointer (g -> display , g -> root_win , false, 0 , GrabModeSync , GrabModeSync , None , None , CurrentTime );
1844
1843
}
1845
- if (key .mode == NotifyUngrab ) {
1844
+ if (msg .mode == NotifyUngrab ) {
1846
1845
XUngrabPointer (g -> display , CurrentTime );
1847
1846
}
1848
1847
}
1849
1848
}
1850
1849
1850
+ static void handle_focus (Ghandles * g , XID winid )
1851
+ {
1852
+ struct msg_focus msg ;
1853
+ read_data (g -> vchan , (char * ) & msg , sizeof (msg ));
1854
+ return handle_focus_helper (g , winid , msg );
1855
+ }
1856
+
1851
1857
static int bitset (unsigned char * keys , int num )
1852
1858
{
1853
1859
return (keys [num / 8 ] >> (num % 8 )) & 1 ;
0 commit comments