Skip to content

Commit

Permalink
fixed localization, and geometry logic... again
Browse files Browse the repository at this point in the history
  • Loading branch information
naelstrof committed Feb 27, 2017
1 parent 394393e commit 98399eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else()
set( MANTARGET "maim.1" )
endif()

add_definitions(-DMAIM_VERSION="v4.4.57")
add_definitions(-DMAIM_VERSION="v4.4.58")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")

Expand Down
18 changes: 8 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,16 @@ int app( int argc, char** argv ) {
std::cerr << "\n";
}
}
// Localize to our parent
int px, py;
Window junk;
XTranslateCoordinates( x11->display, maimOptions->parent, selection.id, (int)selection.x, (int)selection.y, &px, &py, &junk );
glm::ivec2 imageloc;
XImage* image = x11->getImage( selection.id, selection.x, selection.y, selection.w, selection.h, imageloc);
// localize our selection now
glm::ivec4 sourceGeo = getWindowGeometry( x11, selection.id );
selection.x -= sourceGeo.x;
selection.y -= sourceGeo.y;
glm::vec4 parentGeo = getWindowGeometry( x11, maimOptions->parent );
selection.x += parentGeo.x;
selection.y += parentGeo.y;
// Snapshot the image
XImage* image = x11->getImage( selection.id, px, py, selection.w, selection.h, imageloc);
if ( maimOptions->format == "png" ) {
// Convert it to an ARGB format, clipping it to the selection.
ARGBImage convert(image, imageloc, glm::vec4(selection.x, selection.y, selection.w, selection.h), 4, x11 );
ARGBImage convert(image, imageloc, glm::vec4(px, py, selection.w, selection.h), 4, x11 );
if ( !maimOptions->hideCursor ) {
convert.blendCursor( x11 );
}
Expand All @@ -357,7 +355,7 @@ int app( int argc, char** argv ) {
convert.writePNG(*out, maimOptions->quality );
} else if ( maimOptions->format == "jpg" || maimOptions->format == "jpeg" ) {
// Convert it to a RGB format, clipping it to the selection.
ARGBImage convert(image, imageloc, glm::vec4(selection.x, selection.y, selection.w, selection.h), 3, x11 );
ARGBImage convert(image, imageloc, glm::vec4(px, py, selection.w, selection.h), 3, x11 );
if ( !maimOptions->hideCursor ) {
convert.blendCursor( x11 );
}
Expand Down
3 changes: 0 additions & 3 deletions src/x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ X11::~X11() {

XImage* X11::getImage( Window draw, int x, int y, int w, int h, glm::ivec2& imageloc ) {
glm::ivec4 sourceGeo = getWindowGeometry( this, draw );
// First we localize the geometry
x -= sourceGeo.x;
y -= sourceGeo.y;
// We need to clamp the selection to fit within the
// provided window.
x = glm::clamp( x, 0, sourceGeo.z-1 );
Expand Down

0 comments on commit 98399eb

Please sign in to comment.