Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
fdac60bd
Commit
fdac60bd
authored
Jul 14, 2010
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let the window manager know we're a "normal" window
parent
b60cbd56
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
52 deletions
+48
-52
SDL_x11window.c
src/video/x11/SDL_x11window.c
+48
-52
No files found.
src/video/x11/SDL_x11window.c
View file @
fdac60bd
...
@@ -224,6 +224,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -224,6 +224,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
SDL_VideoData
*
data
=
(
SDL_VideoData
*
)
_this
->
driverdata
;
SDL_VideoData
*
data
=
(
SDL_VideoData
*
)
_this
->
driverdata
;
SDL_DisplayData
*
displaydata
=
SDL_DisplayData
*
displaydata
=
(
SDL_DisplayData
*
)
window
->
display
->
driverdata
;
(
SDL_DisplayData
*
)
window
->
display
->
driverdata
;
Display
*
display
=
data
->
display
;
int
screen
=
displaydata
->
screen
;
Visual
*
visual
;
Visual
*
visual
;
int
depth
;
int
depth
;
XSetWindowAttributes
xattr
;
XSetWindowAttributes
xattr
;
...
@@ -233,6 +235,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -233,6 +235,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
XWMHints
*
wmhints
;
XWMHints
*
wmhints
;
XClassHint
*
classhints
;
XClassHint
*
classhints
;
SDL_bool
oldstyle_fullscreen
;
SDL_bool
oldstyle_fullscreen
;
Atom
_NET_WM_WINDOW_TYPE
;
Atom
_NET_WM_WINDOW_TYPE_NORMAL
;
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
if
((
window
->
flags
&
SDL_WINDOW_FULLSCREEN
)
&&
!
data
->
net_wm
)
{
if
((
window
->
flags
&
SDL_WINDOW_FULLSCREEN
)
&&
!
data
->
net_wm
)
{
...
@@ -253,7 +257,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -253,7 +257,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if
(
window
->
flags
&
SDL_WINDOW_OPENGL
)
{
if
(
window
->
flags
&
SDL_WINDOW_OPENGL
)
{
XVisualInfo
*
vinfo
;
XVisualInfo
*
vinfo
;
vinfo
=
X11_GL_GetVisual
(
_this
,
d
ata
->
display
,
displaydata
->
screen
);
vinfo
=
X11_GL_GetVisual
(
_this
,
d
isplay
,
screen
);
if
(
!
vinfo
)
{
if
(
!
vinfo
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -266,7 +270,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -266,7 +270,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if
(
window
->
flags
&
SDL_WINDOW_OPENGL
)
{
if
(
window
->
flags
&
SDL_WINDOW_OPENGL
)
{
XVisualInfo
*
vinfo
;
XVisualInfo
*
vinfo
;
vinfo
=
X11_GLES_GetVisual
(
_this
,
d
ata
->
display
,
displaydata
->
screen
);
vinfo
=
X11_GLES_GetVisual
(
_this
,
d
isplay
,
screen
);
if
(
!
vinfo
)
{
if
(
!
vinfo
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -305,15 +309,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -305,15 +309,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* Is the colormap we need already registered in SDL? */
/* Is the colormap we need already registered in SDL? */
if
((
colormap
=
if
((
colormap
=
X11_LookupColormap
(
data
->
display
,
X11_LookupColormap
(
display
,
screen
,
visual
->
visualid
)))
{
displaydata
->
screen
,
visual
->
visualid
)))
{
xattr
.
colormap
=
colormap
;
xattr
.
colormap
=
colormap
;
/* printf("found existing colormap\n"); */
/* printf("found existing colormap\n"); */
}
else
{
}
else
{
/* The colormap is not known to SDL so we will create it */
/* The colormap is not known to SDL so we will create it */
colormap
=
XCreateColormap
(
data
->
display
,
colormap
=
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
RootWindow
(
data
->
display
,
displaydata
->
screen
),
visual
,
AllocAll
);
visual
,
AllocAll
);
/* printf("colormap = %x\n", colormap); */
/* printf("colormap = %x\n", colormap); */
...
@@ -392,11 +393,10 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -392,11 +393,10 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}
}
/* status = */
/* status = */
/* XStoreColors(d
ata->d
isplay, colormap, colorcells, ncolors); */
/* XStoreColors(display, colormap, colorcells, ncolors); */
xattr
.
colormap
=
colormap
;
xattr
.
colormap
=
colormap
;
X11_TrackColormap
(
data
->
display
,
displaydata
->
screen
,
X11_TrackColormap
(
display
,
screen
,
colormap
,
visual
,
NULL
);
colormap
,
visual
,
NULL
);
SDL_free
(
colorcells
);
SDL_free
(
colorcells
);
}
}
...
@@ -412,15 +412,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -412,15 +412,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* Is the colormap we need already registered in SDL? */
/* Is the colormap we need already registered in SDL? */
if
((
colormap
=
if
((
colormap
=
X11_LookupColormap
(
data
->
display
,
X11_LookupColormap
(
display
,
screen
,
visual
->
visualid
)))
{
displaydata
->
screen
,
visual
->
visualid
)))
{
xattr
.
colormap
=
colormap
;
xattr
.
colormap
=
colormap
;
/* printf("found existing colormap\n"); */
/* printf("found existing colormap\n"); */
}
else
{
}
else
{
/* The colormap is not known to SDL so we will create it */
/* The colormap is not known to SDL so we will create it */
colormap
=
XCreateColormap
(
data
->
display
,
colormap
=
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
RootWindow
(
data
->
display
,
displaydata
->
screen
),
visual
,
AllocAll
);
visual
,
AllocAll
);
/* printf("colormap = %x\n", colormap); */
/* printf("colormap = %x\n", colormap); */
...
@@ -493,18 +490,16 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -493,18 +490,16 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}
}
status
=
status
=
XStoreColors
(
d
ata
->
d
isplay
,
colormap
,
colorcells
,
ncolors
);
XStoreColors
(
display
,
colormap
,
colorcells
,
ncolors
);
xattr
.
colormap
=
colormap
;
xattr
.
colormap
=
colormap
;
X11_TrackColormap
(
data
->
display
,
displaydata
->
screen
,
X11_TrackColormap
(
display
,
screen
,
colormap
,
visual
,
colorcells
);
colormap
,
visual
,
colorcells
);
SDL_free
(
colorcells
);
SDL_free
(
colorcells
);
}
}
}
else
{
}
else
{
xattr
.
colormap
=
xattr
.
colormap
=
XCreateColormap
(
data
->
display
,
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
RootWindow
(
data
->
display
,
displaydata
->
screen
),
visual
,
AllocNone
);
visual
,
AllocNone
);
}
}
...
@@ -527,8 +522,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -527,8 +522,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
y
=
window
->
y
;
y
=
window
->
y
;
}
}
w
=
XCreateWindow
(
data
->
display
,
w
=
XCreateWindow
(
display
,
RootWindow
(
display
,
screen
),
x
,
y
,
RootWindow
(
data
->
display
,
displaydata
->
screen
),
x
,
y
,
window
->
w
,
window
->
h
,
0
,
depth
,
InputOutput
,
visual
,
window
->
w
,
window
->
h
,
0
,
depth
,
InputOutput
,
visual
,
(
CWOverrideRedirect
|
CWBackPixel
|
CWBorderPixel
|
(
CWOverrideRedirect
|
CWBackPixel
|
CWBorderPixel
|
CWColormap
),
&
xattr
);
CWColormap
),
&
xattr
);
...
@@ -565,7 +559,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -565,7 +559,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
sizehints
->
y
=
y
;
sizehints
->
y
=
y
;
sizehints
->
flags
|=
USPosition
;
sizehints
->
flags
|=
USPosition
;
}
}
XSetWMNormalHints
(
d
ata
->
d
isplay
,
w
,
sizehints
);
XSetWMNormalHints
(
display
,
w
,
sizehints
);
XFree
(
sizehints
);
XFree
(
sizehints
);
}
}
...
@@ -577,7 +571,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -577,7 +571,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
set
=
SDL_FALSE
;
set
=
SDL_FALSE
;
/* First try to set MWM hints */
/* First try to set MWM hints */
WM_HINTS
=
XInternAtom
(
d
ata
->
d
isplay
,
"_MOTIF_WM_HINTS"
,
True
);
WM_HINTS
=
XInternAtom
(
display
,
"_MOTIF_WM_HINTS"
,
True
);
if
(
WM_HINTS
!=
None
)
{
if
(
WM_HINTS
!=
None
)
{
/* Hints used by Motif compliant window managers */
/* Hints used by Motif compliant window managers */
struct
struct
...
@@ -590,40 +584,36 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -590,40 +584,36 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}
MWMHints
=
{
}
MWMHints
=
{
(
1L
<<
1
),
0
,
0
,
0
,
0
};
(
1L
<<
1
),
0
,
0
,
0
,
0
};
XChangeProperty
(
d
ata
->
d
isplay
,
w
,
WM_HINTS
,
WM_HINTS
,
32
,
XChangeProperty
(
display
,
w
,
WM_HINTS
,
WM_HINTS
,
32
,
PropModeReplace
,
(
unsigned
char
*
)
&
MWMHints
,
PropModeReplace
,
(
unsigned
char
*
)
&
MWMHints
,
sizeof
(
MWMHints
)
/
sizeof
(
long
)
);
sizeof
(
MWMHints
)
/
4
);
set
=
SDL_TRUE
;
set
=
SDL_TRUE
;
}
}
/* Now try to set KWM hints */
/* Now try to set KWM hints */
WM_HINTS
=
XInternAtom
(
d
ata
->
d
isplay
,
"KWM_WIN_DECORATION"
,
True
);
WM_HINTS
=
XInternAtom
(
display
,
"KWM_WIN_DECORATION"
,
True
);
if
(
WM_HINTS
!=
None
)
{
if
(
WM_HINTS
!=
None
)
{
long
KWMHints
=
0
;
long
KWMHints
=
0
;
XChangeProperty
(
data
->
display
,
w
,
XChangeProperty
(
display
,
w
,
WM_HINTS
,
WM_HINTS
,
32
,
WM_HINTS
,
WM_HINTS
,
32
,
PropModeReplace
,
PropModeReplace
,
(
unsigned
char
*
)
&
KWMHints
,
(
unsigned
char
*
)
&
KWMHints
,
sizeof
(
KWMHints
)
/
sizeof
(
long
)
);
sizeof
(
KWMHints
)
/
4
);
set
=
SDL_TRUE
;
set
=
SDL_TRUE
;
}
}
/* Now try to set GNOME hints */
/* Now try to set GNOME hints */
WM_HINTS
=
XInternAtom
(
d
ata
->
d
isplay
,
"_WIN_HINTS"
,
True
);
WM_HINTS
=
XInternAtom
(
display
,
"_WIN_HINTS"
,
True
);
if
(
WM_HINTS
!=
None
)
{
if
(
WM_HINTS
!=
None
)
{
long
GNOMEHints
=
0
;
long
GNOMEHints
=
0
;
XChangeProperty
(
data
->
display
,
w
,
XChangeProperty
(
display
,
w
,
WM_HINTS
,
WM_HINTS
,
32
,
WM_HINTS
,
WM_HINTS
,
32
,
PropModeReplace
,
PropModeReplace
,
(
unsigned
char
*
)
&
GNOMEHints
,
(
unsigned
char
*
)
&
GNOMEHints
,
sizeof
(
GNOMEHints
)
/
sizeof
(
long
)
);
sizeof
(
GNOMEHints
)
/
4
);
set
=
SDL_TRUE
;
set
=
SDL_TRUE
;
}
}
/* Finally set the transient hints if necessary */
/* Finally set the transient hints if necessary */
if
(
!
set
)
{
if
(
!
set
)
{
XSetTransientForHint
(
data
->
display
,
w
,
XSetTransientForHint
(
display
,
w
,
RootWindow
(
display
,
screen
));
RootWindow
(
data
->
display
,
displaydata
->
screen
));
}
}
}
else
{
}
else
{
SDL_bool
set
;
SDL_bool
set
;
...
@@ -633,27 +623,27 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -633,27 +623,27 @@ X11_CreateWindow(_THIS, SDL_Window * window)
set
=
SDL_FALSE
;
set
=
SDL_FALSE
;
/* First try to unset MWM hints */
/* First try to unset MWM hints */
WM_HINTS
=
XInternAtom
(
d
ata
->
d
isplay
,
"_MOTIF_WM_HINTS"
,
True
);
WM_HINTS
=
XInternAtom
(
display
,
"_MOTIF_WM_HINTS"
,
True
);
if
(
WM_HINTS
!=
None
)
{
if
(
WM_HINTS
!=
None
)
{
XDeleteProperty
(
d
ata
->
d
isplay
,
w
,
WM_HINTS
);
XDeleteProperty
(
display
,
w
,
WM_HINTS
);
set
=
SDL_TRUE
;
set
=
SDL_TRUE
;
}
}
/* Now try to unset KWM hints */
/* Now try to unset KWM hints */
WM_HINTS
=
XInternAtom
(
d
ata
->
d
isplay
,
"KWM_WIN_DECORATION"
,
True
);
WM_HINTS
=
XInternAtom
(
display
,
"KWM_WIN_DECORATION"
,
True
);
if
(
WM_HINTS
!=
None
)
{
if
(
WM_HINTS
!=
None
)
{
XDeleteProperty
(
d
ata
->
d
isplay
,
w
,
WM_HINTS
);
XDeleteProperty
(
display
,
w
,
WM_HINTS
);
set
=
SDL_TRUE
;
set
=
SDL_TRUE
;
}
}
/* Now try to unset GNOME hints */
/* Now try to unset GNOME hints */
WM_HINTS
=
XInternAtom
(
d
ata
->
d
isplay
,
"_WIN_HINTS"
,
True
);
WM_HINTS
=
XInternAtom
(
display
,
"_WIN_HINTS"
,
True
);
if
(
WM_HINTS
!=
None
)
{
if
(
WM_HINTS
!=
None
)
{
XDeleteProperty
(
d
ata
->
d
isplay
,
w
,
WM_HINTS
);
XDeleteProperty
(
display
,
w
,
WM_HINTS
);
set
=
SDL_TRUE
;
set
=
SDL_TRUE
;
}
}
/* Finally unset the transient hints if necessary */
/* Finally unset the transient hints if necessary */
if
(
!
set
)
{
if
(
!
set
)
{
/* NOTE: Does this work? */
/* NOTE: Does this work? */
XSetTransientForHint
(
d
ata
->
d
isplay
,
w
,
None
);
XSetTransientForHint
(
display
,
w
,
None
);
}
}
}
}
...
@@ -662,7 +652,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -662,7 +652,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if
(
wmhints
)
{
if
(
wmhints
)
{
wmhints
->
input
=
True
;
wmhints
->
input
=
True
;
wmhints
->
flags
=
InputHint
;
wmhints
->
flags
=
InputHint
;
XSetWMHints
(
d
ata
->
d
isplay
,
w
,
wmhints
);
XSetWMHints
(
display
,
w
,
wmhints
);
XFree
(
wmhints
);
XFree
(
wmhints
);
}
}
...
@@ -671,7 +661,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -671,7 +661,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if
(
classhints
!=
NULL
)
{
if
(
classhints
!=
NULL
)
{
classhints
->
res_name
=
data
->
classname
;
classhints
->
res_name
=
data
->
classname
;
classhints
->
res_class
=
data
->
classname
;
classhints
->
res_class
=
data
->
classname
;
XSetClassHint
(
d
ata
->
d
isplay
,
w
,
classhints
);
XSetClassHint
(
display
,
w
,
classhints
);
XFree
(
classhints
);
XFree
(
classhints
);
}
}
...
@@ -688,16 +678,22 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -688,16 +678,22 @@ X11_CreateWindow(_THIS, SDL_Window * window)
e
.
xclient
.
data
.
l
[
1
]
=
_NET_WM_STATE_FULLSCREEN
;
e
.
xclient
.
data
.
l
[
1
]
=
_NET_WM_STATE_FULLSCREEN
;
e
.
xclient
.
data
.
l
[
2
]
=
0l
;
e
.
xclient
.
data
.
l
[
2
]
=
0l
;
XSendEvent
(
data
->
display
,
XSendEvent
(
display
,
RootWindow
(
display
,
screen
),
0
,
RootWindow
(
data
->
display
,
displaydata
->
screen
),
0
,
SubstructureNotifyMask
|
SubstructureRedirectMask
,
&
e
);
SubstructureNotifyMask
|
SubstructureRedirectMask
,
&
e
);
}
}
/* Let the window manager know we're a "normal" window */
_NET_WM_WINDOW_TYPE
=
XInternAtom
(
display
,
"_NET_WM_WINDOW_TYPE"
,
False
);
_NET_WM_WINDOW_TYPE_NORMAL
=
XInternAtom
(
display
,
"_NET_WM_WINDOW_TYPE_NORMAL"
,
False
);
XChangeProperty
(
display
,
w
,
_NET_WM_WINDOW_TYPE
,
XA_ATOM
,
32
,
PropModeReplace
,
(
unsigned
char
*
)
&
_NET_WM_WINDOW_TYPE_NORMAL
,
1
);
/* Allow the window to be deleted by the window manager */
/* Allow the window to be deleted by the window manager */
XSetWMProtocols
(
d
ata
->
d
isplay
,
w
,
&
data
->
WM_DELETE_WINDOW
,
1
);
XSetWMProtocols
(
display
,
w
,
&
data
->
WM_DELETE_WINDOW
,
1
);
if
(
SetupWindowData
(
_this
,
window
,
w
,
SDL_TRUE
)
<
0
)
{
if
(
SetupWindowData
(
_this
,
window
,
w
,
SDL_TRUE
)
<
0
)
{
XDestroyWindow
(
d
ata
->
d
isplay
,
w
);
XDestroyWindow
(
display
,
w
);
return
-
1
;
return
-
1
;
}
}
#ifdef X_HAVE_UTF8_STRING
#ifdef X_HAVE_UTF8_STRING
...
@@ -705,7 +701,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -705,7 +701,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
Uint32
fevent
=
0
;
Uint32
fevent
=
0
;
pXGetICValues
(((
SDL_WindowData
*
)
window
->
driverdata
)
->
ic
,
pXGetICValues
(((
SDL_WindowData
*
)
window
->
driverdata
)
->
ic
,
XNFilterEvents
,
&
fevent
,
NULL
);
XNFilterEvents
,
&
fevent
,
NULL
);
XSelectInput
(
d
ata
->
d
isplay
,
w
,
XSelectInput
(
display
,
w
,
(
FocusChangeMask
|
EnterWindowMask
|
LeaveWindowMask
|
(
FocusChangeMask
|
EnterWindowMask
|
LeaveWindowMask
|
ExposureMask
|
ButtonPressMask
|
ButtonReleaseMask
|
ExposureMask
|
ButtonPressMask
|
ButtonReleaseMask
|
PointerMotionMask
|
KeyPressMask
|
KeyReleaseMask
|
PointerMotionMask
|
KeyPressMask
|
KeyReleaseMask
|
...
@@ -714,7 +710,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -714,7 +710,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}
}
#else
#else
{
{
XSelectInput
(
d
ata
->
d
isplay
,
w
,
XSelectInput
(
display
,
w
,
(
FocusChangeMask
|
EnterWindowMask
|
LeaveWindowMask
|
(
FocusChangeMask
|
EnterWindowMask
|
LeaveWindowMask
|
ExposureMask
|
ButtonPressMask
|
ButtonReleaseMask
|
ExposureMask
|
ButtonPressMask
|
ButtonReleaseMask
|
PointerMotionMask
|
KeyPressMask
|
KeyReleaseMask
|
PointerMotionMask
|
KeyPressMask
|
KeyReleaseMask
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment