Skip to content

Commit 6ed2b68

Browse files
authored
Merge pull request #4 from orchardstreet/orchardstreet-patch-2
Turn XAutoRepeat back on when exit via titlebar
2 parents 889bc27 + 22368ba commit 6ed2b68

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

main-x11.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
------------------------------------------------------------------*/
2222
#include <X11/Xlib.h>
2323
#include <X11/Xutil.h>
24+
#include <X11/Xatom.h>
2425
#include <X11/keysym.h>
2526
#include <sys/types.h>
2627

@@ -57,6 +58,7 @@ XTextProperty wname;
5758
char *font_name = "10x20";
5859
unsigned int window_width, window_height,
5960
display_width, display_height;
61+
Atom wmDeleteMessage;
6062

6163
/*------------------------------------------------------------------
6264
* main
@@ -138,6 +140,10 @@ int Graphics_init ( unsigned int win_width, unsigned int win_height )
138140
color_gc = XCreateGC ( display, win, gc_valuemask, &gc_values );
139141
text_gc = XCreateGC ( display, win, gc_valuemask, &gc_values );
140142

143+
/* Get atom and indicate X11 client is willing to participate */
144+
wmDeleteMessage = XInternAtom ( display, "WM_DELETE_WINDOW", False );
145+
XSetWMProtocols ( display, win, &wmDeleteMessage, 1 );
146+
141147
/* load default font */
142148
font_info = XLoadQueryFont ( display, font_name );
143149
if ( !font_info )
@@ -477,6 +483,15 @@ int Handle_events ( void )
477483
}
478484
break;
479485

486+
case ClientMessage:
487+
if ( event.xclient.data.l[0] >= 0 && ((unsigned long int) \
488+
event.xclient.data.l[0]) == wmDeleteMessage )
489+
{
490+
Graphics_shutdown ();
491+
exit(0);
492+
}
493+
break;
494+
480495
default:
481496
break;
482497
}

player.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,17 @@ void Player_update1 ( OBJECT *obj )
164164
if ( (gv->key_LEFT1 == FALSE) && (gv->key_RIGHT1 == FALSE) && \
165165
player1->rot )
166166
{
167-
if(player1->rot > 0)
167+
if ( player1->rot > 0 )
168168
{
169169
player1->rot -= ROT_Z * gv->fadjust;
170-
if(player1->rot < 0)
170+
if ( player1->rot < 0 )
171171
player1->rot = 0;
172-
}
173-
else
172+
}
173+
else
174174
{
175175
player1->rot += ROT_Z * gv->fadjust;
176-
if(player1->rot > 0)
177-
player1->rot = 0;
176+
if ( player1->rot > 0 )
177+
player1->rot = 0;
178178
}
179179
}
180180

@@ -235,17 +235,17 @@ void Player_update2 ( OBJECT *obj )
235235
if ( (gv->key_LEFT2 == FALSE) && (gv->key_RIGHT2 == FALSE) && \
236236
player2->rot )
237237
{
238-
if(player2->rot > 0)
238+
if ( player2->rot > 0 )
239239
{
240240
player2->rot -= ROT_Z * gv->fadjust;
241-
if(player2->rot < 0)
241+
if ( player2->rot < 0 )
242242
player2->rot = 0;
243-
}
244-
else
243+
}
244+
else
245245
{
246246
player2->rot += ROT_Z * gv->fadjust;
247-
if(player2->rot > 0)
248-
player2->rot = 0;
247+
if ( player2->rot > 0 )
248+
player2->rot = 0;
249249
}
250250
}
251251

0 commit comments

Comments
 (0)