mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-07 06:15:56 +02:00
Update get position
This commit is contained in:
@@ -389,18 +389,7 @@ void WindowCtrlUnix::updatePositions()
|
||||
*/
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
bool status = GetWindowPosition( m_display, window, &x, &y, &width, &height );
|
||||
|
||||
/*
|
||||
* Get the position
|
||||
*/
|
||||
int x2;
|
||||
int y2;
|
||||
int width2;
|
||||
int height2;
|
||||
bool status2 = GetWindowPosition2( m_display, window, &x2, &y2, &width2, &height2 );
|
||||
GetWindowPosition( m_display, window, &x, &y );
|
||||
|
||||
/*
|
||||
* Update the list?
|
||||
@@ -418,8 +407,7 @@ void WindowCtrlUnix::updatePositions()
|
||||
}
|
||||
|
||||
//#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "Update pos: %1, %2, %3, %4, %5" ).arg( x ).arg( y ).arg( width ).arg( height ).arg( status ) );
|
||||
emit signalConsole( QString( "Update pos2: %1, %2, %3, %4, %5" ).arg( x2 ).arg( y2 ).arg( width2 ).arg( height2 ).arg( status2 ) );
|
||||
emit signalConsole( QString( "Update pos: %1, %2" ).arg( x ).arg( y ) );
|
||||
emit signalConsole( QString( "Update pos corrected: %1, %2" ).arg( x - left ).arg( y - top ) );
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -460,49 +460,44 @@ void GetWindowFrameExtensions( void *display, quint64 window, int* left, int*
|
||||
/*
|
||||
* Get the window position
|
||||
*/
|
||||
bool GetWindowPosition( void* display, quint64 window, int* pos_x, int* pos_y, int* width, int* height )
|
||||
void GetWindowPosition( void* display, quint64 window, int* pos_x, int* pos_y )
|
||||
{
|
||||
Display* dsp = (Display*)display;
|
||||
|
||||
int x, y;
|
||||
/*
|
||||
* Get position, method 1
|
||||
*/
|
||||
int x1, y1;
|
||||
Window child;
|
||||
XWindowAttributes xwa;
|
||||
int status1 = XTranslateCoordinates( dsp, window, XDefaultRootWindow( dsp ), 0, 0, &x, &y, &child );
|
||||
int status2 = XGetWindowAttributes( dsp, window, &xwa );
|
||||
XTranslateCoordinates( dsp, window, XDefaultRootWindow( dsp ), 0, 0, &x1, &y1, &child );
|
||||
|
||||
/*
|
||||
* Get position, method 2
|
||||
*/
|
||||
int x2, y2;
|
||||
Window root;
|
||||
uint width, height;
|
||||
uint border;
|
||||
uint depth;
|
||||
XGetGeometry( dsp, window, &root, &x2, &y2, &width, &height, &border, &depth );
|
||||
|
||||
int x = x1;
|
||||
int y = y1;
|
||||
|
||||
if( x == 0 && y == 0 )
|
||||
{
|
||||
x = x2;
|
||||
y = y2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Correct the position
|
||||
*/
|
||||
XGetWindowAttributes( dsp, window, &xwa );
|
||||
|
||||
*pos_x = x - xwa.x;
|
||||
*pos_y = y - xwa.y;
|
||||
|
||||
*width = xwa.width;
|
||||
*height = xwa.height;
|
||||
|
||||
return status1 == 0 && status2 == 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the window position
|
||||
*/
|
||||
bool GetWindowPosition2( void* display, quint64 window, int* pos_x, int* pos_y, int* width, int* height )
|
||||
{
|
||||
Display* dsp = (Display*)display;
|
||||
|
||||
Window root_return;
|
||||
int x_return, y_return;
|
||||
unsigned int width_return, height_return;
|
||||
unsigned int border_width_return;
|
||||
unsigned int depth_return;
|
||||
|
||||
int status = XGetGeometry( dsp, window, &root_return, &x_return, &y_return, &width_return,
|
||||
&height_return, &border_width_return, &depth_return );
|
||||
|
||||
*pos_x = x_return;
|
||||
*pos_y = y_return;
|
||||
|
||||
*width = width_return;
|
||||
*height = height_return;
|
||||
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -251,17 +251,7 @@ void GetWindowFrameExtensions( void *display, quint64 window, int* left, int*
|
||||
* @param pos_x Storage for the x coordinate
|
||||
* @param pos_y Storage for the y coordinate
|
||||
*/
|
||||
bool GetWindowPosition( void *display, quint64 window, int* pos_x, int* pos_y, int* win_width, int* win_height );
|
||||
|
||||
/**
|
||||
* @brief GetWindowPosition2. Get the window position.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param pos_x Storage for the x coordinate
|
||||
* @param pos_y Storage for the y coordinate
|
||||
*/
|
||||
bool GetWindowPosition2( void *display, quint64 window, int* pos_x, int* pos_y, int* win_width, int* win_height );
|
||||
void GetWindowPosition( void *display, quint64 window, int* pos_x, int* pos_y );
|
||||
|
||||
/**
|
||||
* @brief GetWindowRectangle. Get the window rectangle.
|
||||
|
||||
Reference in New Issue
Block a user