> iinntt XXGGrraabbDDeevviicceeBBuuttttoonn((DDiissppllaayy **_d_i_s_p_l_a_y,, XXDDeevviiccee **_d_e_v_i_c_e,, uunnssiiggnneedd iinntt _b_u_t_t_o_n,, uunnssiiggnneedd iinntt _m_o_d_i_f_i_e_r_s,, XXDDeevviiccee **_m_o_d_i_f_i_e_r___d_e_v_i_c_e,, WWiinnddooww _g_r_a_b___w_i_n_d_o_w,, BBooooll _o_w_n_e_r___e_v_e_n_t_s,, uunnssiiggnneedd iinntt _e_v_e_n_t___c_o_u_n_t,, XXEEvveennttCCllaassss **_e_v_e_n_t___l_i_s_t,, iinntt _t_h_i_s___d_e_v_i_c_e___m_o_d_e,, iinntt _o_t_h_e_r___d_e_v_i_c_e_s___m_o_d_e));; iinntt XXUUnnggrraabbDDeevviicceeBBuuttttoonn((DDiissppllaayy **_d_i_s_p_l_a_y,, XXDDeevviiccee **_d_e_v_i_c_e,, uunnssiiggnneedd iinntt _b_u_t_t_o_n,, uunnssiiggnneedd iinntt _m_o_d_i_f_i_e_r_s,, XXDDeevviiccee **_m_o_d_i_f_i_e_r___d_e_v_i_c_e,, WWiinnddooww _g_r_a_b___w_i_n_d_o_w));; </pprree>> _<_h_3 _i_d_=_"_A_R_G_U_M_E_N_T_S_"_> _A_R_G_U_M_E_N_T_S _<_/_h_3_> _<_d_l _c_o_m_p_a_c_t_> _<_d_t_> _<_i_>_d_i_s_p_l_a_y_<_/_i_> _<_d_d_> _S_p_e_c_i_f_i_e_s _t_h_e _c_o_n_n_e_c_t_i_o_n _t_o _t_h_e _X _s_e_r_v_e_r_. _<_d_t_> _<_i_>_d_e_v_i_c_e_<_/_i_> _<_d_d_> _S_p_e_c_i_f_i_e_s _t_h_e _d_e_v_i_c_e _t_h_a_t _i_s _t_o _b_e _g_r_a_b_b_e_d _o_r _r_e_l_e_a_s_e_d _<_d_t_> _<_i_>_b_u_t_t_o_n_<_/_i_> _<_d_d_> _S_p_e_c_i_f_i_e_s _t_h_e _d_e_v_i_c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E_i_t_h_e_r _t_h_e _g_r_a_b _w_i_n_d_o_w _i_s _a_n _a_n_c_e_s_t_o_r _o_f _(_o_r _i_s_) _t_h_e _f_o_c_u_s _w_i_n_d_o_w_, _O_R _<_d_d_> _t_h_e _g_r_a_b _w_i_n_d_o_w _i_s _a _d_e_s_c_e_n_d_e_n_t _o_f _t_h_e _f_o_c_u_s _w_i_n_d_o_w _a_n_d _c_o_n_t_a_i_n_s _t_h_e _d_e_v_i_c_e_. _<_d_t_> _<_b_>_·_<_/_b_> _A _p_a_s_s_i_v_e _g_r_a_b _o_n _t_h_e _s_a_m_e _b_u_t_t_o_n_/_m_o_d_i_f_i_e_r _c_o_m_b_i_n_a_t_i_o_n _d_o_e_s _n_o_t _e_x_i_s_t _<_d_d_> _o_n _a_n_y _a_n_c_e_s_t_o_r _o_f _g_r_a_b___w_i_n_d_o_w_. _<_/_d_l_> _<_p_> _T_h_e _i_n_t_e_r_p_r_e_t_a_t_i_o_n _o_f _t_h_e _r_e_m_a_i_n_i_n_g _a_r_g_u_m_e_n_t_s _i_s _a_s _f_o_r _X_G_r_a_b_D_e_v_i_c_e_. _T_h_e _a_c_t_i_v_e _g_r_a_b _i_s _t_e_r_m_i_n_a_t_e_d _a_u_t_o_m_a_t_i_c_a_l_l_y _w_h_e_n _t_h_e _l_o_g_i_c_a_l _s_t_a_t_e _o_f _t_h_e _d_e_v_i_c_e _h_a_s _a_l_l _b_u_t_t_o_n_s _r_e_l_e_a_s_e_d _(_i_n_d_e_p_e_n_d_e_n_t _o_f _t_h_e _l_o_g_i_c_a_l _s_t_a_t_e _o_f _t_h_e _m_o_d_i_f_i_e_r _k_e_y_s_)_. _<_p_> _N_o_t_e _t_h_a_t _t_h_e _l_o_g_i_c_a_l _s_t_a_t_e _o_f _a _d_e_v_i_c_e _(_a_s _s_e_e_n _b_y _c_l_i_e_n_t _a_p_p_l_i_c_a_t_i_o_n_s_) _m_a_y _l_a_g _t_h_e _p_h_y_s_i_c_a_l _s_t_a_t_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_I_C_S_"_> _D_I_A_G_N_O_S_T_I_C_S _<_/_h_3_> _<_d_l _c_o_m_p_a_c_t_> _<_d_t_> _B_a_d_D_e_v_i_c_e _<_d_d_> _A_n _i_n_v_a_l_i_d _d_e_v_i_c_e _w_a_s _s_p_e_c_i_f_i_e_d_. _T_h_e _s_p_e_c_i_f_i_e_d _d_e_v_i_c_e _d_o_e_s _n_o_t _e_x_i_s_t _o_r _h_a_s _n_o_t _b_e_e_n _o_p_e_n_e_d _b_y _t_h_i_s _c_l_i_e_n_t _v_i_a _X_O_p_e_n_I_n_p_u_t_D_e_v_i_c_e_. _T_h_i_s _e_r_r_o_r _m_a_y _a_l_s_o _o_c_c_u_r _i_f _t_h_e _s_p_e_c_i_f_i_e_d _d_e_v_i_c_e _i_s _t_h_e _X _k_e_y_b_o_a_r_d _o_r _X _p_o_i_n_t_e_r _d_e_v_i_c_e_. _<_d_t_> _B_a_d_M_a_t_c_h _<_d_d_> _T_h_i_s _e_r_r_o_r _m_a_y _o_c_c_u_r _i_f _a_n _X_G_r_a_b_D_e_v_i_c_e_B_u_t_t_o_n _r_e_q_u_e_s_t _w_a_s _m_a_d_e _s_p_e_c_i_f_y_i_n_g _a _d_e_v_i_c_e _t_h_a_t _h_a_s _n_o _b_u_t_t_o_n_s_, _o_r _s_p_e_c_i_f_y_i_n_g _a _m_o_d_i_f_i_e_r _d_e_v_i_c_e _t_h_a_t _h_a_s _n_o _k_e_y_s_. _<_d_t_> _B_a_d_V_a_l_u_e _<_d_d_> _S_o_m_e _n_u_m_e_r_i_c _v_a_l_u_e _f_a_l_l_s _o_u_t_s_i_d_e _t_h_e _r_a_n_g_e _o_f _v_a_l_u_e_s _a_c_c_e_p_t_e_d _b_y _t_h_e _r_e_q_u_e_s_t_. _U_n_l_e_s_s _a _s_p_e_c_i_f_i_c _r_a_n_g_e _i_s _s_p_e_c_i_f_i_e_d _f_o_r _a_n _a_r_g_u_m_e_n_t_, _t_h_e _f_u_l_l _r_a_n_g_e _d_e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